natawut nupairojassembly language1 unix survival guide
TRANSCRIPT
Natawut Nupairoj Assembly Language 1
Unix Survival Guide
Natawut Nupairoj Assembly Language 2
What is Unix ?
• Very popular OS. (Solaris, HP/UX, Ultrix, Linux, FreeBSD, etc.)
• Being used in many medium-end/high-end servers.
• Very stable, flexible, portable.
Natawut Nupairoj Assembly Language 3
Why do you need to care ?
• Good question! It is Windows’ world anyway.• WRONG!
– A lot of servers are Unix-based.– Unix is older than Windows but yet it still has the old
basic concepts.– Unix is considered to be “cleaner” than Windows in
term of coding.– Unix is still more secured than Windows.– Most of network devices are Unix-based (e.g. routers,
caches, mail servers, security servers).– You can find a job with good pay with Unix.
Natawut Nupairoj Assembly Language 4
Unix History
• Born in 1969 as a child of project called “Multrics” (by Bell Labs, GE, and MIT).
• Its famous parents: Ken Thompson and Dennis Ritchie.
• Its famous sibling (and supporter): C language (by Brian Kennigan and Dennis Ritchie).
• First machine: DEC’s PDP-7.• First game on Unix: “space travel”.• Famous game on early Unix: “rogue”.
Natawut Nupairoj Assembly Language 5
Unix Features
• Why is it so popular ?– Multitasking.– Multiuser.– Portability.– Network applications.
Natawut Nupairoj Assembly Language 6
Basic Skills for this Class
• Basic Unix operations: login, logout, directory• Basic Unix commands: man, ls, cd, pwd, rm,
mv, cat, more• Editing commands: pico, vi• Assembler / Debugger: as, ld, gcc, gdb• Which computer you can use ?
– Remote login (using telnet or secure shell).– cpu200, zeus, and athena.
Natawut Nupairoj Assembly Language 7
Basic Unix Operations
• Start using the system: loginlogin: natawutPassword:Last login: Mon Aug 12 22:37:02 from zeus.cp.eng.chula$
• Quitting from the system: logout$ logout
• ALWAYS LOGOUT !!!– Can use “exit” or CTRL-D.
Natawut Nupairoj Assembly Language 8
Editing Keys
• When entering a command at the shell prompt:– erase one character: ctrl-H / backspace– erase the whole line: ctrl-U– stop execution: ctrl-C– pause output to the screen: ctrl-S– resume after a pause: ctrl-Q
Natawut Nupairoj Assembly Language 9
Directory Structure
• All files are organized in “(sub)directory” (folders).– hierarchy: current
directory, parent directory, root directory
– path reference: absolute, relative
/
home usrbin
natawut athasit
Admin bin public_html
Class Images
Natawut Nupairoj Assembly Language 10
Basic Unix Commands
• Getting help: man (manual)$ man ls
$ man man
• format: man <command>
Natawut Nupairoj Assembly Language 11
Basic Unix Commands (cont’)
• Listing all the files: ls$ ls
Admin Class bin public_html
• options: ls -l, ls -a, ls -al, ls <directory>$ ls –l Class
$ ls –al ..
• format: ls [-laCFR] <directory>
Natawut Nupairoj Assembly Language 12
Basic Unix Commands (cont’)
• Understand permissions:$ ls -ltotal 168drwxr-xr-x 3 natawut faculty 4096 Aug 5 16:24 Classdrwxr-xr-x 2 natawut faculty 4096 Jul 10 00:25 Imagesdrwxr-xr-x 2 natawut faculty 4096 Jul 10 00:25 Librarydrwxr-xr-x 8 natawut faculty 4096 Jan 26 2002 Olddrwxr-xr-x 2 natawut faculty 4096 Aug 5 16:09 Publicationsdrwxr-xr-x 2 natawut faculty 4096 Aug 1 01:04 Templates-rw-r--r-- 1 natawut faculty 4800 Aug 1 01:05 class.html-rw-r--r-- 1 natawut faculty 4551 Aug 1 01:17 contact.html-rw-r--r-- 1 natawut faculty 5817 Aug 1 01:21 home.html-rw-r--r-- 1 natawut faculty 3343 Feb 19 17:15 index.html...
Natawut Nupairoj Assembly Language 13
Basic Unix Commands (cont’)
• Finding out where I am: pwd (print working directory)
$ pwd
/home/natawut
• Walking around: cd (changing directory)$ cd Admin
$ pwd
/home/natawut/Admin
Natawut Nupairoj Assembly Language 14
Basic Unix Commands (cont’)
• change to parent directory, root directory.$ pwd
/home/natawut/Admin
$ cd ..
$ pwd
/home/natawut
$ cd /
$ pwd
/
$ cd
$ pwd
/home/natawut
Natawut Nupairoj Assembly Language 15
Basic Unix Commands (cont’)
• change to absolute path, relative path.$ pwd/home/natawut$ cd public_html/Class$ pwd/home/natawut/public_html/Class$ cd /usr$ pwd/usr$ cd$ pwd/home/natawut$ cd ../../usr$ pwd/usr
Natawut Nupairoj Assembly Language 16
Basic Unix Commands (cont’)
• Deleting stuffs: rm (remove)$ rm hw1.asm
• Changing a file’s name / Moving things around: mv (move)
$ mv hw1.asm h1.abc
$ mv h1.abc Class
$ mv h1.abc Class/hw1.txt
Natawut Nupairoj Assembly Language 17
Basic Unix Commands (cont’)
• Displaying file’s content: cat$ cat hw1.asm
• A better version than cat: more$ more hw1.asm
Natawut Nupairoj Assembly Language 18
•Editing Files in Unix
• Several editing programs: pico, vi, emacs• Simple editor: pico
– Available only on cpu200.– Similar to “Notepad” program on Windows.
• For advance users: vi and emacs
Natawut Nupairoj Assembly Language 19
References
• “man” pages.• Grace Todino et. al., Learning the UNIX
Operating System, O’Reilly&Associates, Inc.• Other Unix books.• Links in my homepage.
http://www.cp.eng.chula.ac.th/~natawut