Skip to cheat sheet
← Return to Arsenal
CHEAT SHEET / LINUX

ARSENAL / COMMAND CHEAT SHEETS

Linux Commands

The commands, files, and permissions A+ Core 2 expects you to recognize on a Linux desktop.

This sheet follows CompTIA A+ 220-1202 objective 1.9, "identify common features and tools of the Linux client/desktop operating system." Decode any permission set with the chmod widget, then try the scenario quiz.

01 / FILE MANAGEMENT

Working with files and folders

Linux is case-sensitive: Report.txt and report.txt are different files. A $ prompt means a regular user; # means root.

ls1.9

Lists directory contents. -l long format (permissions, owner, group, size, date), -a includes hidden dot files, -h human-readable sizes.

When to use it: seeing what is in a folder and who owns it. ls -la is the everyday version.

ls
ls -la /etc
ls -lh ~/Downloads

pwd1.9

Print working directory: the full path of the folder you are in. Move around with cd (cd .. up, cd ~ home, cd / root).

When to use it: before running something destructive, to be sure you are where you think you are.

pwd

mv1.9

Moves or renames files and folders. There is no separate rename command. -i asks before overwriting.

When to use it: renaming a file, or moving it to another directory.

mv draft.txt final.txt
mv -i report.pdf ~/Documents/

cp1.9

Copies files. -r copies a directory and everything in it; -i asks before overwriting; -p keeps permissions and timestamps.

When to use it: backing up a config file before you edit it.

cp /etc/hosts /etc/hosts.bak
cp -r ~/Projects /media/usb/

rm1.9destructive

Removes files. -r removes directories recursively, -i asks first, -f forces without asking. There is no recycle bin at the command line.

When to use it: deleting files you are certain about. Run pwd and ls first.

rm old.log
rm -ri ~/tmp/build

chmod1.9

Changes permissions using octal (chmod 755) or symbolic notation (chmod u+x, chmod go-w). -R applies to a whole directory tree. Try the decoder below.

When to use it: making a script executable or locking a private file down to its owner.

chmod u+x backup.sh
chmod 600 ~/.ssh/id_ed25519
chmod -R 755 /var/www/site

chown1.9sudo

Changes the owner, and optionally the group, of files: chown user:group file. -R is recursive. Giving a file to someone else needs root.

When to use it: files copied as root are now owned by root and the user cannot edit them.

sudo chown jsmith:jsmith report.ods
sudo chown -R www-data:www-data /var/www/site

grep1.9

Searches text for a pattern and prints matching lines. -i ignores case, -r searches folders, -n shows line numbers, -v shows lines that do not match. Often fed by a pipe (|).

When to use it: finding an error in a log, or filtering another command's output.

grep -i "error" /var/log/syslog
ps aux | grep firefox

find1.9

Searches the directory tree for files by name, type, size, age, or owner: -name, -iname (any case), -type f or d, -size +100M, -mtime -7 (changed in the last 7 days).

When to use it: you know something about a file but not where it is. grep searches inside files; find searches for the files themselves.

find ~ -iname "*.pdf"
find / -type f -size +1G 2>/dev/null

02 / INTERACTIVE

Permission decoder (rwx and octal)

Each class gets read (4), write (2), and execute (1). Add them for each digit: 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--, 0 = ---. Tick boxes, type an octal number, or type a symbolic string; the others update.

Permission checkboxes by class
ClassRead (4)Write (2)Execute (1)Digit
Owner (u)0
Group (g)0
Others (o)0

What ls -l would show

-rwxr-xr-x

chmod 755 filename

The first character of ls -l output is the type: - file, d directory, l symbolic link. On a directory, read lets you list it, write lets you create and delete files inside it, and execute lets you enter it with cd.

03 / FILESYSTEM MANAGEMENT

Checking and attaching storage

fsck1.9sudo

File system check: scans a partition and repairs inconsistencies. Run it on an unmounted file system; checking a mounted one can cause damage. -y answers yes to every repair. For the root file system, it runs at boot or from live media.

When to use it: after a power loss, or when a drive will not mount cleanly. It is the Linux counterpart to chkdsk.

sudo umount /dev/sdb1
sudo fsck -y /dev/sdb1

mount1.9sudo

Attaches a file system to a folder (the mount point) so you can use it. With no arguments it lists what is mounted. umount detaches it. Mounts listed in /etc/fstab happen automatically at boot.

When to use it: a USB drive or second disk did not appear automatically.

sudo mkdir -p /mnt/usb
sudo mount /dev/sdb1 /mnt/usb
sudo umount /mnt/usb

04 / ADMINISTRATIVE + PACKAGES

Root access and installing software

su1.9

Switch user. su - opens a login shell as root and needs the root password. su - jsmith becomes another user. Type exit to return.

When to use it: you need a long session as another account and you know its password. Many distros, including Ubuntu, lock the root password so su to root does not work by default.

su -
su - jsmith

sudo1.9

Runs one command with root privileges, using your own password. Only users allowed in the sudoers file (often the sudo or wheel group) can use it, and each use is logged.

When to use it: almost every admin task. It is the safer, accountable alternative to logging in as root.

sudo apt update
sudo -i

apt1.9sudo

The package manager on Debian, Ubuntu, and Linux Mint (.deb packages). update refreshes the package lists; upgrade installs newer versions; install, remove, and search do what they say.

When to use it: installing or patching software on a Debian-family system. Run update before install or upgrade.

sudo apt update
sudo apt upgrade
sudo apt install vlc
sudo apt remove vlc

dnf1.9sudo

The package manager on Fedora, RHEL, Rocky, and AlmaLinux (.rpm packages). install, upgrade, remove, search, and check-update. dnf replaced the older yum, which is not on the 220-1202 list; on current systems yum is usually just an alias for dnf.

When to use it: installing or patching software on a Red Hat-family system.

sudo dnf check-update
sudo dnf upgrade
sudo dnf install vlc

05 / NETWORK

Addresses, reachability, and DNS

ip1.9

Shows and changes network settings. ip addr (or ip a) lists IP addresses per interface, ip link shows interface state and MAC address, ip route shows the routing table and default gateway. It replaces the older ifconfig.

When to use it: the Linux version of ipconfig: "do I have an address and a gateway?"

ip a
ip route
sudo ip link set eth0 up

ping1.9

Sends ICMP echo requests. Unlike Windows, Linux ping keeps going until you press Ctrl+C. -c sets a count.

When to use it: testing reachability of the gateway, a server, or an outside address.

ping -c 4 192.168.1.1
ping -c 4 8.8.8.8

curl1.9

Transfers data to or from a URL (HTTP, HTTPS, FTP and more). -I fetches headers only, -o saves to a file name you choose, -O keeps the remote file name, -L follows redirects.

When to use it: checking whether a web service answers and with what status code, or downloading a file without a browser.

curl -I https://www.comptia.org
curl -L -O https://example.com/file.iso

dig1.9

Queries DNS and shows the full answer. Add a record type (MX, AAAA, TXT), @server to ask a specific resolver, or +short for just the result.

When to use it: a name will not resolve, or you need to compare what two DNS servers return. It is the Linux tool most like nslookup.

dig comptia.org
dig comptia.org MX +short
dig @1.1.1.1 www.comptia.org

traceroute1.9

Lists each router hop to a destination with timings. Linux uses UDP probes by default; -I switches to ICMP like Windows tracert. Some distros need it installed first.

When to use it: ping fails and you need to see where along the path it stops.

traceroute www.comptia.org
sudo traceroute -I 8.8.8.8

06 / INFORMATIONAL

Help, file contents, processes, and space

man1.9

Opens the manual page for a command. Arrow keys scroll, /word searches, q quits. man -k keyword searches page descriptions.

When to use it: any time you need a switch you do not remember. Many commands also accept --help.

man chmod
man -k partition

cat1.9

Prints a file's contents to the screen. It can also concatenate several files into one with >. For long files, less lets you scroll.

When to use it: a quick look at a short config file.

cat /etc/hosts
cat part1.txt part2.txt > whole.txt

top1.9

A live, refreshing view of processes sorted by CPU use, plus load average, memory, and swap. Press M to sort by memory, k to kill a process by PID, and q to quit.

When to use it: the system is slow right now and you want to see what is eating CPU or RAM. It is the closest thing to Task Manager.

top

ps1.9

A one-time snapshot of processes. On its own it shows only your current shell. ps aux (or ps -ef) lists every process with its PID, owner, and CPU and memory use.

When to use it: finding the PID of a specific program, usually piped into grep.

ps aux
ps aux | grep sshd

du1.9

Disk usage: how much space files and folders use. -s gives a single total per argument, -h human-readable sizes.

When to use it: the disk is full and you need to find which folder is responsible.

du -sh ~/Downloads
du -sh /var/log/*

df1.9

Disk free: size, used, and available space for each mounted file system. -h human-readable.

When to use it: "Is the drive full?" Use df to see which file system is full, then du to see what filled it.

df -h

07 / TEXT EDITOR

nano

nano1.9

A simple terminal text editor. The shortcut bar at the bottom uses ^ for Ctrl: Ctrl+O write out (save), Ctrl+X exit, Ctrl+W search, Ctrl+K cut a line, Ctrl+U paste it.

When to use it: editing a config file. Use sudo for files under /etc, and copy the original first.

sudo cp /etc/hosts /etc/hosts.bak
sudo nano /etc/hosts

08 / COMMON CONFIGURATION FILES

Files worth knowing by name

FileWhat it holds
/etc/passwdOne line per account: username, UID, GID, comment, home directory, and login shell. Readable by everyone. The password field just shows x, because hashes moved to /etc/shadow.
/etc/shadowPassword hashes and password-aging settings. Readable only by root.
/etc/hostsStatic name-to-IP mappings. On a default setup it is checked before DNS, so a bad entry here can override DNS.
/etc/fstabFile systems to mount at boot: device or UUID, mount point, type, and options. A typo can stop the system from booting normally.
/etc/resolv.confThe DNS servers (nameserver lines) and search domains the system uses. On many desktops it is generated by NetworkManager or systemd-resolved, so manual edits can be overwritten.

09 / OS COMPONENTS + ROOT

What is running underneath

PartWhat it does
BootloaderRuns after the firmware (UEFI or BIOS) and loads the kernel. GRUB2 is the common one, and it shows the boot menu when several OSs or kernels are installed.
KernelThe core of the OS. It manages the CPU, memory, devices and drivers, and file systems, and everything else talks to hardware through it. uname -r shows its version.
systemdThe init system on most modern distros. It runs as process ID 1, starts services, and manages them. systemctl status ssh, systemctl restart ssh, systemctl enable ssh (start at boot); journalctl reads its logs.
Root accountThe superuser, UID 0, with unrestricted control of the system. Best practice is to log in as a regular user and use sudo for single tasks, so actions are logged and mistakes stay small.

10 / CHECK YOURSELF

Scenario quiz

Pick the best command for each situation. The explanation appears after you answer.

Command list checked against the CompTIA A+ Core 2 (220-1202) Exam Objectives, version 2.0, objective 1.9. Examples use Ubuntu and Fedora defaults; paths and tools vary slightly by distribution. CompTIA and A+ are trademarks of CompTIA, Inc.; BB Tech Tools is not affiliated with CompTIA. Linux is a registered trademark of Linus Torvalds.