Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda The Linux File System (chapter 4 in text)

Similar presentations


Presentation on theme: "Agenda The Linux File System (chapter 4 in text)"— 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 df, 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 the Linux (Unix) OS, the "root directory" / is the starting directory, and other "child directories", "grandchild directories”, etc. are created The hierarchical structure resembles an "upside-down tree" root / home public user1 user2 user3 ipc144 nled

4 Typical UNIX Directories
Directory Path Description / Root directory (ancestor to all directories). /home Used to store users’ home directories. /home/account Your home directory (where account is name you use to login). This is your working directory after you login. /bin Common system binaries (commands). /usr/bin Common utilities (commands) for users. /usr/sbin Common utilities for user administration. /etc General System Admin. Files (eg passwd) /var Dynamic files (log files) /tmp, /var/tmp Temporary files for programs /dev Device files (terminals, printers, etc.)

5 File Naming Rules The following rules apply to naming ordinary files or "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/ics124/assignments File pathname: /home/username/ops224/assignments/assn1.txt

7 Absolute vs Relative Pathnames
Absolute Pathname A pathname that begins from root. The pathname begins with a slash eg /home/msaul/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. eg. unx (i.e. we are already in /home/msaul)

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 relative pathname, always make certain 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/msaul/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 df / du commands The df command reports file space usage on entire Linux system. This gives an “overall” picture of free disk space remaining on the system. df Filesystem k-blocks Used Available Use% Mounted on /dev/hda % / /dev/hda % /boot shmfs % /dev/shm server8:/home/ % //server8/home The du command reports file space usage on any directory path you specify (eg. Your home directory). All directories and files that are contained within the specified directory and related sizes will be displayed Du /home/matrixid /nled_tutorial /KDesktop/Trash /Kdesktop Disk Partitions Directory paths and related sizes Total size (in bytes) of current directory (matrixid)

13 Making Directories Building directories is similar in approach to building a house Begins from a foundation (eg home directory). Need to build in proper order (add on addition to house in right location). Use a logical scheme. When building directories from different locations, must provide proper absolute or relative pathname!!

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

15 Where do we want to build directory?
Want to build a directory called tmp that branches-off of your home directory Verify which directory 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 ls or ls -ld command)

16 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 mur/dir1 (This would create the parent directory mur and then the child directory dir1. The - p means "create all the directories in the Path").

17 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.

18 Removing Sub-trees To remove a sub-tree (a directory and all of its contents including sub-directories) use rm -r directory (or rm -R directory). The command rm –rf removes both subdirectories and files contained in a directory-path. 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!

19 Listing Directory Contents
ls Compact listing of non-hidden files. ls -a Compact 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 directory file(s) rather than the contents of that directory.


Download ppt "Agenda The Linux File System (chapter 4 in text)"

Similar presentations


Ads by Google