Linux Commands to Know for the CompTIA A+ and Linux+ Exams

Both A+ and Linux+ test command-line knowledge, at very different depths. A+ expects recognition of common commands and what they do; Linux+ expects you to use them with options and combine them.

Grouping by task makes them easier to hold than an alphabetical list.

Navigation and inspection

pwd prints the working directory. cd changes it — cd ~ for home, cd - for the previous directory. ls lists; ls -l gives the long format with permissions and ownership, ls -a includes hidden files beginning with a dot, and ls -lh gives human-readable sizes.

find searches the filesystem by name, size, age or type. locate is faster because it queries a pre-built database, at the cost of being only as current as the last database update. which shows the path of an executable.

Files and directories

cp copies, with -r for directories. mv moves and also renames. rm removes, rm -r recursively — and rm -rf deletes without prompting and without mercy, which is worth respecting. mkdir -p creates a directory tree in one go. touch creates an empty file or updates a timestamp. ln -s creates a symbolic link.

Reading files: cat for short ones, less for paging through long ones, head and tail for the beginning and end, and tail -f to follow a log as it is written — the single most useful troubleshooting command on this list.

Permissions and ownership

chmod changes permissions, numerically as in chmod 755 or symbolically as in chmod u+x. chown changes the owner, chgrp the group.

The numeric values: read is 4, write is 2, execute is 1, added together per user, group and other. So 755 is read/write/execute for the owner and read/execute for everyone else; 644 is read/write for the owner and read for everyone else. Those two appear constantly.

sudo runs a single command with elevated privilege and is preferred over su, which switches user entirely, because sudo is logged per command and does not require sharing the root password.

Processes and system state

ps aux lists all running processes. top and htop show them live, ordered by resource use. kill sends a signal to a process ID — the default signal asks politely, and kill -9 forces termination without allowing cleanup, so it is a last resort. killall works by process name.

df -h shows filesystem usage, du -sh the size of a directory, free -h memory, and uptime load averages. systemctl manages services — status, start, stop, enable for boot-time start.

Note the distinction between start and enable: start runs it now, enable makes it run at boot. A service that works until reboot was started but never enabled.

Networking

ip a shows interfaces and addresses, and ip r the routing table. These replaced ifconfig and route, which still appear on exams but are deprecated.

ping tests reachability. traceroute shows the path. dig and nslookup query DNS. ss -tuln lists listening ports, replacing netstat. curl and wget fetch over HTTP. ssh connects to a remote host; scp and sftp transfer files over the same channel.

Text processing

Where Linux+ separates from A+. grep searches for patterns — -i ignores case, -r recurses, -v inverts the match. awk extracts and processes columns. sed performs stream editing and substitution. cut takes fields, sort orders, uniq -c counts adjacent duplicates, and wc -l counts lines.

The pipe is what makes these powerful: grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn produces a ranked list of source addresses from failed SSH logins. Being able to read a pipeline like that is a genuine Linux+ skill.

Redirection: > overwrites a file, >> appends, 2> redirects error output, and 2>&1 merges errors into standard output.

Packages, archives and help

apt on Debian and Ubuntu, dnf or yum on Red Hat derivatives. tar -czvf archive.tar.gz dir/ creates a compressed archive and tar -xzvf extracts one — the flags are create, extract, gzip, verbose, file.

man opens the manual page, and --help gives quick usage. Knowing how to find the option matters more than memorising every flag.

What to remember

Permissions are 4 for read, 2 for write, 1 for execute, with 755 and 644 the common values. systemctl start runs a service now, enable makes it start at boot. ip and ss have replaced ifconfig and netstat. tail -f follows a log live. Pipes chain grep, awk, sort and uniq into real analysis, and reading a pipeline is the Linux+ skill.

Related reading: Linux permissions · ifconfig and ip · YUM and DNF

Comments