The filesystem and navigating it
Everything on a Linux system is organised into one big tree of files and directories, and to work on a server you must be able to move around it, see what is there, and manipulate files — all by typing. This is the most basic Linux skill and the one you will use every minute of every day. This lesson is the filesystem: how it is laid out, and the handful of commands that navigate and manage it.
One tree, starting at /
Unlike Windows with its C: and D: drives, Linux has a single tree of directories starting from the
root, written /. Everything — every file, every disk, every device — hangs off that one root. A path
like /home/asha/report.txt reads left to right from the root: inside /, the home directory, inside that
asha, inside that the file report.txt.
A few directories you will meet constantly on a server (you do not memorise them all, just recognise them):
/home— users' personal directories (/home/asha). Your files live here./etc— configuration files for the system and installed software. You will edit files here often./var— variable data: logs live in/var/log, which is where you look when something breaks./usr— installed programs and their files./tmp— temporary files, wiped on reboot./root— the home directory of theroot(administrator) user.
Knowing that logs are in /var/log and config is in /etc already makes you useful on a server.
Where am I, and what is here
Two commands anchor you:
pwd # print working directory: the full path of where you currently are
ls # list the files and directories here
ls -l # long listing: permissions, owner, size, modified date — one per line
ls -la # also show hidden files (those starting with a dot, like .bashrc)
ls -la is the one you will type most — it shows everything, with detail. Files and directories whose names
start with . are hidden by convention (configuration files, usually); -a reveals them.
Moving around: cd and paths
You change directory with cd, and you can give it two kinds of path:
- Absolute path — from the root:
cd /var/loggoes there no matter where you are. - Relative path — from where you are now:
cd projectsgoes intoprojectsinside the current directory.
A few shortcuts that save enormous time:
cd /etc # absolute: go to /etc
cd .. # up one level (.. means "the parent directory")
cd ../.. # up two levels
cd ~ # your home directory (~ is shorthand for /home/you)
cd # with no argument, also goes home
cd - # back to the previous directory you were in
. means "the current directory" and .. means "the parent" — these appear everywhere, so learn them now.
Run pwd after each cd until moving around is automatic.
Creating, copying, moving, deleting
The core file operations, each a short command:
mkdir logs # make a directory called logs
mkdir -p a/b/c # make nested directories, creating parents as needed
touch notes.txt # create an empty file (or update its timestamp)
cp notes.txt backup.txt # copy a file
cp -r src/ dest/ # copy a directory and everything in it (-r = recursive)
mv notes.txt archive/ # move a file into a directory
mv old.txt new.txt # rename a file (move is also rename)
rm backup.txt # remove a file
rm -r olddir/ # remove a directory and its contents
Note mv is both "move" and "rename" — there is no separate rename command.
A serious warning about rm
There is no undo and no recycle bin on the Linux command line. rm deletes immediately and permanently.
rm -r somedir/ deletes the directory and everything inside it, gone. And rm -rf / (or a mistyped path)
can destroy a system. So:
- Look before you delete. Run
lson what you are about to remove first. - Be careful with
-rand wildcards.rm -r *deletes everything in the current directory — make sure you are where you think you are (pwdfirst). - Never blindly copy a
rm -rfcommand from the internet. Read what it targets.
This caution is not paranoia; deleting the wrong thing on a production server is a genuine way to cause an
outage, and it happens to people who typed too fast. Slow down around rm.
Looking at a file's contents
You will constantly want to read a file without opening an editor:
cat file.txt # print the whole file
less file.txt # page through a long file (q to quit, / to search)
head file.txt # first 10 lines
tail file.txt # last 10 lines
tail -f app.log # follow a log live as new lines are written — you will use this a lot
tail -f on a log file is one of the most-used commands in operations: you run it and watch new log lines
appear in real time as the application does things. less is how you read a long config or log file
comfortably.
Check your work
One tree from /. Linux has a single directory tree rooted at / (no drive letters); paths read
left-to-right from root. Know: /home (your files), /etc (config), /var/log (logs — where you look when
things break), /usr (programs), /tmp (temp), /root (admin's home).
Locate/list: pwd (where am I), ls / ls -l (detail) / ls -la (with hidden dotfiles). Dotfiles are
hidden config by convention.
Move: cd with absolute (/var/log) or relative (projects) paths; .. = parent, . = current, ~ =
home, cd - = previous. pwd to confirm.
Manage files: mkdir/mkdir -p, touch, cp/cp -r, mv (move and rename), rm/rm -r.
rm has no undo, no recycle bin — it deletes permanently. ls before deleting, pwd before wildcards,
never blind-copy rm -rf. Deleting the wrong thing causes real outages.
Read files: cat (whole), less (page, q//), head/tail (first/last 10), tail -f (follow a log
live — heavily used in ops).
Practice
- Use
pwd,ls -laandcdto explore from/: visit/etc,/var/logand your home directory, runningpwdat each. - From your home directory,
mkdir -p practice/a/b,cdinto it, thencd ../..and confirm withpwd. toucha file,cpit,mv/rename the copy, thenrmit — runninglsbefore and after each step.- Explain, with an example, why
rm -ris dangerous and the checks you do before running it. - Use
cat,head,tailandlesson a file in/var/log(or any text file); quitlesswithq. - Explain what
~,.,..andcd -each mean, with an example of each.
Official documentation
- Ubuntu — The Linux directory structure — What the top-level directories are for.
- GNU Coreutils manual — The reference for
ls,cp,mv,rmand friends. - Linux Filesystem Hierarchy Standard — The standard that defines
/etc,/var,/usrand the rest.
Next: files, permissions and ownership.
Stuck on this lesson?
Being stuck is part of it — but being stuck alone for three days is not. Our internship programme pairs this curriculum with code review and one-to-one help from working developers, and it is free.
About the internship