1 / 17

Chapter 4 The File Structure

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

onawa
Download Presentation

Chapter 4 The File Structure

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. Chapter 4The File Structure

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

  3. The Hierarchical File Structure directory directory directory directory directory directory ordinary file ordinary file ordinary file ordinary file ordinary file

  4. Directory and Ordinary Files 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 compute.c - a C programming language source file compute.o - the object code for the program compute - the same program as an executable file memo.0410 - a text file Absolute Pathnames A path from the root(/) directory to the file

  5. Directories (1/5) 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) Home Directory When first log in on UNIX system, the working directory is home directory Startup Files It gives the operating system specific information about you Bourne Shell and Korn Shell - .profile C Shell - .login

  6. 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. Changing to Another Working Directory Utility - cd (change directory) Usage - cd [absolute pathname, relative pathname] cd (with no argument) - change directory to the home directory . - synonymous with the pathname of the working directory .. - synonymous with the pathname of the parent of the working directory 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 Relative Pathnames A path from the working directory to a file. Directories (3/5)

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

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

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

  11. 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. 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 Directory Access Permissions Directory cannot be executed It means you can search through the directory Access Permissions (3/3)

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

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

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

  17. Symbolic Links (Cont.) Creating a Symbolic Link Removing Hard and Symbolic Links A file exits only as long as a hard link to it exits 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

More Related