Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 The File Structure. Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links.

Similar presentations


Presentation on theme: "Chapter 4 The File Structure. Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links."— Presentation transcript:

1 Chapter 4 The File Structure

2 Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links

3 The Hierarchical File Structure ordinary file directory

4 Directory and Ordinary Files u Filenames  SunOS and Berkeley UNIX system - 255 characters  Older version of UNIX - 14 characters  Case-sensitive  No two files in the same directory can have same name  Filename Extensions l compute.c - a C programming language source file l compute.o - the object code for the program l compute - the same program as an executable file l memo.0410 - a text file u Absolute Pathnames  A path from the root(/) directory to the file

5 Directories (1/5) u The Working Directory  The directory you are working in (=current directory)  To access any file in the working directory, don’t need a pathname  Utility - pwd (print working directory) u Home Directory  When first log in on UNIX system, the working directory is home directory  Startup Files l It gives the operating system specific information about you l Bourne Shell and Korn Shell -.profile l C Shell -.login

6 u Creating a Directory  Utility - mkdir [directory name]  ‘ls’ does not distinguish between a directory and an ordinary file ( option: -F)  ls [directory name] - lists the contents of the directory Directories (2/5) [lab]/user3/kplee/work 59 > ls dong/ graph.c gu/ java/ mSQL/ project/ rand/ unix/ [lab]/user3/kplee/work 60 > mkdir /user3/kplee/work/computer [lab]/user3/kplee/work 61 > ls computer/ graph.c java/ project/ unix/ dong/ gu/ mSQL/ rand/

7 u Changing to Another Working Directory  Utility - cd (change directory)  Usage - cd [absolute pathname, relative pathname] l cd (with no argument) - change directory to the home directory l. - synonymous with the pathname of the working directory l.. - synonymous with the pathname of the parent of the working directory u Deleting a Directory  Utility - rmdir (remove directory) [rm -r]  Usage - rmdir (rm -r) [absolute pathname, relative pathname]  Cannot delete the working directory or a directory that contains files u Relative Pathnames  A path from the working directory to a file. Directories (3/5)

8 u Moving Files from One Directory to Another  Utility - mv (move)  Usage - mv existing-file-list destination-directory u Important Standard Directories and Files  / (root) l The ancestor of all files in the file system  /home l Typically each user’s home directory is subdirectories of the /home directory  /usr l Traditionally includes subdirectories that contain information used by system  /usr/bin, /bin l Contain the standard UNIX utility programs Directories (4/5)

9  /usr/ucb l Contain the networking utilities  /etc, /usr/etc l Administrative, configuration,and other system files are kept here l /etc - includes utilities needed during the booting process l /usr/etc - includes utilities that are most useful after the system is up and running  /var l Includes subdirectories contain the files that vary as the system runs  /dev l Include files that represent peripheral devices  /tmp l Hold temporary files Directories (5/5)

10 Access Permissions (1/3) u Three type of users  Owner  Group  Other u Three type of access  Read  Write  Execute

11 u The ls Utility with the -l and -g Options $ ls -lg letter.0610 check_spell -rw-r--r-- 1 alex pubs 3355 May 2 10:52 letter.0610 -rwxr-xr-x 2 alex pubs 852 May 5 14:03 check_spell  the type of file (first character) ; d : directory, - : file  the file’s access permissions (the next nine characters)  the number of links to the file  the name of the owner of the file  the name of the group that has group access to the file  the size of the file in characters (bytes)  the date and time the file was created or last modified  the name of the file Access Permissions (2/3)

12 u Changing Access Permissions  The owner of the files can modify the access permissions  Utility - chmod (change mode)  Usage - chmod [a,g,o][+,-]{r,w,x} filename  Example $ chmod a+rw letter.0610 $ ls -lg letter.0610 -rw-rw-rw- 1 alex pubs 3355 May 2 10:52 letter.0610 $ chmod o-rw check_spell $ ls -lg check_spell -rwxr-x--- 2 alex pubs 852 May 5 14:03 check_spell u Directory Access Permissions  Directory cannot be executed l It means you can search through the directory Access Permissions (3/3)

13 Links (1/5) u Link is a pointer to a file u Objective - Sharing files u Creating Additional Links  To share a file with another user l Give the user permission to read and write to the file l Allow the user to create a link to the file  Example correspondence personalmemosbusiness to_do personal memosbusiness

14 u Using ln to Create a Link  Utility - ln (link)  Usage - ln to-be-linked-filename new-filename  Example (working directory is /home/jenny) $ ln /home/alex/letter draft Links (2/5) / home jennyalex memo planning /home/alex/letter and /home/jenny/draft

15 Links (3/5) u Example ( 실습 ) $ cat file_a This is file A. $ ln file_a file_b $ cat file_b This is file A. $ vi file_b $cat file_b This is file B after the change. $cat file_a This is file B after the change. $ cat file_c This is file C. $ cp file_c file_d $ cat file_d This is file C. $ vi file_d $cat file_d This is file D after the change. $cat file_c This is file C. $ ls -l file_a file_b file_c file_d $ ls -i file_a file_b file_c file_d

16 Links (4/5) u Removing Links  Use rm utility  When last link is removed, OS release the space the file occupied on the disk u Symbolic Links  Comparison l Hard link - a pointer to a file l Symbolic link - Indirect pointer to a file – 실제 파일의 경로를 내용으로 가진 디렉토리 엔트리  필요성 l 디렉토리에 대한 hard link 는 superuser 만이 만들 수 있다. l 다른 파일 시스템 사이에는 hard link 를 사용할 수 없다.

17 u Symbolic Links (Cont.)  Creating a Symbolic Link  Removing Hard and Symbolic Links l A file exits only as long as a hard link to it exits l When remove a file, be sure to remove all symbolic link to it Links (5/5) [lab]/user3/kplee 42 > ln -s./work/computer/ course [lab]/user3/kplee 44 > ls -al course lrwxrwxrwx 1 kplee archilab 15 Aug 13 19:43 course ->./work/computer/ [lab]/user3/kplee 45 > cd course [lab]/user3/kplee/course 46 > ls test_a test_b [lab]/user3/kplee/course 59 > pwd /user3/kplee/work/computer [lab]/user3/kplee/course 61 > echo $cwd /user3/kplee/course [lab]/user3/kplee/course 66 > cd.. [lab]/user3/kplee/work 67 > echo $cwd /user3/kplee/work


Download ppt "Chapter 4 The File Structure. Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links."

Similar presentations


Ads by Google