1 / 95

COMP 104: Intro to Unix

COMP 104: Intro to Unix. Week 2. Review of Last Week. History of Unix Unix design philosophy The Unix shell, variables and options Unix commands: alias, cat, date, echo, exit, finger, hostname, login, lp, ls, man, more, passwd, set, setenv, uname, wc, whatis, whereis, who, whoami.

shino
Télécharger la présentation

COMP 104: Intro to Unix

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. COMP 104: Intro to Unix Week 2

  2. Review of Last Week • History of Unix • Unix design philosophy • The Unix shell, variables and options • Unix commands: alias, cat, date, echo, exit, finger, hostname, login, lp, ls, man, more, passwd, set, setenv, uname, wc, whatis, whereis, who, whoami

  3. Agenda – Activity 1 • Introduction to the Unix File System • Unix file system • File Types • Directory File Paths • Access Permissions • Demonstration of file system

  4. Agenda – Activity 2 • UNIX Commands • Navigating the File System: • pwd, ls, touch, cd • Demonstration of pwd, ls, touch, and cd • Working With Files: • cp, mv, rm, mkdir, rmdir • Demonstration of cp, mv, rm, mkdir, rmdir

  5. Agenda – Activity 2 Continued • More UNIX Commands • File Permissions: • id, umask, chmod • Demonstration of id, umask, chmod • In class assignment • Break (10 minutes)

  6. Agenda – Activity 3 • vi Editor • Introduction to the vi editor • Practice with the editor • Preview of next week

  7. Activity 1

  8. The Unix File System Everything is aFile in Unix

  9. Types of Unix Files There are Three Types of Files: • Ordinary / Regular Files • Directories • Special Files – Internal representation of a physical device (keyboard, printer, terminal)

  10. The Tree-Structured File System root (/) bin dev etc lib lost+found sys tmp usr bin games lib local spool

  11. Another Example The following directory tree, and files are located under /export/home/smith/comp110 |_[assignment1] | \_assign1-1.doc | |_[assignment2] | \_assign2-1.doc | |_[lab1] \_[doc] | \_bubblesort.man | |_[report] | \_lab1.report | |_[source] \_sort.cpp sort.o

  12. Common Unix Directories /bin stores basic Unix programs /dev contains files that represent devices /etc files for managing the system /lib contains libraries of programs /lost+found contains ‘misplaced’ files /sys contains system source files /tmp temporary storage /usr important directory – contains many things

  13. Unix Directories Root Directory / Your Home Directory /export/home/{userid} $HOME variable • Shows your current home directory • print $HOME - display variable setting

  14. Unix Directories Present Working Directory • Your current location -or- • Current Directory

  15. Unix Commands: pwd Use pwd to display the name of your current working directory /export/home/morris07/> pwd

  16. Present Working Directory

  17. Absolute Path Absolute Path /export/home/morris07/labs NOTE: These always start with a “/” from root.

  18. Unix Commands: cd Use cd to change your working directory /export/home/morris07/> cd {directory name}

  19. Absolute Path

  20. Absolute Path

  21. Relative Path If your pwd was /export/home/morris07/ You could do: cd examples To move into the examples subdirectory

  22. Relative Path

  23. Relative Path (Shorthand) Single dot . Your current directory Double dot .. Your parent directory cd . Takes you to where already are! cd .. Takes you to the pwd’s parent directory. cd ~Takes you to your home directory cd - Takes you to the previous directory

  24. Relative Path

  25. Relative Path

  26. Relative Path

  27. Unix Commands: ls Use ls to list the contents of a directory /export/home/morris07/> ls /export/home/morris07/> ls –l * (long format) /export/home/morris07/> ls –la * (long format, and list all entries including those that begin with a “.”

  28. Unix Commands: ls /export/home/morris07/> ls –F * Flags directories with a “/” and executables with a “*” Using Wildcards: * Any string of characters ?Any one character (not space) [ ] Match any character in the brackets

  29. Unix Commands: ls Examples ls *.c Lists all files ending with ‘.c’ ls file? Lists any file with file and one character at the end ls v[6,7]file Lists v6file and v7file

  30. Unix Commands: ls

  31. Unix Commands: ls

  32. Unix Commands: ls

  33. Unix Commands: ls

  34. Using Relative Path in ls • ls -al .. Lists your parent directory • ls –al ~ Lists your home directory

  35. Question/Answer Session

  36. Activity 2

  37. Unix Commands: touch Use touch to change a file’s access time and modification time to the current date /export/home/morris07/>touch {file name} NOTE: If the file does not exist, touch will create a new file

  38. Unix Commands: id Use id to display your userid and groupid /export/home/morris07/>id

  39. Unix Commands: id

  40. Unix Security • Login name and a password • Encryption on important files • Access permission

  41. Encryption of files • Text page 334 • crypt • Description will make more sense after next week • Requires a key – do not forget the key

  42. Access Permissions Ordinary File • Read: you can read from the file • Write: you can write to the file • Execute: you can execute the file key

  43. Directory Permissions Directory • Read • You can read the directory • Write • You can create, move, copy or remove directory contents • Execute: • You can search the directory

  44. How Permissions are Managed There are three Permission Groups: • Owner: • Owner’s Group: • Everyone Else/Other:

  45. Permissions -rwxrwxrwx 1 morris07 student 512 Jan 12 14:07 file.exe -rw-rw- rw- 1 morris07 student 812 Jan 12 14:22 file.name drw-rw-rw- 1 morris07 student 812 Jan 12 14:22 labs ----------------------------------------------------------------------------------------- r read permission w write permission x execute permission - permission not granted ----------------------------------------------------------------------------------------- ownergroupeverybody At the far left, 1’st character rwx rwx rwx shows type of file. “-” ordinary “d” is directory

  46. Unix Commands: chmod Use chmod to change the file-access permissions on an existing file >chmod{mode} {file} >chmod777 file.name

  47. Numeric Value of Permissions FILE MODE, or MODE read permission = 4 write permission = 2 execute permission = 1 no permission = 0 To calculate the proper permissions you want to assign, simply add the numbers together: read + write + execute = 4 + 2 + 1 = 7 read + write = 4 + 2 = 6 …

  48. chmod: Calculating the Mode Number Meaning 400 Owner has read permission 200 Owner has write permission 100 Owner has execute permission 040 Group has read permission 020 Group has write permission 010 Group has execute permission 004 Everyone else has read permission 002 Everyone else has write permission 001 Everyone else has execute permission -------- 777

  49. Numeric Value of Permissions chmod 777 lab1 Allows rwx to everyone! chmod 755 lab1 Allows rwx to user, and rx to group/others. Or to deny group and others rwx permissions: chmod 700 lab1

  50. Symbolic-Mode File Permissions Letters represent the groups and permissions: u = User, g = Group, o = Others + or – To add or remove a permission from: r = Read, w = Write, x = Execute chmod ugo+rwx lab1 Allows rwx to everyone! Or to deny group and others rwx permissions: chmod go-rwx lab1

More Related