1 / 25

Announcements : Instructor: Yifeng Zhu Email: yzhu@cse.unl

Announcements : Instructor: Yifeng Zhu Email: yzhu@cse.unl.edu Office: 501 Building, Room 2, Cubic 2.2 Office Hour: Monday 4:00-5:00, or by appointment Phone: 472-0820 Grader: Olga Komina Email: okomina@cse.unl.edu Office: 501 Building, Room 5, Cubic 5.7 Office Hour:

phiala
Download Presentation

Announcements : Instructor: Yifeng Zhu Email: yzhu@cse.unl

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. Announcements: • Instructor: Yifeng Zhu • Email: yzhu@cse.unl.edu • Office: 501 Building, Room 2, Cubic 2.2 • Office Hour: Monday 4:00-5:00, or by appointment • Phone: 472-0820 • Grader: Olga Komina • Email: okomina@cse.unl.edu • Office: 501 Building, Room 5, Cubic 5.7 • Office Hour: • Phone: 472-5029 • For those who got new accounts, please register. Otherwise, your new accounts will be closed after two weeks. • A typo on Syllabus: web course link: http://cse.unl.edu/~yzhu/cs251 • Quiz: drop only one. (two zeros, only one to be dropped)

  2. Chapter 2: Exploring the UNIX File System File and File Systems

  3. Understanding Files and Directories: Objectives • After studying this lesson, you should be able to: • File system structure • Navigating, creating and deleting… • Unix permissions • Build your own personal web

  4. Understanding the UNIX File System • In UNIX, a file is the basic component for data storage • UNIX considers everything it interacts with as a file, even attached devices such as monitors • A file system is the UNIX system’s way of organizing files on mass storage devices such as hard and floppy disks

  5. / bin usr etc users lib bin local games include lib Unix file system structure • The file system is a hierarchical structure resembling a rooted tree, anchored at the root (“/”):

  6. Unix file system structure • Every item in the file system is a file (or a link). • Directories can contain file and other directories (called subdirectories). The subdirectory is considered as the child of the parent directory • Each directory may have only one parent. • A directory is a special kind of file that can contain other files and directories

  7. Absolute & Relative Paths • To describe an object in the file system you specify a path. • Paths are either absolute, beginning at the root level: /usr/local/bin/howto • Or they are relative to the current directory: ../stuff/morestuff/afile

  8. Navigating the File System Continued • Any time the \ symbol is the first character in a path, it stands for the root directory • A relative path takes a shorter journey • You can enter the relative path to begin at your current working directory and proceed from there

  9. Navigating the File System cd<dir> change to <dir> cd .. change to parent dir pwd print current directory ls list directory contents ls -l long listing ls -a list all files ls -al long listing, all files

  10. Using Dot and Dot Dot Addressing Techniques • UNIX interprets a single dot character to mean the current directory, and dot dot (two consecutive dots) to mean the parent directory • cd . - keeps you in the current directory • cd .. - returns the user to their home directory

  11. Tilda (~) directory • The tilda (~) represents your home directory. • It is a short cut. It means the same thing as /home/user_name • Example: • Enter your home directory: cd ~ • Enter another person’s home directory: cd ~yzhu

  12. Creating & Deleting files cp copy file or directory mv move file or directory mkdir create a directory rmdir delete a directory rm delete a file rm -r delete recursively rm -rf force recursive delete

  13. Copying files cp copy file or directory • syntax: cp [options] source-filedestination-file • source-file: name and path of file to be copied • destination-file: name and path of resulting copy of the file • options: are optional; not required • Common options: • -i : interactive copy; prompts before overwriting an existing file • -r : recursive copy; copies the entire directory structure from the top down and recreates it at destination • Examples: • cp /etc/passwd . • cp –i /etc/passwd ~ • cp /etc/passwd ~/fileb • cp -r /etc/pcmcia ~

  14. Renaming files mv move file or directory • Better name could be the rename command. • Changes the name of one file to another. • Syntax: mv [options] [old file name] [new file name] • Note, if [new file name] is a directory, you will move [old file name] to that directory and keep the original name.

  15. Removing files rm remove file or directory • Deletes the specified file or files. • This is destructive! • They are gone! • They cannot be retrieved!!! • Syntax: rm [options] [file name] • Note: this does not generally work with directories. • rm –r [directory name]

  16. Unix File Permissions • Because UNIX is a multi-user system, users can set permissions for files they own so that others can read, write, or execute their files • A file’s owner is the person who created it • The permissions the owner sets are listed as part of the file description • The first section of file permission specifiers indicates the owner’s permissions

  17. Unix File Permissions • Each file and directory has permissions that support access control. • Permissions are defined as: read (‘r’) – view contents write (‘w’) – change contents execute (‘x’) – run the file or change to the directory • Permissions are defined in three sets, for the owner, group, and all others. • Directories must be executable to be accessed.

  18. View Permissions $ ls –l /etc/passwd -rw-r--r-- 1 root root 1369 Apr 30 2003 /etc/passwd $ ls –l /bin/ls -rwxr-xr-x 1 root root 46888 Jan 19 2003 /bin/ls* owner group size creation date permissions 1st character: type, ‘-’ for file, ‘d’ directory, ‘s’ special, ‘l’ link Next three are read, write, execute for owner Then, next three for group, and next three for all others. Character means permission granted, ‘-’ means denied.

  19. File Permission Specifiers

  20. Examples: file permissions -rw------- Only owner can read and write -rwxrwxrwx Everyone can read, write and execute (and delete) (not very common!) -rw-r--r-- Everyone can read, but only owner can write

  21. Examples: directory permissions drwx------ Only owner can view, cd into, and delete drwxrwx--- Owner and group can view, write, etc. drwxr-xr-x Everyone can cd into but only owner can modify

  22. Changing Permissions $ chmod [ugoa(+/-)rwx] <dir> Where • u = user, g = group, o = others, a = all; • + = add permission, - = remove To make a directory readable by others: $ chmod go+rx <dir>

  23. Making a web page 1. Create the directory: $ cd (or: cd ~) $ mkdir public_html 2. Set the Unix permissions: $ chmod go+x ~ (or: chmod a+x ~) $ chmod go+rx public_html (or: chmod a+x public_html) 3. Create the index.html file: $ cd ~/public_html $ cp ~yzhu/public_html/cs251/example.html index.html $ chmod go+rx index.html Feel free to edit or substitute your own html file(s).

  24. Chapter Summary • In UNIX, a file is the basic component for data storage. UNIX considers everything to be a file, even attached devices • A file system is the UNIX system’s way of organizing files on mass storage devices such as hard and floppy disks • Every file can be located by using a correct and unique pathname, that is, a listing of names of directories leading to a particular file

  25. Chapter Summary Continued • The standard tree structure starts with the root (/) directory, which serves as the foundation for a nested group of other directories and subdirectories • A path, as defined in UNIX, serves as a map to access any file on the system. Special path( . (the directory itself), .. (the parent directory), ~ (the home directory)) • You can use the chmod command to set permissions for files that you own • Commands: ls, cd, pwd, cp, rm, mkdir, rmdir

More Related