Lesson 2 - Navigating the Linux Filesystem
Interactive Terminal Sim:
Understanding the Filesystem
Every operating system needs a way to organise the files and folders stored on a computer. Linux uses a filesystem to organise everything into a hierarchy of directories and files.
Unlike Windows, which commonly uses drive letters such as
C:, Linux has a single starting point called the
root directory. It is represented by a forward
slash:
/
Everything on a Linux system exists somewhere underneath this directory. Your files, programs, configuration files and even hardware devices are organised within this structure.
You can think of the filesystem like a tree. The root directory is the trunk, directories are branches, and files are the leaves.
Where Am I?
When you open a terminal, you are always working inside a particular directory. This is called your current working directory.
To find out where you currently are, use the pwd
command:
pwd
pwd stands for Print Working Directory.
It prints the full path of the directory you are currently inside.
For example, you might see:
/home/student
This tells you that you are inside the student
directory, which is inside /home.
You can see what is inside your current directory using
ls:
ls
Try using pwd and ls in the terminal.
Knowing where you are and what is around you is the first step to
navigating Linux.
Moving Through Directories
The cd command is used to
change directory. It allows you to move from one
directory to another.
For example, if your current directory contains a folder called
Documents, you can enter it with:
cd Documents
You can then use pwd to confirm where you are:
pwd
To move back to the directory above your current location, use
..:
cd ..
The two dots represent the parent directory — the directory immediately above the one you are currently in.
There is also a shortcut for your home directory:
cd ~
The ~ symbol represents your home directory. This means
you can return home from almost anywhere without needing to type out
the entire path.
Understanding Paths
A path describes the location of a file or directory in the filesystem.
There are two main types of paths: absolute paths and relative paths.
Absolute Paths
An absolute path starts at the root directory
/ and gives the complete location of something.
/home/student/Documents
This path always refers to the same location, regardless of which directory you are currently in.
Relative Paths
A relative path describes a location starting from your current directory.
If you are currently in /home/student, you could enter
your Documents folder with:
cd Documents
You could also refer to it as:
./Documents
The . represents your current directory.
Understanding paths is extremely important when using Linux. Eventually, you will use them to open files, run programs, move files and interact with different parts of the system.