View
216
Download
1
Embed Size (px)
Citation preview
CS 202Computer Science II Lab
Fall 2009September 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 <filename>’ : save file as <filename>
– ‘:w’ : save file with current name
• Exit program:– ‘:wq’ : Save and Exit
– ‘:q!’ : Exit without Save
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;
}
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++ <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>
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
Remote Login
• Software:– SSH Secure Shell Client– Putty– WinSCP
• Host:– remote.ecc.unr.edu
Remote Login -Putty
Remote Login -Putty
Remote Login -SSH
Remote Login -SSH
Remote Login -SSH
Remote Login -SSH
Remote Login -SSH
Questions?