1 / 20

Agenda

Agenda. The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands: quota, du mkdir, mkdir -p, rmdir rm –r, rm -rf ls, ls -a, ls -F, ls -l, ls -ld. File System.

elvis-morin
Télécharger la présentation

Agenda

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. Agenda The Linux File System (chapter 4 in text) • Directory Structures / Navigation • Terminology • File Naming Rules • Relative vs Absolute pathnames • Unix Commands: • quota, du • mkdir, mkdir -p, rmdir • rm –r, rm -rf • ls, ls -a, ls -F, ls -l, ls -ld

  2. File System • A File System is a structure used to organize programs and data on a computer’s storage device • Linux (Unix) OS has a special file called a directory file used to store ordinary files as well as other directories • Directories allow a computer’s file system to be better organized

  3. / (root) home public user1 user2 user3 ipc144 unx122 Hierarchical File System • In Unix and Linux, the "root directory" /is the starting directory, and contains "child directories", "grandchild directories”,etc. • The hierarchical structure resembles an "upside-down tree"

  4. Typical UNIX Directories • Directory PathDescription/Root directory (ancestor to all files) • /home/account Home directory (where account is name used to login) - this is your working directory when you login • /bin, /sbin Essential system binaries (booting) • /usr/bin Common utilities (commands) for users • /usr/sbin Common utilities for system administration • /etc System admin/config files (eg passwd) • /varDynamic files(log files)/tmp, /var/tmpTemporary files for programs • /dev Device files (terminals, printers, etc.)

  5. File Naming Rules • The following rules apply to naming ordinary files and "directory files": • Some older file systems restrict filename size to 14 characters, most file systems allow for 255 characters (safest to select filename size of 14) • Can use letters (upper & lower case), numbers, period , comma, or underscore _ characters • Upper case is different than lower case • A period at beginning of filename hides file • Avoid spaces and other punctuation in filenames

  6. Pathnames • A pathname is a listing of directories that will lead to a directory or a file • The concept of a pathname relates to every operating system including Unix, Linux, MS-DOS, MS-Windows, Apple-Macintosh, etc.! • Examples: • Directory pathname: • /home/username/unx122/assignments • File pathname: • /home/username/unx122/assignments/assn1.txt

  7. Absolute vs Relative Pathnames • Absolute Pathname • A pathname that begins from root • The pathname begins with a slash e.g. /home/username/unx122 • Relative Pathname • A pathname that is "relative" to the location of the current or "working" directory • Use cd to set the current directory, pwd to display the working (current) directory e.g. unx122 (assuming we are already in /home/username)

  8. Relative Pathnames • Rules: • A relative pathname does NOT begin with a slash • Following symbols can be used: • .. parent directory • . current directory Warning: When using a relative pathname, always make sure you know your present working directory!

  9. Relative Pathnames • Examples: • Change to another directory branch from parent directory: cd ../unx122 • copy sample.c file from your professor’s directory to your current directory:cp /home/profname/ipc144/sample.c .

  10. Relative-to-Home Pathnames • You can specify a pathname as relative-to-home by using a tilde and slash at the start, e.g.~/unx122/notes.html • The tilde ~ is replaced by your home directory (typically /home/your.account/) to make the pathname absolute

  11. Why Learn File Management? • To keep your home directory organized (less searching to find your files) • If files are not FTP’d to other locations and removed, you will run out of disk spaceConsequences of Not Removing Unused Files:- Programs such as cc will not run properly- Your account may be suspended!

  12. quota command • The quota command displays the user’s disk quota and usage. This information is given in terms of blocks and number of files: • $ quota • Disk quotas for user lczegel (uid 6444): • Filesystem blocks quota limit grace files quota limit grace • server13:/home/ 73024 80000 82000 2705 4000 4100

  13. du command • The du command reports file space usage (in blocks) of directory path specified - all directories within the specified directory will be displayed • $ du dir1100 dir1/vi_tutorial1048 dir1/lab32116 dir1/samples4164 dir1 • Options: • -a display files as well as directories • -k display in kbytes rather than blocks Directory paths and sizes Total size (in blocks) of specified directory (dir1)

  14. Creating a Directory Structure • Begin from a foundation (e.g. home directory) • Add directories in proper order - use a logical scheme • When adding directories from different locations, must provide proper absolute or relative pathname!!

  15. Planning Directories • Good directory organization requires planning • Group information together logically • Plan for the future: use dated directories where appropriate (~/2004/Winter, ~/2004/Summer) • Too few directories = excessive number of files in each; too many directories = long pathnames

  16. Where do we want to build directory? • Want to build a directory calledtmp that branches-off from your home directory • Verify directory in which you are located (either look at directory from command prompt or issue the command pwd) • Type mkdir tmp at the Unix prompt, followed by <Enter> • Always verify that directory has been created (e.g. use lsor ls -ld command)

  17. Creating Parent Directories • To create directory paths with parent directories that do not exist you can use the command • mkdir -p pathname • eg. mkdir -p unx122/lab1 • (This would create the parent directory unx122 and the child directory lab1. The -p means "create all directories in the path that don’t already exist")

  18. Removing Directories Removing directories is reverse order of building directories • Issue command rmdir directory • rmdir cannot remove directories containing files or other subdirectories • rmdir cannot remove directories that are anyone's current directory • Need to step back to at least parent directory to remove an empty directory

  19. Removing Sub-trees • To remove a sub-tree (a directory and all of its contents including subdirectories) userm -rdirectory (or rm -R directory). The command rm –rf removes files that are write-protected and issues no messages (-f means “force”). • Caution! Back-up your files before removing. You can use the ftp application to transfer files to another server or your diskette. Refer to next set of notes to learn how to use command-line ftp. • Caution!rm -r can erase large numbers of files very quickly. Use with extreme care!

  20. Listing Directory Contents • ls Compact listing of non-hidden files • ls -aCompact listing of ALL files • ls -l Detailed (long) listing of non-hidden files • ls -F Displays symbols to mark directories (/) and executable files (*) • ls -ld Displays a detailed (long) listing of only specified directory rather than the contents of that directory

More Related