Linux · Getting started

Basic Linux Terminal Commands Everyone Should Know

By , Editor · · Beginner guide
The short answer

The set you actually need every day is small: pwd, ls and cd to move around; cp, mv, rm, mkdir, touch, cat and less to work with files; find and grep to search; chmod and chown for permissions; ps, top/htop and kill for processes; apt or dnf to install software; sudo to run one command as administrator; and man or --help when you get stuck. Learn these and you can drive almost any Linux system.

Coming from Windows? The terminal is Linux's equivalent of Command Prompt or PowerShell, but it is far more central to how the system is used and maintained. The good news is that the commands below are remarkably consistent: they come from the GNU coreutils and the Bash shell, so they work the same on Ubuntu, Debian, Fedora, Arch and nearly every other distribution. The main thing that changes between distros is the package manager, which we cover near the end.

One habit that makes everything easier

Press Tab to auto-complete file names and commands, and use the Up arrow to recall previous commands. These two keys save an enormous amount of typing — and typos. If a command seems stuck, Ctrl + C cancels it and returns you to the prompt.

Everything in Linux lives in a single tree that starts at / (the "root"). Your personal files live under your home directory, written as ~ (for example /home/alex). These three commands tell you where you are and let you move:

CommandWhat it doesExample
pwdPrint working directory — shows your current locationpwd
lsList the files in a directoryls -lah
cdChange directorycd /var/log

A few moves worth memorising:

cd ~        # go to your home directory
cd ..       # move up one level
cd -        # jump back to the previous directory
ls -lah     # long listing, all files (incl. hidden), human-readable sizes

The -a flag reveals hidden files — the GNU coreutils manual defines it as not ignoring file names that start with a dot. -l gives the detailed "long" view with permissions and sizes, and -h prints sizes as KB/MB/GB instead of raw bytes. Flags can be combined, so ls -lah does all three at once.

2. Working with files: cp, mv, rm, mkdir, touch, cat, less

This group creates, copies, moves, reads and deletes files and folders.

CommandWhat it doesExample
mkdirMake a new directorymkdir projects
touchCreate an empty file (or update its timestamp)touch notes.txt
cpCopy a file or foldercp notes.txt backup.txt
mvMove or renamemv notes.txt archive/
rmRemove (delete) a filerm old.txt
catPrint a whole file to the screencat notes.txt
lessView a long file one page at a timeless /var/log/syslog

To copy or delete a whole folder, add the recursive flag -r:

mkdir -p projects/website/css   # -p creates the whole path at once
cp -r projects backup-projects  # copy a directory and everything in it
mv report.pdf ~/Documents/      # move a file into another folder
rm -r old-project               # delete a directory and its contents

Inside less, use the arrow keys or Space to scroll, /word to search, and q to quit. Unlike cat, it does not flood your screen with a huge file all at once.

Caution — rm is permanent There is no Recycle Bin on the Linux command line. rm deletes immediately and for good. Be especially careful with rm -r (recursive) and never run rm -rf / or point a recursive delete at ~ or / — you can erase your entire system. When in doubt, run ls on the path first to confirm exactly what you are about to remove, and consider the -i flag (rm -i) which asks for confirmation on each file.

Two different search tools that people often confuse. find searches for files by name, type, size or age. grep searches inside files for text.

# find: locate files by name under the current folder
find . -name "*.log"

# find: files larger than 100 MB anywhere under /var
find /var -type f -size +100M

# grep: show every line in a file that contains "error"
grep "error" /var/log/syslog

# grep: search recursively through a whole project, case-insensitive
grep -ri "api_key" ./src

You will also see the two combined with a "pipe" (|), which sends the output of one command into another — for example ls -la | grep ".txt" lists only the text files. Pipes are one of the most powerful ideas in the Linux shell.

4. Permissions: chmod and chown

Every file has an owner, a group, and a set of read (r), write (w) and execute (x) permissions for the owner, the group and everyone else. Run ls -l and the first column (like -rwxr-xr--) shows exactly that.

CommandWhat it doesExample
chmodChange a file's permission bitschmod +x script.sh
chownChange a file's owner (and group)sudo chown alex:alex file.txt
chmod +x deploy.sh          # make a script executable
chmod 644 index.html        # owner read/write, everyone else read-only
chmod -R 755 public/        # apply recursively to a folder
sudo chown -R alex:alex /var/www/site   # give a user ownership of a tree

The three-digit numbers are a shorthand: 4 = read, 2 = write, 1 = execute, added together per group. So 755 means the owner has 7 (read+write+execute) and the group and others have 5 (read+execute). Changing ownership almost always needs sudo, which we cover below.

5. Processes: ps, top/htop, kill

A "process" is any running program. These commands let you see what is running and stop something that has frozen or is hogging resources.

CommandWhat it doesExample
psSnapshot of running processesps aux
topLive, updating view of processes and loadtop
htopFriendlier, colour interactive version of tophtop
killStop a process by its ID (PID)kill 4123
ps aux | grep firefox   # find a program's process ID (PID)
kill 4123               # ask process 4123 to close gracefully
kill -9 4123            # force it to stop if it will not respond

Inside top, press q to quit. htop is often nicer to use but is not always installed by default — you can add it with your package manager (see the next section). Use kill -9 only as a last resort, because it stops a program instantly without letting it save.

6. Installing software: apt and dnf

This is the one area that genuinely differs between distributions. Instead of downloading installers from websites, Linux installs software from curated repositories using a package manager. Which one you use depends on your distro family:

TaskDebian / Ubuntu (apt)Fedora / RHEL (dnf)Arch (pacman)
Refresh package listssudo apt updatesudo dnf check-updatesudo pacman -Sy
Install a packagesudo apt install htopsudo dnf install htopsudo pacman -S htop
Remove a packagesudo apt remove htopsudo dnf remove htopsudo pacman -R htop
Upgrade everythingsudo apt upgradesudo dnf upgradesudo pacman -Syu
Search for a packageapt search htopdnf search htoppacman -Ss htop

On Debian and Ubuntu it is standard to run sudo apt update before installing, so the system knows about the latest available versions — Ubuntu's official package management documentation describes it as updating the local package index with the latest changes in the repositories:

sudo apt update && sudo apt install htop

On current Fedora releases, dnf is the modern DNF5 tool — the accepted Fedora change proposal switched the /usr/bin/dnf symlink to dnf5 for Fedora Linux 41 — and the everyday commands shown above are unchanged.

7. Running as administrator: sudo

Many commands that change the system — installing packages, editing files outside your home folder, changing ownership — require administrator (root) privileges. You get them by prefixing a command with sudo ("superuser do") and entering your password:

sudo apt install htop            # install system-wide software
sudo nano /etc/hosts             # edit a protected system file
Caution — sudo removes the guard rails A command run with sudo can change or delete anything on the system, so a mistake is far more costly. Only use it when a command genuinely needs it, read the whole command before you run it, and never paste a sudo command from an untrusted website without understanding what it does. Combining sudo with rm -rf is the single most dangerous thing you can type — treat it with real care.

8. Getting help: man and --help

You never need to memorise every option. Two built-in references cover almost everything, work offline, and describe the exact version installed on your machine:

man ls        # open the full manual for ls  (press q to quit)
ls --help     # quick summary of ls's options
man man       # yes, even man has a manual

Use --help for a fast reminder of the available flags, and man when you want the full explanation with examples. Between them, they are the most reliable Linux reference there is.

Quick reference cheat sheet

CategoryCommands
Navigatepwd, ls, cd
Files & folderscp, mv, rm, mkdir, touch, cat, less
Searchfind, grep
Permissionschmod, chown
Processesps, top, htop, kill
Packagesapt (Debian/Ubuntu), dnf (Fedora/RHEL), pacman (Arch)
Admin & helpsudo, man, --help

Frequently asked

Do these commands work on every Linux distribution?

The core commands in this guide — pwd, ls, cd, cp, mv, rm, mkdir, cat, grep, chmod, ps and the rest — are part of the GNU coreutils and the shell, so they behave the same on Ubuntu, Debian, Fedora, Arch and virtually every other distribution. The main thing that differs is the package manager: Debian and Ubuntu use apt, Fedora and RHEL use dnf, and Arch uses pacman. Where a command varies by distro, we point it out.

What is the difference between apt and dnf?

They are different package managers for different distribution families that do the same job: installing, updating and removing software. apt is used on Debian and Ubuntu-based systems, while dnf is used on Fedora, RHEL and other RPM-based systems. So sudo apt install and sudo dnf install achieve the same result on their respective distros. Arch Linux uses a third tool, pacman.

Is it safe to use sudo rm -rf?

rm -rf deletes files and folders recursively and permanently, with no recycle bin or undo. Adding sudo removes the last safety net by running it as the root user, so a mistyped path can wipe out system files or an entire drive. Always double-check the exact path before you press Enter, avoid running it against / or your home directory, and never blindly paste an rm -rf command you found online.

How do I find out what a command does?

Two built-in tools cover almost everything. Type man followed by a command name, such as man ls, to open its full manual page — press q to quit. For a quick summary of a command's options, most commands also accept a --help flag, for example ls --help. These work offline and are the most reliable reference because they describe the exact version installed on your system.

More Linux guides

This is part of the Windows Now Linux section. Browse all Linux guides, or head back to the Windows Now home.