Study guide · Core notes

Linux CLI Core Notes: commands and paths

Reference notes for everyday Linux terminal work: how the shell finds programs, how files and pipes connect, how permission bits add up, and which command to use for packages, services, networks, and disks.

Subject path · GNU/Linux + systemd5 modulesReviewed October 2026

How to read these notes: Items tagged Extra sit outside the everyday command set, such as legacy ifconfig and netstat. Learn the unmarked items first. New to the topic? Start with the overview for domains and a study plan.

Module 1: Shell, paths, and navigation

The shell reads what you type, expands paths and wildcards, then starts a program.

Path tokens and lookup tools used on a typical bash prompt.
Token or commandMeaning
/The root of the file system. An absolute path starts here.
.The current directory. ./script.sh runs a file in this directory if it is executable.
..The parent of the current directory.
~The current user's home directory, such as /home/ada.
pwdPrints the absolute path of the current working directory.
cd, cd -Changes directory. cd with no argument goes home. cd - returns to the previous directory.
ls -lLists files with type, permissions, owner, group, size, and timestamp.
echo $PATHShows the colon-separated list of directories the shell searches for commands.
which, typewhich prints the first executable on PATH. type also tells you if the name is a builtin, alias, or function.
manOpens the manual page. man ls is the first place to check flags.

PATH vs. the current directory: The current directory is usually not on PATH. That is why ./script.sh is required for a local script, and why command not found often means the package is missing or the directory is not listed in PATH. User customizations commonly live in ~/.bashrc.

Quoting and wildcards

  • * matches any string in a filename. ? matches one character.
  • Double quotes allow variable expansion. Single quotes treat the text literally.
  • A space splits arguments, so quote paths that contain spaces: cd "My Files".

Help without leaving the shell

  • man command for the full page.
  • command --help or command -h for a short flag list (not every command supports both).
  • whatis command for a one-line summary from the man database.

Module 2: Files, text, and search

Create, copy, inspect, and locate files before you try to edit them.

CommandWhat it does
cp, cp -rCopies a file. -r is required to copy a directory tree.
mvMoves or renames a file or directory. It does not copy.
rm, rm -rDeletes a file. -r deletes a directory tree. -f skips prompts; use it carefully.
mkdir -pCreates a directory and any missing parents.
touchCreates an empty file or updates the modification time of an existing one.
ln, ln -sln makes a hard link. ln -s makes a symbolic link that points at another path.
cat, lesscat prints a file. less pages through it and is better for long logs.
head, tail -fShows the first or last lines. tail -f follows a log as it grows.
grepPrints lines that match a pattern. Useful flags: -i ignore case, -r recurse, -n line numbers, -v invert.
find /path -name '*.log'Walks the tree by name, type, or other tests. Quote wildcards so the shell does not expand them first.
nanoA simple full-screen editor. vi or vim is common on servers; learn :q to leave it.
tar -czf archive.tar.gz dir/Creates a gzip-compressed archive. Extract with tar -xzf archive.tar.gz.

Pipes and redirection

The shell can send a command's output to a file or to another command. This is how short one-line workflows are built.

OperatorEffect
>Writes standard output to a file, replacing the file if it exists.
>>Appends standard output to a file.
2>Writes standard error to a file. 2>&1 merges errors into standard output.
|Sends the left command's output to the right command's input.
&&Runs the next command only if the previous one succeeded.
||Runs the next command only if the previous one failed.
teeCopies a pipeline to both the screen and a file.

Examples: grep -n error /var/log/syslog | less, ps aux | grep ssh, du -sh * | sort -h. A pipeline does not change the original file unless a later command writes back to it.

Module 3: Permission math and ownership

Every file has a mode for the owner, the group, and everyone else.

Read = 4, write = 2, execute = 1. Add the values for each of the three positions. ls -l shows the same information as letters, such as rwxr-xr-x.

Common octal modes. Execute on a directory means you can enter it, not that it is a program.
ModeLettersTypical use
755rwxr-xr-xPrograms and directories others may enter but not write
644rw-r--r--Regular files that others may read
700rwx------Private directory or script, owner only
600rw-------Private file such as a key or .ssh config
777rwxrwxrwxWorld-writable; avoid except on purpose, and prefer a sticky bit on shared temp directories

Commands

  • chmod 755 file or chmod u+x file changes the mode.
  • chown user:group file changes owner and group. You usually need sudo.
  • umask subtracts permissions from new files. A umask of 022 yields 644 files and 755 directories.

Special bits Extra

  • Sticky bit on a directory (often /tmp, mode 1777): users can delete only their own files.
  • SUID on an executable: the process runs as the file's owner. passwd is the classic example.
  • SGID on a directory: new files inherit the directory's group.

Users, privilege, and processes

Know which account you are, and which process is using the CPU.

Command or fileWhat it does
whoami, idPrints your username, or your UID, GIDs, and group names.
sudo commandRuns one command with root privileges, using your password and the sudoers rules.
su, su -Switches to another account, root by default, using that account's password. su - also loads the target user's environment.
/etc/passwdAccount names, UIDs, home directories, and login shells. It is world-readable.
/etc/shadowPassword hashes. Only root can read it.
ps auxA snapshot of processes, including user, PID, CPU, memory, and command.
topA live view of CPU and memory. htop is a friendlier Extra alternative if it is installed.
kill PID, kill -9 PIDDefault kill sends SIGTERM (15) and asks the process to exit. -9 is SIGKILL and cannot be caught. Try 15 first.

sudo vs. su: sudo keeps an audit trail of who ran what and can allow only selected commands. su is a full switch to another account. On many desktop distributions the root password is not set, so sudo is the intended path.

Module 4: Packages and systemd services

Install software with the distribution's package manager, then manage services with systemctl.

Debian and Ubuntu: apt

sudo apt update
sudo apt install nginx
sudo apt upgrade
apt show nginx          # package details
apt search nginx

update refreshes the package index. install adds a package. upgrade installs newer versions of packages already on the system. Searching does not need sudo.

Fedora and RHEL: dnf

sudo dnf install nginx
sudo dnf upgrade
dnf info nginx
dnf search nginx
sudo dnf remove nginx

dnf refreshes metadata as needed. Service package names can differ: Debian often uses apache2, while RHEL-family systems use httpd.

systemctl commandResult
systemctl status sshShows whether the unit is loaded, active, enabled, and recent log lines. Debian may use ssh; some systems use sshd.
sudo systemctl start nameStarts the service now.
sudo systemctl stop nameStops the service now.
sudo systemctl restart nameStops and starts the service.
sudo systemctl enable nameStarts the service automatically at boot. disable reverses this.
journalctl -u nameShows that unit's logs. -xe jumps to recent errors. -f follows.

Networking from the command line

Prefer ip and ss. Treat ifconfig and netstat as Extra legacy names.

CommandWhat it does
ip a or ip addrLists interfaces and IPv4/IPv6 addresses.
ip routeShows the routing table, including the default gateway.
ss -tulpnShows listening TCP/UDP sockets and the processes that own them.
ping hostTests whether a host replies to ICMP echo. It does not prove a TCP service is open.
traceroute hostLists hops toward a destination. Some systems ship tracepath instead.
dig example.comQueries DNS. dig +short prints a compact answer.
curl -I https://example.comFetches a URL. -I requests headers only. wget downloads to a file by default.
ssh user@hostEncrypted remote shell on TCP port 22. Copy files with scp or rsync.
ifconfig, netstat ExtraLegacy interface and socket tools. Use ip and ss on current distributions.

Name resolution order: the stub resolver usually checks /etc/hosts before DNS servers listed in /etc/resolv.conf. A wrong hosts entry can override a correct public DNS answer.

Module 5: Disks, mounts, and troubleshooting

Separate "how full is the file system" from "how large is this directory."

Command or fileWhat it does
df -hFree space per mounted file system, in human-readable units.
du -sh pathDisk usage of one path. Combine with sort -h to find large directories.
lsblkBlock devices, sizes, and mount points as a tree.
mount, umountAttaches or detaches a file system. You cannot umount a busy mount.
/etc/fstabFile systems mounted at boot. A bad line can delay or block startup.
fsckChecks and repairs a file system. Run it only when the file system is unmounted, or from rescue media.
free -hRAM and swap use. This is memory, not disk.
uname -a, uptimeKernel and architecture; how long the system has been up and the load average.
dmesgKernel ring buffer: disks appearing, driver errors, and OOM kills.
/var/logTraditional text logs. On systemd systems, journalctl is often the first stop.

Read the error before you guess

  • command not found: the program is not installed, or its directory is not on PATH. Do not confuse this with a missing file argument.
  • Permission denied: the account cannot read, write, or execute that path. Check ls -l and whether you need sudo.
  • No space left on device: the file system is full, or inodes are exhausted. Check df -h and df -i.
  • No such file or directory: the path is wrong, or a symlink is broken. Use ls and pwd before rewriting the command.

Frequently asked questions

What is the difference between sudo and su?

sudo runs a single command with root privileges, using your own password and the permissions in the sudoers file. su switches to another user account, root by default, and requires that account's password.

What does chmod 755 mean?

chmod 755 sets owner read + write + execute (7), and group and others read + execute (5). It is the usual mode for programs and directories that others may enter but not write.

Should I still learn ifconfig and netstat?

Learn ip and ss first. ifconfig and netstat are Extra legacy tools. Some older systems still have them, but modern distributions expect ip addr and ss -tulpn.

Continue the Linux CLI study path

Test what you have learned with a timed practice exam.

Linux CLI hub →
Available

Overview

Scope, domains, command map, file-system layout, and a study plan for everyday Linux CLI.

Available · You are here

Core Notes

Technical reference notes for the shell, files, permissions, packages, services, and networking.

Available

Practice Exams

200 original questions with custom exams, explanations, and a score report by domain.

Related Tools

Useful companions while you study.

All study topics →