The Linux File System
Operating Systems 1
1
Data Storage on Linux
All data are stored on disk (physical representation) as
files
Linux hides the physical representation by imposing a
logical structure on the data storage
The Linux operating system logical structure for data
storage is the file system
A user of the Linux operating system is unaware of the
physical representation of data, they need only concern
themselves with the logical structure view
2
Physical and Logical Views
DISC SYSTEM
PHYSICAL LAYER OF THE DATA STORAGE
PARTITIONS, PARTITION TABLES ETC..
ADMINISTRATORS VIEW
/ (root)
LOGICAL LAYER OF THE DATA STORAGE
A FILE SYSTEM - A DIRECTORY TREE
THE USERS VIEW
3
The Logical View
The file system is the part of the Linux operating
system that is responsible for the storage of data
– All data is stored in Files
The files in the Linux operating system are organised in
a directory structure
– A directory can contain files
– A directory can contain other directories
– A directory can contain both files and other
directories
4
Very Important Distinction
TYPE WINDOWS LINUX
FILE FILE FILE
DIRECTORY FOLDER FILE
SUB-DIRECTORY SUB-FOLDER FILE
SYSTEM DIRECTORY FOLDER (ROOT) FILE (ROOT)
HOME DIRECTORY FOLDER (HOME) FILE (HOME)
5
The Directory Tree
/ (root)
home bin usr etc
users
students staff
phil nathan cara
f1 A file f2 A file
6
Paths through the File System
A direction starting from root
Through to the location of the target file
Remember that this is the logical path.
Next point in the path denoted by ‘/ ’
First Linux command pwd
– Prints your current location within the file system
this is called the working directory
7
Tracing the path of a file
/ (root)
home bin usr etc
users
students staff /home/users/staff/phil/f1
phil nathan cara
f1 A file f2 A file
8
Absolute Paths
These paths give the full path from the root
Working directory ignored
Here are two absolute paths:
/home/users/staff/phil/f1
/home/users/staff/nathan
9
Relative Paths
These are paths that trace the root between
the current working directory and the file you
wish to describe
Here are two examples with a working
directory of /home/users/
staff/phil/f1
staff/nathan
10
Hypothetical Linux File System
/ (root)
Nathan is logged on to his HOME directory,
consequently, his current working directory
home is /home/users/staff/nathan
users
The absolute pathname to file3 is
students staff /home/users/staff/nathan/letters/file3
phil nathan file1
The relative pathname to his file3 is
letters/file3
code letters
NB: Absolute paths always start with /
file2
file2 file3
11
You never get to see everything
Users only get to see a small part of the file
system
Only administrators see all files from root
onwards
When you log on to Linux you can see from
home onwards
In other words partial branches of the directory
tree (depends on your access rights)
12
So when Logging On
Working directory set to your user name
Only place where you have permission to write
information
But you can read information elsewhere
This all depends on the allocated file
permissions
13
Contents of Working Directory
The ‘ls’ command lists the contents of the
current working directory
Only lists contents one level below the current
directory
14
The ‘ls’ command
/ (root)
home
users Working Directory: staff
Listing: phil nathan
students staff
phil nathan file1
Working Directory: letters
Listing: file2 file3
code letters
file2
file2 file3
15
Changing the Working Directory
The cd command is used to move up and
down the directory structure or tree
Accepts one argument the new working path
This can be absolute or relative path
16
The Change Directory command
/ (root)
Rebecca's HOME directory has
the following absolute
home
pathname
Rebecca’s Home users /home/users/students/rebecca
Directory and
Working directory students staff If Rebecca wished to change
from her HOME directory to the
phil nathan file1
rebecca cara
directory containing the file
code letters HelloWorld.java then she would
Rebecca’s new
java
Working directory need to use the cd command
file2
notes code file2 file3
case selection HelloWorld.java
17
The commands to use
COMMAND LINE DESCRIPTION
> cd /home/users/students/rebecca/java/code cd is the command and
/home/users/students/rebecca/java/code
is the argument (absolute path)
> cd java/code cd is the command and
java/code is the argument (relative path)
> cd cd is the command with no argument
takes you back to your home directory
> cd / cd is the command and
/ is the argument (absolute path again)
> cd . cd is the command and
. is the argument (refers to current working
directory so does nothing)
> cd .. cd is the command and
.. Is the argument moves up to next level in
directory tree (short for parent of working
directory)
18
The whole tree
The tree command prints the directory tree
Operates from working directory
Recursively explores all the branches of the
directory tree
Not just a single path
19
Using the On-Line manual
The man command used to describe in detail
the operation of all other commands in the
Linux Operating System i.e.
Remember you must quit the
man command as it endlesses
loops waiting for the next
query.
When you quit it return you to
the Linux shell
20
Final Exit
The command used to log off the Linux system
Type exit
This will log you off and then end your Linux
session
Do not just kill the window off!
This is bad practice
21
Two Applications to access Linux
putty.exe (xterm terminal emulator)
psftp.exe (Secure File Transfer Protocol)
22
Summary of File System Concepts
Files and Directories
Root
Directory Tree
Home Directory
Working Directory
Absolute Path
Relative Path
23
Summary of OS Commands
ls listing contents of a directory
man description of all OS commands
cd changing the current working
directory
pwd displaying current working directory
tree displaying a directory tree
24