Finding Your Way on a Linux System
Domain 2 - Finding Your Way on a Linux System
This domain tests command-line literacy: navigating the filesystem, getting help without the internet, and creating or editing files at the shell. It rewards knowing exact syntax and the difference between absolute and relative paths.
Core rules
- The shell expands
~to your home directory,.to the current directory and..to the parent. Absolute paths start at/; relative paths start from$PWD. - Commands are found by searching
$PATHleft to right.echo $PATHshows it;export PATH=$PATH:/opt/binappends a directory for the current shell and its children. - Help sources, in order of specificity:
command --help,man command,info command, and/usr/share/doc/<package>/. - man sections: 1 user commands, 2 system calls, 3 library functions, 5 file formats (e.g.
man 5 passwd), 8 admin commands.man -k keyword(same asapropos) searches descriptions. ls -lshows type, permissions, links, owner, group, size, date and name;ls -aincludes dotfiles.cp -rcopies directories,mvrenames or moves,rm -rremoves recursively,mkdir -pcreates intermediate directories, andfileguesses content type from magic bytes, not from the extension.
Worked example
You are in /home/anna and need the format of the password file. man passwd returns the command in section 1; man 5 passwd returns the file format, which is the correct answer. Reasoning: the same name lives in several sections, and the section number disambiguates them.
Traps
rmhas no recycle bin and no undo.cd ..from/stays at/.- Aliases and shell functions can shadow a binary;
typetells you which one runs. mkdir a/bfails ifais missing - use-p.