Everything in Linux lives in a single directory tree that starts at the root, written as /. There are no drive letters like C:—disks, USB sticks and even devices appear as folders inside that one tree. In this lesson you will learn the three commands you will type more than any others: pwd, ls and cd.
A few directories are worth recognizing early:
/ – the root of everything/home – personal folders for each user (yours is /home/yourname)/etc – system configuration files/bin and /usr/bin – the programs (commands) themselves/var – logs and variable data, e.g. /var/log/tmp – temporary files, cleared on rebootYour home directory is where you keep your own files. The shell abbreviates it as ~ (tilde).
pwd stands for print working directory. It shows the folder your shell is currently "standing in":
pwd
# /home/samEvery command you run operates relative to this location unless you say otherwise, so knowing where you are is step one of everything.
ls lists the contents of a directory. On its own it lists the current directory; give it a path to look elsewhere:
ls # list current directory
ls /etc # list a specific directory
ls -l # long format: permissions, owner, size, date
ls -a # include hidden files (names starting with .)
ls -lh # long format with human-readable sizes (4.0K, 2.3M)
ls -lt # sort by modification time, newest firstHidden files start with a dot, like .bashrc. They are not secret—just tucked away so everyday listings stay clean. The -l output looks like this:
-rw-r--r-- 1 sam sam 4096 Jul 20 10:30 notes.txt
drwxr-xr-x 2 sam sam 4096 Jul 19 09:12 projectsA leading d means directory; a leading - means regular file. We decode the permission letters fully in lesson 5.
cd (change directory) moves your shell to a new location:
cd /var/log # go to an absolute path
cd projects # go into a subfolder of the current directory
cd .. # go up one level to the parent
cd ../.. # up two levels
cd ~ # jump home from anywhere
cd # same as cd ~
cd - # jump back to the previous directoryAn absolute path starts with / and works from anywhere: /home/sam/projects/site. A relative path starts from where you are now: if you are in /home/sam, then projects/site reaches the same place. Two special names exist in every directory: . means "this directory" and .. means "the parent directory".
cd /home/sam/projects # absolute
cd ../downloads # relative: sibling folder of the current onePress Tab while typing a path and the shell completes it for you; press Tab twice to see all options. This is not a luxury—professionals rely on it to avoid typos:
cd /var/lo<Tab> # completes to /var/log/
ls ~/Doc<Tab> # completes to ~/Documents/Also try the Up arrow to recall previous commands, and clear (or Ctrl+L) to clean your screen.
cd ~
pwd
ls -la
cd /etc
ls | head
cd -
pwdRun these in order and predict each output before pressing Enter—that habit turns commands into knowledge.
/; your files live in ~ (your home).pwd shows where you are, ls shows what is there, cd moves you... is the parent directory, . is the current one, cd - returns to the previous location./; relative paths start from your current directory.Next lesson: Working with Files: touch, cp, mv, mkdir — start creating, copying and organizing files.