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 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
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
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
.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
..Text editors – VI Saving Files – ‘:w ’ : save file as – ‘:w’ : save file with current name Exit program: – ‘:wq’ : Save and Exit – ‘:q!’ : Exit without Save
showInfo The content of “showInfo.cpp” #include using namespace std; int main() { cout << "My name is : Ray" << endl; cout << "My is : << endl; return 0; }
Compiling and Running C++ programs on Linux The g++ compiler: On Linux and many Unix systems the standard C++ compiler is called g++.
Compiling Program Primitive Compilation – $ g++ Compile with specified output name – $ g++ -o Compile as object – $ g++ -c -o Linking Program – $ g++ -o
Hello World Using any text editor to create file called “hello.cpp” #include using namespace std; //use standard namespace int main() { cout << "Hello World" << endl; return 0; } g++ -o hello hello.cpp./hello
Remote Login Software: – SSH Secure Shell Client – Putty – WinSCP Host: – remote.ecc.unr.edu
Remote Login -Putty
Remote Login -SSH
Questions?