Chapter 01
Filesystem and navigation
Linux has one directory tree starting at /, with a conventional place for everything. Knowing the layout tells you where to look.
Filesystem layout
Also called FHS, /etc, /var, /usr
- What
- Everything hangs off
/. Key directories:/etcconfiguration,/homeusers' files,/varchanging data such as logs and databases,/usrinstalled programs and libraries,/tmptemporary files,/optadd-on software,/procand/syslive kernel information. - Why
- When you need a config file, a log or a binary on an unfamiliar machine, the layout tells you where it almost certainly is.
- Example
- Nginx config lives in
/etc/nginx, its logs in/var/log/nginx, and the binary in/usr/sbin/nginx.
Absolute and relative paths
Also called pwd, ~, ..
- What
- An absolute path starts at
/, such as/var/log/syslog. A relative path starts from the current directory..is the current directory,..its parent and~your home directory. - Why
- Scripts and cron jobs run from unpredictable directories, so knowing which kind of path you wrote avoids "file not found" surprises.
Watch out
Relative paths in scripts run from cron or systemd, which start in a different working directory than your shell.
Creating, copying, moving and deleting
Also called cp, mv, rm, mkdir, touch
- What
mkdir -pcreates directories including parents,touchcreates an empty file,cp -rcopies,mvmoves or renames, andrmdeletes (-rfor directories). There is no recycle bin.- Why
- Daily file work. Knowing the flags avoids partial copies and accidental overwrites.
mkdir -p app/config
cp -r app app.bak
mv notes.txt docs/notes.md
cp -i draft.txt final.txt
rm -r build/Watch out
rm -rf with a variable or glob you have not checked. Run ls with the same pattern first, and never run it as root out of habit.
Hard and symbolic links
Also called ln -s, symlink, inode
- What
- A symbolic link is a small file pointing to a path. A hard link is another name for the same data on disk (the same inode). Deleting the target breaks a symlink but not a hard link.
- Why
- Symlinks switch versions and config without copying, such as
currentpointing at the latest release directory.
ln -s /opt/app/releases/2026-09-18 /opt/app/current
ls -l /opt/app/current
readlink -f /opt/app/currentGetting help
Also called man, --help, tldr
- What
man cmdopens the manual page,cmd --helpprints a short usage summary, andtype cmdtells you whether a name is a program, a shell builtin or an alias. Search manuals withman -k keyword.- Why
- The manual on the machine matches the installed version exactly, unlike a random web answer.