20
CS 202 Computer Science II Lab Fall 2009 September 3

CS 202 Computer Science II Lab

  • Upload
    sancho

  • View
    43

  • Download
    1

Embed Size (px)

DESCRIPTION

CS 202 Computer Science II Lab. Fall 2009 September 3. Today Topics. File Access Permissions Text Editors VI Emacs Compiling C++ Programs Accessing Linux Remotely Putty SSH. File Access Permissions. user u/group g/other o r or 4 read permission w or 2 write permission - PowerPoint PPT Presentation

Citation preview

Page 1: CS 202 Computer Science II Lab

CS 202Computer Science II Lab

Fall 2009September 3

Page 2: CS 202 Computer Science II Lab

Today Topics

• File Access Permissions• Text Editors– VI– Emacs

• Compiling C++ Programs• Accessing Linux Remotely– Putty– SSH

Page 3: CS 202 Computer Science II Lab

File Access Permissions

• user u/group g/other o• r or 4 read permission• w or 2 write permission• x or 1 execute permission• - no permission• chmod [options] file –change file or directory

access permissions; (+/-/=)– chmod 755 file1 or chmod u=rwx,go=rx file1

Page 4: CS 202 Computer Science II Lab

Text editors - emacs• emacs/xemacs – are text editors used to

create/modify files• emacs [filename]– $ emacs cs202file.cpp

• Note:– C- = Control (Ctrl) key– M- = Meta key, generally the Alt key but can also be the

Esc key• Essential Commands– C-x,C-s Save the file– C-x,C-w Save to a new file– C-x,C-c Exit emacs– C-x,u Undo last edit

Page 5: CS 202 Computer Science II Lab

Text editors – VI..

• There are two mode on this editor:– Command mode– Text-entry mode

• vi [filename]• Back to command mode by using “Esc” key

Page 6: CS 202 Computer Science II Lab

.Text editors – VI.• Inserting text:– ‘i’ : insert before cursor – ‘a’ : append after cursor – ‘R’ : replace the text– ‘I’, ‘A’, ‘o’, ‘O’

• Deleting text:– ‘x’ : delete character under cursor

– ‘dw’ : delete word under cursor

– ‘dd’ : delete line under cursor

Page 7: CS 202 Computer Science II Lab

..Text editors – VI

• Saving Files– ‘:w <filename>’ : save file as <filename>

– ‘:w’ : save file with current name

• Exit program:– ‘:wq’ : Save and Exit

– ‘:q!’ : Exit without Save

Page 8: CS 202 Computer Science II Lab

showInfo• The content of “showInfo.cpp”

#include <iostream>using namespace std;int main() {

cout << "My name is : Ray" << endl;cout << "My email is : [email protected]" << endl;return 0;

}

Page 9: CS 202 Computer Science II Lab

Compiling and Running C++ programs on Linux

• The g++ compiler: On Linux and many Unix systems the standard C++ compiler is called g++.

Page 10: CS 202 Computer Science II Lab

Compiling Program

• Primitive Compilation– $ g++ <programname.cpp>

• Compile with specified output name– $ g++ -o <ouput filename> <programname.cpp>

• Compile as object– $ g++ -c -o <object filename> <programname.cpp>

• Linking Program– $ g++ -o <object filename> <pg1.cpp> <pg2.cpp>

Page 11: CS 202 Computer Science II Lab

Hello World• Using any text editor to create file called “hello.cpp”

#include <iostream> using namespace std; //use standard namespaceint main() {

cout << "Hello World" << endl;return 0;

}

g++ -o hello hello.cpp./hello

Page 12: CS 202 Computer Science II Lab

Remote Login

• Software:– SSH Secure Shell Client– Putty– WinSCP

• Host:– remote.ecc.unr.edu

Page 13: CS 202 Computer Science II Lab

Remote Login -Putty

Page 14: CS 202 Computer Science II Lab

Remote Login -Putty

Page 15: CS 202 Computer Science II Lab

Remote Login -SSH

Page 16: CS 202 Computer Science II Lab

Remote Login -SSH

Page 17: CS 202 Computer Science II Lab

Remote Login -SSH

Page 18: CS 202 Computer Science II Lab

Remote Login -SSH

Page 19: CS 202 Computer Science II Lab

Remote Login -SSH

Page 20: CS 202 Computer Science II Lab

Questions?