ReferenceBeginner15 min read

Linux Commands List - The Essential Commands, Explained with Examples (Try Them in Your Browser)

A categorized list of essential Linux commands, from pwd, cd, and ls to grep, find, permissions, and process management, each with syntax and examples. Every command on this page can be practiced right in your browser.

Here is a categorized list of the essential Linux commands, each with its syntax, role, and examples.

What makes this list different from others: every command on this page can be practiced right in your browser. Each entry has a practice link that opens the matching WebTerm Learn lesson. There is nothing to install and nothing you can break. Don't just read; when a command catches your eye, go type it.

In the lessons, you drive a terminal like this one yourself

Working with Files and Directories

The highest-frequency group, and the place to start.

CommandSyntaxWhat it doesPractice
pwdpwdPrint the path of the directory you are currently inOpen lesson
cdcd directoryChange directory. cd .. goes up, cd - goes backOpen lesson
lsls [options]List files and directoriesOpen lesson
mkdirmkdir nameCreate a directory. -p creates nested paths in one goOpen lesson
touchtouch filenameCreate an empty file (originally a timestamp updater)Open lesson
mvmv source destinationMove files or directories; also used for renamingOpen lesson
cpcp source destinationCopy files. Use -r for directoriesOpen lesson
rmrm filenameDelete files. -r removes a directory and its contentsOpen lesson
rmdirrmdir nameDelete only empty directories (fails safely if not empty)Open lesson
lnln -s target linknameCreate a symbolic link (a shortcut-like reference)Open lesson

The forms you will type most often:

ls -la              # detailed view, including hidden files
mkdir -p app/src    # create nested directories at once
cp -r docs backup   # copy a whole directory
mv draft.txt notes/ # move into the notes directory
rm -i old.txt       # confirm before deleting

Directories nest inside each other, and the "paths" you handle with pwd and cd are addresses into that nesting.

home/user/docs/report.txt
The path /home/user/docs is an address that walks the nested folders from the outside in

Viewing File Contents

Checking a file from the command line is often faster than opening an editor.

CommandSyntaxWhat it doesPractice
catcat filenamePrint the whole file. Best for short filesOpen lesson
headhead -n N filenameShow only the first lines (10 by default)Open lesson
tailtail -n N filenameShow only the last lines. The classic way to check recent log entriesOpen lesson
lessless filenameScroll through a long file. Quit with qOpen lesson
tail -n 20 access.log   # just the latest 20 log lines
less error.log          # scroll through a long log (q to quit)

Searching and Filtering

For "where is that file" and "which lines contain this string".

CommandSyntaxWhat it doesPractice
findfind path conditionsFind files by name, type, size, and moreOpen lesson
grepgrep pattern filenameFind lines matching a pattern inside filesOpen lesson
wcwc -l filenameCount lines, words, and charactersOpen lesson
find . -name "*.log"          # find .log files under the current directory
grep -n "ERROR" server.log    # matching lines with line numbers
grep -r "TODO" src/           # search a directory recursively
wc -l access.log              # count lines in a log

Pipes and Redirection

The real power of the terminal is combining commands. These are symbols rather than commands, but they matter just as much.

grepwc|
A pipe is a tunnel that streams the left command's output into the right command
SymbolSyntaxWhat it doesPractice
|cmd1 | cmd2Send the output of the left command into the right one (pipe)Open lesson
>cmd > fileWrite output to a file (overwrite)Open lesson
>>cmd >> fileAppend output to the end of a fileOpen lesson
grep "ERROR" app.log | wc -l   # count error lines
ls -la > files.txt             # save the listing to a file
echo "done" >> history.log     # append one line to a log

Compressing and Archiving

CommandSyntaxWhat it doesPractice
tartar -czf name.tar.gz targetBundle and compress files (-czf), or extract (-xzf)Open lesson
tar -czf backup.tar.gz docs/   # compress the docs directory
tar -xzf backup.tar.gz         # extract it
tar -tf backup.tar.gz          # just list the contents

Shell Tricks and Configuration

The group that makes your daily typing faster.

CommandSyntaxWhat it doesPractice
echoecho textPrint text or a variable's value, like echo $HOMEOpen lesson
aliasalias name='command'Give a long command a short nameOpen lesson
exportexport NAME=valueSet an environment variableOpen lesson
envenvList environment variablesOpen lesson
historyhistoryShow your command history. Pairs well with arrow keys and Ctrl+ROpen lesson
manman commandOpen the manual for a commandOpen lesson
alias gs='git status'   # two keystrokes for a frequent command
echo $SHELL             # check which shell you are using
man ls                  # read the manual for ls (q to quit)

Permissions and Root Privileges

Unavoidable on servers. When you hit "Permission denied", come back here.

CommandSyntaxWhat it doesPractice
chmodchmod mode filenameChange file permissions (read, write, execute)Open lesson
chownchown owner filenameChange the owner of a fileOpen lesson
sudosudo commandRun a command with administrator (root) privilegesOpen lesson
chmod +x deploy.sh        # make a script executable
sudo chown app config.yml # hand ownership to the app user

Users and Packages

CommandSyntaxWhat it doesPractice
useraddsudo useradd nameCreate a userOpen lesson
passwdsudo passwd nameSet a user's passwordOpen lesson
aptsudo apt install packageSearch, install, and update software (Debian/Ubuntu family)Open lesson
sudo apt update            # refresh package information
sudo apt install tree      # install tree

Processes and System Health

When someone says "the server feels slow", these are the first commands you reach for.

CommandSyntaxWhat it doesPractice
psps auxList running processesOpen lesson
toptopLive view of CPU and memory usage. Quit with qOpen lesson
killkill PIDTerminate a processOpen lesson
dfdf -hShow free disk spaceOpen lesson
dudu -h pathShow how much space each directory usesOpen lesson
freefree -hShow memory usageOpen lesson
unameuname -aShow OS and kernel informationOpen lesson
ps aux | grep node   # find node processes
df -h                # disk space in human-readable units
du -h -d 1 .         # which directory is eating the space

Services and Scheduled Tasks

CommandSyntaxWhat it doesPractice
systemctlsudo systemctl status serviceStart, stop, and inspect services (daemons)Open lesson
journalctljournalctl -u serviceRead a service's logsOpen lesson
crontabcrontab -eSchedule recurring tasks with cronOpen lesson
sudo systemctl restart nginx   # restart nginx
journalctl -u nginx            # check nginx logs
crontab -l                     # list scheduled tasks

Networking

CommandSyntaxWhat it doesPractice
pingping hostCheck whether you can reach a serverOpen lesson
curlcurl URLSend a request to a URL and read the response. The go-to for APIsOpen lesson
sshssh user@hostConnect securely to a remote serverOpen lesson
ping example.com                        # reachability check
curl -O https://example.com/data.json   # download a file
ssh app@203.0.113.10                    # log in to a server

Turning a List into Commands You Can Actually Use

This list covers nearly everything you need for everyday work. But nobody learns commands by staring at a table. Commands are like vocabulary in a foreign language: they stick exactly as fast as you use them.

WebTerm Learn teaches every command on this page in a safe, browser-based environment where you type them for real. There is nothing to install or configure, and any mistake resets in one click.

Found a command you want in your fingers? Hit "Open lesson" in the table and type it right now.

Related Courses

Ready to practice? Try these interactive courses.

Related Articles

Back to Articles