Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:

Similar presentations


Presentation on theme: "Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:"— 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 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" / (root) homepublic user1user2user3ipc144unx122

4 Typical UNIX Directories Directory Path Description / Root directory (ancestor to all files) /home/accountHome directory (where account is name used to login) - this is your working directory when you login /bin, /sbinEssential system binaries (booting) /usr/binCommon utilities (commands) for users /usr/sbinCommon utilities for system administration /etcSystem admin/config files (eg passwd) /varDynamic files (log files) /tmp, /var/tmpTemporary files for programs /devDevice 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 space Consequences 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 dir1 100dir1/vi_tutorial 1048dir1/lab3 2116dir1/samples 4164dir1 Options: -a display files as well as directories -k display in kbytes rather than blocks Total size (in blocks) of specified directory (dir1) Directory paths and sizes

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 called tmp 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 Always verify that directory has been created (e.g. use ls or 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) use rm -r directory (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 lsCompact listing of non-hidden files ls -aCompact listing of ALL files ls -lDetailed (long) listing of non-hidden files ls -FDisplays symbols to mark directories (/) and executable files (*) ls -ldDisplays a detailed (long) listing of only specified directory rather than the contents of that directory


Download ppt "Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:"

Similar presentations


Ads by Google