Presentation is loading. Please wait.

Presentation is loading. Please wait.

Working with Linux Lab 1 1. Login and logout Account – username & password – Note: Linux is case-sensitive Administrator: username = root Logout: exit,

Similar presentations


Presentation on theme: "Working with Linux Lab 1 1. Login and logout Account – username & password – Note: Linux is case-sensitive Administrator: username = root Logout: exit,"— Presentation transcript:

1 Working with Linux Lab 1 1

2 Login and logout Account – username & password – Note: Linux is case-sensitive Administrator: username = root Logout: exit, Ctrl+D 2

3 Linux File System 3 (C) WINDOWSProgram Files FontsSystem32 …. (D) DataMusic OS …. (/) boot home …. etc khoastudent1 root Windows File System Linux File System

4 Directory/file commands List contents of directory : ls [-a] [-l] [directory_name] Print working directory: pwd Change working directory : cd directory_name E.g. cd /home Create new directory : mkdir directory_name Remove a directory: rm -r directory_name Some special symbols : ~ : home directory.. : parent directory 4

5 Directory/file commands Display file content : cat filenameor more filename head filenameor tail filename Copy file(s) or directory: cp [-r] source_file destination_file Remove file or directory rm –r file_name Move (rename) file(s)/directory mv old_pathnew_path 5

6 File system and permissions Each user may owns one or more directories/files Each user has different access rights in different directories/files  users can share their data together  users also can protect their private data 6

7 File system and permissions Access right on directory/file – read (r) – write (w) – execute (x) Each directory/file has 9 access-right bits, divide into 3 groups as follow : – owner – group (e.g. people the same project team) – others (people in public domain) 7

8 File system and permissions 8

9 Changing access rights (1) Symbolic chmod who op mode [-R] file(s) Who: u : owner g : group o : others a : all Mode: r : read w : write x : execute Op + : grant more rights - : revoke rights = : reset rights 9

10 Changing access rights (2) Example $ touch temp $ ls –l temp -rw-r--r-- 1 user1 staff 0 Jun 11 11:44 temp $ chmod o-r temp $ ls -l temp -rw-r----- 1 user1 staff 0 Jun 11 11:44 temp $ chmod u+x, o+r temp $ ls -l temp -rwxr--r-- 1 user1 staff 0 Jun 11 11:44 temp 10

11 Changing access rights (3) Numeric: chmod xyz [-R] file(s) read = 4 write = 2 execute = 1 11 Octal valueAccess right 7rwx 6rw- 5r-x 4r-- 3-wx 2-w- 1--x 0---

12 Changing access rights (4) Example: some common access rights of directory/file(s) 12 Octal valueAccess right 600600rw------- 644644rw-r--r-- 700700rwx------ 751751rwxr-x--x 775775rwxrwxr-x 777777rwxrwxrwx

13 Changing access rights (5) Example $ touch abc $ ls –l abc -rw-r--r-- 1 user1 staff 0 Jun 11 11:44 abc $ chmod 555 abc $ ls -l abc -r-xr-xr-x 1 user1 staff 0 Jun 11 11:44 abc $ chmod 775 abc $ ls -l abc -rwxrwxr-x 1 user1 staff 0 Jun 11 11:44 abc 13

14 Advanced utilities (1) Who is who? who [option] Print current host name hostname Where do they come from? which [filename] How much disk usage? df [option] Clear screen clearOR Ctrl + L 14

15 Advanced utilities (2) Find a specified file : find path –name filename Find lines in file matching a pattern grep pattern file_name Mount and unmount file system mount -t filesystem device_file mount_point umount mount_point 15

16 vi editor Interactive simple editor Can not use mouse Text editing on a buffer Appears on most Unix or Unix-like system 16

17 vi usage 17 syntaxmeaning vi filenameopen/create file a or ichange to edit mode ESC → wq!save and quit ESC → q! not save and quit

18 Cursor movement in vi 18 CmdMeaning nn move cursor left n character(s) nn move cursor down n character(s) nn move cursor up n character(s) nn move cursor right n character(s) Entermove cursor to beginning of next line Gmove cursor to the last line nwnwmove cursor left n word(s) nWnWmove cursor right n word(s)

19 Text manipulation commands 19 CmdMeaning nxnxdelete n character(s) from current cursor position nXnXdelete n character(s) immediately preceding current cursor position D, d$delete all characters from current cursor position to end of line d0, d|delete all characters from left column of screen to character preceding current cursor position on current line

20 Text manipulation commands 20 CmdMeaning ndddelete n line(s) beginning at current line dGdelete all lines, starting with current line, through end of file d1Gdelete all lines, starting with current line, through beginning of file ndwdelete from cursor position through end of n following word ndbdelete from nearest preceding word through character before current cursor position Jjoin the next line at the end of current line

21 Text manipulation commands 21 CmdMeaning ~change case of current character rreplace single character at cursor position nccchange n line(s) beginning at current line cGchange all lines from current line through end of file ncwchange n word(s) on the left of cursor ncbchange n word(s) on the right of cursor

22 Text manipulation commands 22 CmdMeaning nY, nyycopy (yank) n line(s) into buffer nywcopy (yank) n word(s) into buffer y$copy (yank) from current cursor position through end of line into buffer yGcopy (yank) from current line through end of file into buffer pInsert buffer content at the line after current line PInsert buffer content at the line above current line


Download ppt "Working with Linux Lab 1 1. Login and logout Account – username & password – Note: Linux is case-sensitive Administrator: username = root Logout: exit,"

Similar presentations


Ads by Google