Skip to content

Linux fundamentals cheat sheet

The Linux commands for files, permissions, users, processes, services and networking that the Linux Fundamentals course uses, on one printable page.

Files and directories

CommandWhat it does
pwd / cd dir / cd -where am I / go there / go back
ls -lalist everything, with permissions and owners
cp -r a b / mv a b / rm -r dircopy / move or rename / delete a tree
mkdir -p a/b/cmake a path, parents included
find / -name '*.conf' 2>/dev/nullfind files by name
cat, less, head -n 20, tail -fread a file, page it, start, follow
du -sh dir / df -hsize of a directory / free disk

Permissions and ownership

CommandWhat it does
chmod 644 f / chmod u+x fset by number / add by letter
chmod -R g+rX dirgroup may read a tree and enter directories
chown user:group fchange owner and group
umaskthe default permissions new files lose
id / groupsmy user, my groups

Numbers: r=4 w=2 x=1, per owner/group/other. 755 programs, 644 files, 600 secrets.

Users

CommandWhat it does
sudo -i / sudo cmdroot shell / one command as root
useradd -m -s /bin/bash namecreate a user with a home
usermod -aG group nameadd to a group (log in again to see it)
passwd nameset a password
getent passwd namelook a user up

Processes and services

CommandWhat it does
ps aux / topevery process / live view
pgrep -a name / kill PID / kill -9 PIDfind / ask to stop / force stop
`systemctl statusstart
systemctl enable --now nginxstart now and at boot
journalctl -u nginx -ffollow a service's log

Networking

CommandWhat it does
ip a / ip raddresses / routes
ss -tlnplistening TCP ports and their programs
ping -c 3 hostis it reachable
curl -I https://siteHTTP headers only
getent hosts name / dig nameresolve a name
nmap -sV hostscan ports and versions (only hosts you may scan)

Shell habits

Ctrl+R search history · !! last command · cmd > file write, >> file append, 2>&1 errors too · cmd | less · man cmd · cmd --help.

Practise it on a real machineLinux Fundamentals course
Open the lab