Navigating the File Systems
Module 4 Navigating the File Systems
Introduction
A file system is the methods and the data structures
that an operating system uses to keep track of files.
Topics
The Tree Structure
The File System Hierarchy
Path Names
Basic File System Commands
Create and Remove Directories
Eng. Ghassan Abuelwafa 0912235453 2
The Tree Structure
Linux File Structure
Example:
/home/condron/source/xntp
Eng. Ghassan Abuelwafa 0912235453 3
The File System Hierarchy
File System Hierarchy Standard (FHS)
The directories and files noted here are small
subsets of those specified by the FHS document.
The /dev/ Directory
The /etc/ Directory
The /lib/ Directory
The /mnt/ Directory
The /opt/ Directory
The /proc/ Directory
The /sbin/ Directory
Eng. Ghassan Abuelwafa 0912235453 4
Path Names
A PATH is an environment variable that is a list of
directories that the operating system looks in to find
commands issued by the user.
Example 1: # whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
There are two types of path names
Relative Path
Absolute Path
Contd…
Eng. Ghassan Abuelwafa 0912235453 5
Path Names
Absolute path
Accessing a particular directory or file from the other
location, by typing the full details of path.
Absolute path starts with the root (/) directory. It includes all
directories and sub-directories.
A relative path starts in your present working directory.
Relative path
Accessing a particular directory or file from same location, by
typing the file or directory name.
In the case of relative path, the path does not start with a slash.
Paths that don’t start with a slash are always relative.
Eng. Ghassan Abuelwafa 0912235453 6
Basic File System Commands
pwd It displays the user’s present working
directory.
ls Lists the contents of the files and directories
cd Changes and also opens the directory.
cat It combines files and print on the standard
output
find Command The find command searches for files and
directories in the file hierarchy.
Syntax
find <path> -name <file name>
Example: find / -name file1
Eng. Ghassan Abuelwafa 0912235453 7
Create and Remove Directories
Creating directories
Use mkdir command to create a new directory
Syntax
# mkdir <new directory name>
Example: mkdir dir1
Removing directories
There are two commands you can use for removing
directories.
rmdir
rm -r
Eng. Ghassan Abuelwafa 0912235453 8
Lab Exercise
How will you create a new directory?
Use rm –r to remove the existing directory.
Eng. Ghassan Abuelwafa 0912235453 9