circuittimes.com
Subscribe
How-to

Linux Commands Cheat Sheet for Beginners

A Linux commands cheat sheet for beginners with tested examples, a Windows comparison and a free two-page PDF to download.

Rafael Ondrejka

13 min read

Illustration of a terminal window with a gear and a sparkle

Linux commands are short instructions you type into a terminal to work with files, programs, networks and the system itself.

A small set of them covers most daily work. This guide lists the ones to learn first, with examples that were run in a real shell.

It also covers the Linux commands list by task, a Windows-to-Linux comparison and a free PDF cheat sheet to keep. Command descriptions follow the Debian manual pages, and I last checked the sources on October 22, 2026.

The short answer

Start with about a dozen commands: pwd, ls, cd, mkdir, cp, mv, rm, cat, grep, find, chmod and man. They let you move around, manage files, search and read documentation.

Learn pipes and redirection next. They let you chain commands, which is where the terminal becomes powerful.

Good to know

Commands here are for Debian and Ubuntu style systems. Package commands differ on other families, but file and text commands are the same almost everywhere.

Download the cheat sheet

A two-page PDF version of this guide is ready to download. It covers the same commands in compact tables, so you can print it or keep it beside your terminal.

Download the Linux commands cheat sheet PDF. It is free, and it follows the tables below.

How to read a command

Every command follows the same pattern: the command name, then options, then the thing it acts on. Options usually start with a dash.

command [options] [arguments]
ls -l notes

Here ls is the command, -l is an option that asks for a long listing, and notes is the folder to list.

Getting help

You do not need to memorize every option. The manual pages describe each command, and most commands print a short summary with –help.

CommandWhat it does
man lsOpens the manual page for ls
ls –helpPrints a short usage summary
historyLists the commands you typed earlier

The manual's own description of man is an interface to the system reference manuals. Press q to leave a manual page.

A practice folder

You can try every command safely in a folder you create. The example below was run in a real shell. Your folder name and prompt will differ.

$ mkdir notes logs
$ ls
logs
notes
$ echo 'buy milk' > notes/todo.txt
$ printf 'pears\napples\nbananas\napples\n' > notes/fruit.txt
$ cat notes/fruit.txt
pears
apples
bananas
apples

The echo and printf commands write text, and the greater-than sign sends it to a file. That sign is redirection, which is covered below.

Linux commands for beginners: moving around

These commands show where you are and let you move. Descriptions follow the manual pages.

CommandWhat it doesExample
pwdPrints the full name of the current directorypwd
lsLists directory contentsls -l
cdChanges the current directorycd notes
cd ..Moves up one levelcd ..
cdWith no argument, returns to your home directorycd

Files and folders

These commands create, copy, move and remove files and folders.

CommandWhat it doesExample
mkdirMakes directoriesmkdir logs
touchUpdates file timestamps and creates an empty file if it does not existtouch new.txt
cpCopies files and directoriescp a.txt b.txt
mvMoves or renames filesmv a.txt logs/
rmRemoves files or directoriesrm old.txt
rmdirRemoves empty directoriesrmdir logs
lnMakes links between filesln -s target link

Copying and moving in practice

This session continues the practice folder. The copy is moved into logs, then both folders are listed.

$ cp notes/todo.txt notes/todo-copy.txt
$ mv notes/todo-copy.txt logs/todo-old.txt
$ ls notes logs
logs:
todo-old.txt

notes:
fruit.txt
todo.txt

Be careful with rm

The rm command removes files, and the shell has no recycle bin to restore them from. Check the name before you press Enter, and keep it away from wildcards until you are confident.

Adding -r makes rm remove directories and everything inside them, so avoid it, and avoid sudo rm, until you are comfortable.

Do not run a command copied from the internet until you understand it. This is our advice, and it matters most for rm and anything that begins with sudo.

Viewing files

These commands show what is inside a file.

CommandWhat it doesExample
catPrints files to the standard outputcat notes/todo.txt
lessLets you scroll a file one screen at a timeless long.log
headPrints the first lines of a file, 10 by defaulthead -n 2 file.txt
tailPrints the last lines, 10 by defaulttail -n 1 file.txt
wcCounts lines, words and byteswc -l file.txt
$ head -n 2 notes/fruit.txt
pears
apples
$ tail -n 1 notes/fruit.txt
apples
$ wc -l notes/fruit.txt
4 notes/fruit.txt

Searching

The two commands to learn are grep for text inside files and find for files themselves.

CommandWhat it doesExample
grepPrints lines that match a patterngrep -n apples file.txt
findSearches for files in a directory treefind . -name '*.txt'
$ grep -n apples notes/fruit.txt
2:apples
4:apples
$ grep -c apples notes/fruit.txt
2
$ find . -name '*.txt'
./logs/todo-old.txt
./notes/fruit.txt
./notes/todo.txt

The order find prints results in can differ between systems. Put the pattern in quotes, as shown, so the shell leaves it alone until find receives it.

Sorting and counting

These commands change how text is arranged. They are most useful with pipes.

CommandWhat it doesExample
sortSorts lines of textsort file.txt
uniqReports or omits repeated linessort file.txt | uniq
cutPrints selected parts of each linecut -d' ' -f1 file.txt

Pipes and redirection

The Bash manual describes a pipeline as commands separated by a vertical bar, where each command reads the previous command's output. Redirection sends input or output to or from files.

SymbolWhat it doesExample
|Sends one command's output into the nextsort file.txt | uniq
>Writes output to a file, replacing itecho hi > a.txt
>>Adds output to the end of a fileecho more >> a.txt
$ sort notes/fruit.txt
apples
apples
bananas
pears
$ sort notes/fruit.txt | uniq
apples
bananas
pears

Be careful with the single greater-than sign. An existing file with that name is overwritten. Use the double sign to add to the end instead.

A pipe passes the first command's output to the second command. This one lists the folder and keeps only the lines that match.

$ ls notes | grep fruit
fruit.txt

Permissions

Every file has its own set of permissions for the owner, the group and everyone else. The chmod command changes them, and chown changes the owner and group.

CommandWhat it doesExample
chmodChanges file mode bitschmod 600 file.txt
chownChanges file owner and groupchown user:group file.txt
ls -lShows permissions in the first columnls -l file.txt

The GNU manual says a numeric mode is an octal number with one digit each for the owner, the group and others.

Read is worth 4, write is worth 2 and execute is worth 1, and you add the values together.

NumberPermissions
6Read and write
7Read, write and execute
5Read and execute
4Read only
$ chmod 600 notes/todo.txt
$ ls -l notes/todo.txt | cut -d' ' -f1
-rw-------
$ chmod u+x notes/todo.txt
$ ls -l notes/todo.txt | cut -d' ' -f1
-rwx------

The letter form works too: u for the owner, plus to add, and x for execute. Normally the file's owner can change its permissions, and a process with administrative privileges can too.

Processes

These commands show what is running and stop things that are stuck.

CommandWhat it doesExample
psReports a snapshot of current processesps aux
topShows a live view of the running systemtop
killSends a signal to a process, TERM by defaultkill 1234

Use ps to find the process number, then kill with that number. The default signal is TERM, which asks the program to stop cleanly. It does not force the program, so try it first.

Disk and memory

These commands show space and memory use.

CommandWhat it doesExample
dfReports file system space usagedf -h
duEstimates file space usagedu -sh folder
freeDisplays free and used memoryfree -h
unamePrints system informationuname -a

The -h option prints sizes in readable units. It is supported by these commands, but check the manual page on your system if it behaves differently.

Archives

An archive bundles files into one, and compression makes it smaller. The tar command is the usual tool, and gzip compresses.

CommandWhat it doesExample
tarCreates and extracts archivestar -czf backup.tar.gz notes
gzipCompresses and expands filesgzip file.txt
$ tar -czf notes.tar.gz notes
$ tar -tzf notes.tar.gz
notes/
notes/todo.txt
notes/fruit.txt

The letters in tar -czf mean create, compress with gzip and name the file. The -t option lists an archive's contents without extracting, which is a safe way to check it first.

Network and remote access

These commands check connections and work on other machines.

CommandWhat it doesExample
pingSends echo requests to network hostsping -c 4 example.com
ipShows and manipulates routing, devices and interfacesip addr
curlTransfers data from or to a servercurl -I https://example.com
sshLogs in to a remote machinessh user@host
scpCopies files over sshscp file.txt user@host:

The -c option makes ping stop after that many requests. Without it, ping on Linux keeps going until you press Ctrl and C together.

Packages and services

These commands depend on your distribution. The apt command is for Debian and Ubuntu style systems, and the Debian manual describes it as a command-line interface to package management.

CommandWhat it doesExample
sudoRuns one command with administrator rightssudo apt update
aptInstalls and manages packages on Debian and Ubuntusudo apt install htop
systemctlControls the systemd system and service managersystemctl status ssh
journalctlQueries the systemd journaljournalctl -n 20

Use sudo only when you need it and only for one command at a time. Reading the command twice before pressing Enter is a good habit.

Linux commands for Windows

If you use Windows, you have two routes. You can learn the equivalents, or you can run Linux itself. This table pairs common Windows commands with Linux ones. The Windows descriptions come from Microsoft Learn.

Windows commandLinux commandNotes
dirlsLists a directory's files and subdirectories
typecatDisplays a text file's contents
copycpCopies files from one location to another
movemvMoves files from one place to another
delrmDeletes files
clsclearClears the screen
findstrgrepSearches for text patterns in files
tasklistpsLists running processes
taskkillkillEnds processes
ipconfigip addrShows network configuration
wherewhichLocates a command or file

These pairs are rough equivalents, not exact translations. For example, dir and ls both list a directory, and in PowerShell both are aliases for Get-ChildItem, but their options and output differ.

A PowerShell warning

Microsoft says PowerShell has built-in aliases, including ls and dir for the Get-ChildItem cmdlet on Windows. So typing ls in PowerShell works, but it runs a PowerShell command, not the Linux program.

The options will not match. For real Linux commands, use Linux itself.

Running real Linux on Windows

Microsoft says the Windows Subsystem for Linux, or WSL, lets you run a Linux environment on Windows without a separate virtual machine or dual booting. You can install distributions such as Ubuntu and Debian.

Microsoft's install guide says that running wsl –install in PowerShell as administrator installs the features WSL needs and the Ubuntu distribution by default. Restart your machine afterward.

Our WSL guides cover the steps after installation. Read how to reclaim WSL disk space and every wslconfig setting explained.

How to practice Linux commands

Practice beats reading. These ideas are our advice, and they cost nothing.

Use a practice folder

Create one like the example above and break things only there.

Repeat the same tasks

Create, copy, move, search and delete files until it feels natural.

Read one manual page a day

Open man for a command you already use.

Rebuild a small task

For example, count the lines in a file, find the unique ones and sort them.

Use a safe environment

WSL, a virtual machine or a spare computer is better than a machine that holds your only copy of your work.

Linux commands to know first

If you only learn a handful, learn these. Each one appears in the tables above.

ls and cd

See and change where you are.

cat and less

Read files.

cp and mv

Copy and rename.

mkdir and rm

Create and delete.

grep and find

Search text and files.

chmod

Fix permissions.

man

Read the manual.

Chaining commands and exit status

Every command ends with an exit status, a number that says whether it worked. Zero means success, and anything else means a problem.

You can use that to chain commands. Two ampersands run the next command only if the first succeeded.

$ ls plain.txt && echo "found it"
plain.txt
found it
$ ls missing.txt && echo "found it"
ls: cannot access 'missing.txt': No such file or directory

The second command printed nothing after the error, because the first one failed. Two vertical bars do the opposite: they run the next command only if the first failed. A semicolon runs the next command no matter what.

$ ls missing.txt || echo "not there, carrying on"
not there, carrying on
$ ls missing.txt; echo "exit status of the last command: $?"
exit status of the last command: 2

The special variable with a dollar sign and a question mark holds the exit status of the last command.

The commands true and false do nothing except return 0 and 1, which makes them handy for testing. Our Bash scripting tutorial builds on this idea.

Wildcards and quotes

The shell expands wildcards before the command runs. A star matches any characters, so a pattern that ends in dot txt becomes the list of matching files. Quotes switch that off.

$ echo *.txt
my notes.txt plain.txt report 2024.txt
$ echo "*.txt"
*.txt

Quotes also keep a name with spaces together. In my practice folder, one file is called my notes.txt, and another is called report 2024.txt. Quote the name, or put a backslash before each space.

$ ls "my notes.txt" report\ 2024.txt
my notes.txt
report 2024.txt

Without quotes, the shell sees two names, and the command fails to find either. That one habit prevents many errors.

Files with spaces: find and xargs

The command find lists files, and xargs turns a list into arguments for another command. They are a powerful pair, with one trap. Names with spaces break the simple version.

$ find . -name "*.txt" | xargs ls -l
ls: cannot access './my': No such file or directory
ls: cannot access 'notes.txt': No such file or directory
ls: cannot access './report': No such file or directory
ls: cannot access '2024.txt': No such file or directory

The pipe sent names separated by spaces and newlines, so xargs split my notes.txt into two words. The safe version separates names with a null character, which cannot appear in a file name.

$ find . -name "*.txt" -print0 | xargs -0 ls
./my notes.txt
./plain.txt
./report 2024.txt

Use the print0 option in find with the dash zero option in xargs whenever you pipe file names into another command, especially before a delete.

Three habits that prevent accidents

These habits are our advice, and they cost nothing.

List before you delete

Run ls with the same pattern first. If the list looks right, replace ls with rm.

Quote names

Put quotes around any name that might contain a space or special character.

Read the error

The first line of an error usually names the problem. Do not run the command again with a guess.

Common mistakes

Typing in the wrong folder

Check with pwd before deleting.

Forgetting that case matters

File names and commands are case sensitive.

Using sudo as a habit

Use it only for tasks that need it.

Overwriting with a single arrow

One greater-than sign replaces the file.

Pasting commands blindly

Read each part before pressing Enter.

Before you practice, make sure your terminal itself is set up well. Our terminal and shell setup guide covers Windows, macOS and Linux.

When you are ready to automate tasks, our Bash scripting tutorial shows how to turn commands into scripts.

Frequently asked questions

Which Linux commands matter most?

Begin with pwd, ls, cd, mkdir, cp, mv, rm, cat, grep, find, chmod and man. They cover moving, managing files, searching and reading help.

Is there a Linux commands cheat sheet PDF?

Yes. Download our two-page PDF from this guide. It follows the same tables.

How do I learn Linux commands as a beginner?

Practice in a safe folder, repeat small tasks and read manual pages. Run one command at a time and read what it prints.

Can I use Linux commands on Windows?

Yes, through WSL. PowerShell also has aliases such as ls, but they run PowerShell commands.

How do grep and find differ?

grep looks for text inside files. find locates files by name and other properties.

How can I get help with a command?

Enter man followed by the command name, or put –help after the command.

A quick checklist

Up nextEvery wslconfig setting explainedIf you use Windows, WSL is the easiest way to practice. Read our guide to every wslconfig setting explained.

From circuittimes.com/cloud-dev/linux-commands/

Was this guide helpful?

Keep going

More in Developer Tools

See all

The briefing, without the noise.

The stories that matter in technology, every weekday morning.

Free. Unsubscribe in one click.