The Linux terminal is a text window where you type commands to control your computer. About 30 commands, such as ls, cd, cp, mv, grep, and sudo, cover most everyday tasks.

Graphical desktops are easy to use, but the terminal is where Linux really shines. It’s faster for many jobs, it works the same on a laptop and on a server with no screen, and it’s the only way to manage most web servers, VPS hosts, and Raspberry Pis. If you’ve installed Ubuntu or are starting to work with servers, learning the terminal is the next step.

This guide covers the essential commands, grouped by what you want to do, with short examples you can try yourself. The examples use Ubuntu, but almost everything works on any Linux distribution, and most of it also works in the macOS Terminal.

Opening the Terminal

  • Ubuntu and most desktops: press Ctrl + Alt + T, or search for “Terminal” in the app menu.
  • A remote server: connect with SSH (ssh user@server-ip). See What Is SSH?
  • Windows: install WSL (Windows Subsystem for Linux) to get a real Linux terminal.

When it opens, you’ll see a prompt like this:

user@ubuntu:~$

It shows your username (user), the computer’s name (ubuntu), and your current folder (~ means your home folder). The $ means you’re a regular user. You type commands after it and press Enter.

How a Command Is Built

Most commands follow the same pattern:

command  -options  arguments
ls       -l        /home
  • The command is the program to run (ls lists files).
  • Options (also called flags) change how it behaves. They usually start with - or --. You can combine short ones: ls -l -a is the same as ls -la.
  • Arguments are what the command works on, such as a file or folder name.

Linux is case-sensitive: Notes.txt and notes.txt are different files, and LS isn’t a command.

CommandWhat it does
pwdPrint the folder you’re in (“print working directory”)
lsList files and folders
ls -lList with details: permissions, owner, size, date
ls -aInclude hidden files (names that start with .)
ls -lhDetailed list with readable sizes (K, M, G)
cd folderMove into a folder
cd ..Go up one level
cd ~ or cdGo to your home folder
cd -Go back to the previous folder
cd /Go to the root of the file system

Paths can be absolute (starting from the root, like /home/user/Documents) or relative (starting from where you are, like Documents/projects).

Working with Files and Folders

CommandWhat it does
mkdir projectsCreate a folder
mkdir -p a/b/cCreate nested folders in one step
touch notes.txtCreate an empty file (or update its date)
cp file.txt copy.txtCopy a file
cp -r folder backupCopy a folder and everything in it
mv old.txt new.txtRename a file
mv file.txt Documents/Move a file into another folder
rm file.txtDelete a file
rm -r folderDelete a folder and everything in it
rmdir folderDelete an empty folder

Be careful with rm. The terminal has no Recycle Bin, so deleted files are gone. Use rm -i to be asked before each deletion, double-check paths before pressing Enter, and never run rm -rf on a path you haven’t read twice.

Viewing and Editing Files

CommandWhat it does
cat file.txtPrint the whole file
less file.txtScroll through a long file (press q to quit)
head file.txtShow the first 10 lines (head -n 20 for 20)
tail file.txtShow the last 10 lines
tail -f app.logFollow a log file as new lines are added (Ctrl + C to stop)
nano file.txtEdit a file in a simple text editor
wc -l file.txtCount the lines in a file

In nano, the shortcuts are listed at the bottom of the screen: Ctrl + O saves, Ctrl + X exits. ^ in nano’s menu means the Ctrl key.

Searching

CommandWhat it does
grep "error" app.logShow lines containing “error”
grep -i "error" app.logSame, ignoring upper and lower case
grep -n "error" app.logInclude line numbers
grep -r "TODO" project/Search every file in a folder
find . -name "*.txt"Find files by name, starting from the current folder
which python3Show where a program is installed

Pipes and Redirection

This is where the terminal becomes powerful. You can connect small commands together:

SymbolWhat it doesExample
|Send one command’s output into anotherls | wc -l counts files
>Save output to a file, replacing itls > files.txt
>>Add output to the end of a fileecho "done" >> log.txt

For example, history | grep ssh shows every ssh command you’ve run recently, and ps aux | grep nginx checks whether the nginx web server is running.

Users, Permissions, and sudo

Every file has an owner, a group, and permissions that control who can read (r), write (w), and execute (x) it. ls -l shows them:

-rwxr-xr-x 1 user user 120 Nov 14 09:00 script.sh

The first character is the type (- for a file, d for a folder). The next nine are three sets of rwx: for the owner, the group, and everyone else. Here, the owner can read, write, and run the file, and everyone else can read and run it.

CommandWhat it does
whoamiShow your username
sudo commandRun a command as the administrator (root)
chmod +x script.shMake a file executable
chmod 644 file.txtOwner can read and write; everyone else can only read
chown user:group fileChange a file’s owner (usually needs sudo)

sudo asks for your password and runs one command with full administrator rights. Use it only when a command needs it, such as installing software or editing system files. A command run with sudo can change or delete anything on the system.

Installing and Updating Software

Ubuntu and Debian use the APT package manager:

CommandWhat it does
sudo apt updateRefresh the list of available packages
sudo apt upgradeInstall available updates
sudo apt install htopInstall a program
sudo apt remove htopRemove a program
apt search keywordSearch for a package

Run sudo apt update before installing or upgrading so APT knows about the latest versions. Other distributions use different package managers, such as dnf on Fedora and pacman on Arch, but the idea is the same. See What Is Linux? for how distributions differ.

Checking the System

CommandWhat it does
uname -aShow the kernel version and system details
df -hShow free disk space
du -sh folderShow how much space a folder uses
free -hShow memory (RAM) usage
top or htopLive view of running programs (press q to quit)
ps auxList every running process
kill 1234Stop the process with ID 1234
uptimeShow how long the system has been running

Networking Basics

CommandWhat it does
ip aShow your network interfaces and IP addresses
ping -c 4 example.comTest whether a host responds (4 attempts)
curl -I https://example.comShow a website’s response headers
wget URLDownload a file
ssh user@hostLog in to another computer securely

If you’re new to IP addresses and ports, Computer Networking: The Internet Protocol Explained covers the basics.

Getting Help

You don’t need to memorize every option:

  • man ls opens the full manual for a command (press q to quit, / to search).
  • ls --help prints a shorter summary of options.
  • history lists the commands you’ve run, and the Up arrow brings back the previous one.

Keyboard Shortcuts That Save Time

ShortcutWhat it does
TabAuto-complete a command, file, or folder name
Tab TabShow all possible completions
Up / DownScroll through previous commands
Ctrl + CStop the command that’s running
Ctrl + LClear the screen (same as clear)
Ctrl + RSearch your command history
Ctrl + A / Ctrl + EJump to the start or end of the line
Ctrl + Shift + C / VCopy and paste in most terminal apps

Tab completion is the most useful habit to build. It saves typing and prevents typos in long file names.

Practice: Your First Terminal Session

Try this short exercise. It creates a practice folder, works with a file, and cleans up afterward:

mkdir -p practice/notes
cd practice
echo "Linux is fun" > notes/todo.txt
echo "Learn the terminal" >> notes/todo.txt
echo "Practice every day" >> notes/todo.txt
cat notes/todo.txt
Linux is fun
Learn the terminal
Practice every day

Now search, count, copy, and rename:

grep -n "terminal" notes/todo.txt
wc -l notes/todo.txt
cp notes/todo.txt notes/todo-backup.txt
mv notes/todo-backup.txt notes/old-todo.txt
ls notes
2:Learn the terminal
3 notes/todo.txt
old-todo.txt  todo.txt

Finally, find every text file and remove the practice folder:

find . -name "*.txt"
cd ..
rm -r practice
./notes/todo.txt
./notes/old-todo.txt

The order of find results can vary. If every step worked, you’ve just used a dozen of the commands in this guide.

Common Beginner Mistakes

  • Forgetting that names are case-sensitive. cd documents fails if the folder is Documents.
  • Spaces in file names. Wrap them in quotes (cd "My Files") or use Tab completion, which adds the escapes for you.
  • “Permission denied.” The command needs administrator rights (add sudo) or the file isn’t executable (chmod +x).
  • “Command not found.” The program isn’t installed, or there’s a typo. On Ubuntu, the message often suggests the apt install command to fix it.
  • Pasting commands you don’t understand. Read every command before you run it, especially ones with sudo, rm, or curl ... | bash.

Conclusion

The Linux terminal looks intimidating at first, but a small set of commands covers most of what you’ll do: pwd, ls, and cd to move around; mkdir, cp, mv, and rm to manage files; cat, less, nano, and grep to read and search; and sudo apt to install software.

Open a terminal and use it for something small every day, like updating your system or finding a file. Once these commands feel familiar, you’re ready for the next step: managing a VPS, running Docker containers, or setting up your own server.

Frequently Asked Questions

What is the difference between the terminal, the shell, and the command line?

The terminal is the window you type in. The shell is the program that reads and runs your commands; on most Linux systems it’s Bash. The command line is the general term for working this way. In everyday use, people use the three words interchangeably.

Do I need the terminal to use Linux?

Not for everyday desktop use. Ubuntu and Linux Mint can be used entirely with the mouse. You’ll need the terminal for servers, troubleshooting, and many developer tools.

Is it safe to practice terminal commands?

Yes, as long as you avoid sudo and rm on files you don’t recognize. Practice in your home folder or in a virtual machine, where mistakes can’t affect anything important.

Do these commands work on macOS?

Most of them do. macOS includes a Unix terminal with ls, cd, grep, find, chmod, and many others. Some options differ slightly, and macOS doesn’t use apt; Homebrew is the common package manager there.

How do I stop a command that won’t finish?

Press Ctrl + C. If a program like less, man, or top takes over the screen, press q to quit.

How long does it take to learn the Linux terminal?

You can learn the commands in this guide in a few days of regular practice. Comfort comes from using them for real tasks over a few weeks.