Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems.

Similar presentations


Presentation on theme: "Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems."— Presentation transcript:

1 Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems

2 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

3 Navigating the File System cd change to cd..change to parent dir pwdprint current directory lslist directory contents ls -llong listing ls -a list all files ls -allong listing, all files

4 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

5 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

6 Creating & Deleting files cpcopy file or directory mvmove file or directory mkdircreate a directory rmdirdelete a directory rm delete a file rm -rdelete recursively rm -rfforce recursive delete

7 Unix File Permissions Each file and directory has permissions that support access control. Permissions are defined as: read read (‘r’) – view contents write write (‘w’) – change contents execute 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.

8 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* permissions 1 st 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. ownergroupsizecreation date

9 File Permission Specifiers

10 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

11 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

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

13 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).

14 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

15 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


Download ppt "Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems."

Similar presentations


Ads by Google