1 / 47

UNIX Talk 2007

UNIX Talk 2007. For CEG Y07 Tang Wai Chung, Matthew (MaFai) Date: 27th AUG, 2007. Overview. CSE working environment UNIX basics UNIX file system Process Management Common UNIX utilities Internet Applications Text Editor: VIM. You are here. SHB 122. SHB 924. SHB 904. 7 x 24 hrs.

kameryn
Download Presentation

UNIX Talk 2007

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIX Talk 2007 For CEG Y07 Tang Wai Chung, Matthew (MaFai) Date: 27th AUG, 2007

  2. Overview • CSE working environment • UNIX basics • UNIX file system • Process Management • Common UNIX utilities • Internet Applications • Text Editor: VIM

  3. You are here SHB 122 SHB 924 SHB 904 7 x 24 hrs CSE Student Laboratories undergrad. postgrad.

  4. 1 GB Storage User Account samba server username: tmchan7 password: i_love_u2 * use the same p/w for XP and UNIX.

  5. Connect to UNIX Workstations ssh sparc?? ssh linux? username: tmchan7 password: *********

  6. User Account (Cont) Personal Homepagehttp://www.cse.cuhk.edu.hk/~[username]orhttp://appsrv.cse.cuhk.edu.hk/~[username] • Put your webpages under directory www &allow world readable permission (discuss later) Email address:[username]@cse.cuhk.edu.hk

  7. Printers & Printing Run out of quota? • Quota transfer • Purchase more quota More detailshttp://www.cse.cuhk.edu.hk/corner/tech/account

  8. Chan Tai Man 07123456 / tmchan7 31-Aug-2010 Etiquette in Labs

  9. Why UNIX? Efficient manipulation (regexp, batch, scripting) Accessible account everywhere Convenient programming environment Java C C++

  10. UNIX Basics Users issue commands to the OS.

  11. Commands • Users type in commands to execute their jobs. • Predefined mnemonics with known meaningse.g. ls = list, cp = copy, rm = remove, etc… • Case-sensitive • Basic syntax[command] –[option(s)] [argument(s)] Instruction for how it acts Target to act on

  12. More About Commands • Multiple commands can be separated with a semicolon (;) • Example: [command 1]; [command 2]; [command 3] • Enter command in several lines using backslash (\) • Example: [a very long command 1]; \ (enter)[a very long command 2]

  13. u Ctrl + clear line l Ctrl + clear screen d c Ctrl Ctrl + + disconnect / logout break a command Terminal

  14. Prompt & Shell • You will find a prompt for you to type commands.e.g. sparc1:/uac/y07/tmchan6> • Shell: command interpreter • Review command history • Auto-complete Ctrl Machine Name Current directory

  15. Lab Exercise 1: Startup Setup your own UNIX environment. • Login the PC • Start “SSH Secure Shell Client” • Edit  Settings  Global Settings: Appearance: Colors  Foreground: White; Background: Black • Quick Connect – Host Name = sparcXX; login using your own account • ls • /uac/gds/wctang/bin/startup.script • source .cshrc • ls(this time the listing should be colourful!)

  16. y07 uac usr / UNIX File System • Multi-leveled hierarchy: directory tree Path /uac/y07 /uac /usr /

  17. UNIX File System • Filename: max. length 256 characters – numbers, alphabets, {_ . [ ]} or other symbols • Hidden file began with ‘.’ • Directory: a special file which stores a group of other files (incl. directory). • Every user has a home directory. • Path • Absolute (relative to /) • Relative (current directory)

  18. UNIX File System • Special directories • . = current directory • .. = parent directory (one level up) • ~ = home directory • ~[userA] = home directory of “userA”

  19. Commands (File Manipulations)

  20. Demo 1 File & Directory Redirection & Pipe

  21. Lab Exercise 2: Save File Listing in a file • mkdir utalkcreate a new directory called “utalk” • cd utalkgo into the new directory • ls –l ~ > home.ls.txtlist the home directory and save the output in “home.ls.txt” • more home.ls.txtread back the content • rm home.ls.txtremove the file • cd ..go up one level • rmdir utalkdelete the directory

  22. File Permission y07 user(u) others(o) group(g) • r: read • w: write • x: execute rwxrwxrwx\u/\g/\o/

  23. Changing Permission • Basic Syntaxchmod [permission_triads/mode] [filename] • permission_triads := [who][action][permissions]who = {u, g, o, a} action = {+, -}permissions = {r, w, x}e.g. chmod a+r allcanread.txt • mode := [u][g][o]r = 4, w = 2, x = 13=w+x; 5 = r+x; 7=r+w+xe.g.1: chmod 640 a.txte.g.2: chmod 751 mydir

  24. Archive & Backup: gtar • Very often we would like store an archive of your files (source codes, reports). • gtar is an utility to compress a set of files to an archive (or vice versa). • Compress: gtar zcvf [archive name] [file list] • Expand: gtar zxvf [archive name]

  25. Managing Print Queues • You can check and remove print jobs only on UNIX (even jobs from XP) • Check print queue & find print job IDlpq –P[printer name] • Remove the job from the queuelprm –P[printer name] [job ID] • Print a postscript file directlylpr –P[printer name] [postscript file] • Check print quotasprintquota

  26. Using “man” • The command man will display the manual of other commands.e.g. man lsexplains the details & options with ls • d,f: Forward; b,Ctrl+b: back • /: search for keywords in the manualn: next matched items • q: quit

  27. Email Client: Pine • Pine is a fast, simple and easy-to-use email client on UNIX systems. • With a simple terminal, you can check and send emails everywhere. • You will never be afraid of being infected by unknown attachment from emails! • You can also edit your own email filter script for efficient categorization. (ref: procmail)

  28. Pine: Interface

  29. Pine: Compose Email

  30. Pine: Read Email

  31. Pine: Read Attachment

  32. Demo 2 File Permission Email: Pine

  33. Powerful Editor: VIM • VIM is one of the most powerful text editor in which you can enter the most letters with less number of keystrokes • Syntax highlight is available in nearly all languages you will use here(C, C++, Java, Pascal, HTML, PHP, SQL) • Automatic backup (.swp file) • Highly customizable • Strong support community including

  34. Modes in VIM • In normal mode of VIM, you issue commands instead of inserting letters. • You can enter to insert mode by pressing <i>, <a>, <o>, etc .. • Insert mode, you can type as you do in notepad. • Return to normal mode by pressing <Esc>

  35. Modes in VIM (Cont) <i>, <a>, <o> COMMAND copy & paste formatting INSERT type your codes edit your text <Esc> visual

  36. Move around (Command Mode) • You can use cursor keys or <h> = left; <l> = right; <j> = down; <k> = up • <Ctrl-u> = up half page<Ctrl-d> = down half page<Ctrl-b> = back 1 page<Ctrl-f> = forward 1 page

  37. Move around (Command Mode) • <$>: end of line; <^>: beginning of line; <0>: first position. • <{no}G>: go to line {no} • <gg>: beginning of file • <G>: end of file

  38. Save & Quit • <ZZ>: write file and exit (time to sleep!) • <:w>: save with same name • <:q>: quit • <:wq>: save and quit • When you add ‘!’ at the end of w or q, you force to execute the command. • <:sav {filename}>: save as.

  39. Deleting ... Undo / Redo • <d{type}>: delete 1 object of {type} • <dd>: delete a line • <dw>: delete one word • <d3w>: delete 3 words • <y{type}>: yank (copy) 1 object • <yy>: copy a line to buffer • <p>: paste the buffer content • <u>: undo • <Ctrl-r>: redo

  40. NNTP News Reader: Tin • Most of our courses have newsgroup in the NNTP server. • Tin is fast, simple and easy-to-use news reader on UNIX. • Tin keeps you with the latest news from courses (hints? delay?). • Check and post your news everywhere with a terminal.

  41. Pin: NG Subscription

  42. Tin: Reading News

  43. Tin: Posting News (VIM)

  44. Demo 3 Powerful Editor: VIM News Reader: TIN

  45. Lab Exercise 3: Internet Utilities • Use pine to send an email to me (wctang) using the subject “Y07 [username]” • Use tin to subscribe the newsgroup cuhk.testUse VIM to edit and post in this group.

  46. Q & A / Free Chat Thank you for your attention! See you all again in ERG2020B!

More Related