The Linux Terminal: A Beginner's Guide
It looks like something out of a hacker movie, but it's really just a way to talk to your computer by typing. Let's make it less scary.
What is the terminal?
The terminal (also called the command line, shell, or console) is a text-based way to control your computer. Instead of clicking buttons and icons, you type short commands and press Enter.
Think of it like texting your computer. You type a message (a command), your computer reads it, does the thing, and replies with the result. That's it.
Why bother with the terminal?
- It's faster for some tasks. Renaming 500 files at once? One command. Doing it with a mouse? Good luck.
- Guides love it. Most Linux help articles give you commands to copy and paste. Knowing the basics makes following them much easier.
- It works everywhere. Every Linux system has a terminal, no matter which desktop environment you use. The same commands work on Ubuntu, Fedora, Mint — everywhere.
- It's precise. When you ask for help online, pasting the exact command and its output makes troubleshooting way easier than describing what you clicked.
Opening the terminal
How you open it depends on your desktop environment, but it's always easy to find:
| Desktop | How to open the terminal |
|---|---|
| GNOME (Ubuntu, Fedora) | Press Super (Windows key), type "Terminal", click it |
| KDE Plasma (Kubuntu, Fedora KDE) | Press Super, type "Konsole", click it |
| Cinnamon (Linux Mint) | Press Ctrl+Alt+T or find "Terminal" in the menu |
| XFCE (Xubuntu) | Press Ctrl+Alt+T or find "Terminal Emulator" in the menu |
| Any desktop | Try Ctrl+Alt+T — it's the most common shortcut |
Once it opens, you'll see something like this:
yourname@yourcomputer:~$
That's called the prompt. It's just telling you who you are (yourname), what computer you're on (yourcomputer), and where you are (~ means your home folder). The $ means it's ready for you to type. That's it — nothing scary.
Navigating around: pwd, ls, cd
Think of the terminal as a text version of File Explorer (or Finder on Mac). You're always "standing" inside a folder, and you can look around, move to other folders, and interact with files. Here are the three commands you'll use the most:
pwd — "Where am I?"
pwd stands for "print working directory." It tells you which folder you're currently in.
$ pwd
/home/yourname
That's like looking at the address bar in File Explorer. You're in your home folder.
ls — "What's in here?"
ls lists the files and folders in your current location. It's like opening a folder and seeing what's inside.
$ ls
Desktop Documents Downloads Music Pictures Videos
Want more detail? Add -l for a detailed list, or -a to show hidden files (ones that start with a dot):
# Detailed list (sizes, dates, permissions)
$ ls -l
# Show hidden files too
$ ls -a
# Both at once
$ ls -la
cd — "Go to this folder"
cd stands for "change directory." It's how you move between folders.
# Go into the Documents folder
$ cd Documents
# Go back up one level
$ cd ..
# Go straight to your home folder from anywhere
$ cd ~
# Go to an exact location
$ cd /home/yourname/Downloads
pwd is looking at the address bar. ls is seeing the files in the current folder. cd is double-clicking a folder to go inside it. cd .. is clicking the "Up" arrow.
Creating, moving, and deleting things
These are the commands you'd use instead of right-clicking and choosing "New Folder," "Copy," "Rename," or "Delete" in File Explorer.
mkdir — Make a new folder
# Create a folder called "projects"
$ mkdir projects
# Create a folder and all the parent folders it needs
$ mkdir -p work/clients/acme
That -p flag is handy — it creates work, then clients inside it, then acme inside that, all in one go.
touch — Create an empty file
# Create an empty file called "notes.txt"
$ touch notes.txt
This is like right-clicking in File Explorer and choosing "New > Text Document." The file will be empty, ready for you to put something in it.
cp — Copy a file or folder
# Copy a file
$ cp notes.txt notes-backup.txt
# Copy a file to another folder
$ cp notes.txt Documents/
# Copy an entire folder (need -r for "recursive")
$ cp -r projects projects-backup
mv — Move or rename
mv does double duty. It moves files, and it also renames them (because renaming is basically moving a file to the same place with a different name).
# Rename a file
$ mv notes.txt my-notes.txt
# Move a file to another folder
$ mv my-notes.txt Documents/
# Move and rename at the same time
$ mv my-notes.txt Documents/important-notes.txt
rm — Delete a file or folder
# Delete a file
$ rm old-file.txt
# Delete a folder and everything inside it
$ rm -r old-folder
rm. Unlike Windows, there's no Recycle Bin when you delete with rm. The file is just gone. Double-check what you're deleting before you press Enter. If you're nervous, use rm -i which will ask "are you sure?" for each file.
Reading files
You don't need to open a full text editor just to peek at a file. These commands let you read file contents right in the terminal.
cat — Show the whole file
# Display the entire contents of a file
$ cat notes.txt
This is my first note.
It has two lines.
Great for short files. For long files, the text will fly by too fast to read — use less instead.
less — Read a file page by page
# Open a long file in a scrollable viewer
$ less /var/log/syslog
Use the arrow keys or Page Up/Page Down to scroll. Press q to quit and go back to the terminal. Think of it like a basic read-only text viewer.
head and tail — See the beginning or end
# Show the first 10 lines of a file
$ head notes.txt
# Show the last 10 lines
$ tail notes.txt
# Show the first 5 lines
$ head -n 5 notes.txt
# Show the last 20 lines
$ tail -n 20 notes.txt
tail is especially useful for log files, where the newest entries are at the bottom.
Finding things
Lost a file? Need to find something inside a file? These two commands are your search tools.
find — Search for files by name
# Find a file called "notes.txt" somewhere in your home folder
$ find ~ -name "notes.txt"
# Find all .jpg images in your Pictures folder
$ find ~/Pictures -name "*.jpg"
# Find all folders called "backup" anywhere on the system
$ find / -type d -name "backup" 2>/dev/null
2>/dev/null thing? When you search the whole system with find /, you'll get a bunch of "Permission denied" errors for system folders you can't access. Adding 2>/dev/null hides those error messages so you only see the actual results. Don't worry about memorizing this — just copy it when you need it.
grep — Search inside files
grep searches for a word or phrase inside one or more files. It's like using Ctrl+F, but across many files at once.
# Find the word "password" in a file
$ grep "password" config.txt
# Search in all .txt files in the current folder
$ grep "password" *.txt
# Search through a folder and all its subfolders
$ grep -r "TODO" ~/projects/
# Search without caring about uppercase/lowercase
$ grep -i "hello" notes.txt
Permissions: what "Permission denied" means
If you've tried a command and gotten a "Permission denied" error, don't worry — you didn't break anything. It just means that your user account doesn't have permission to do that particular thing.
Linux has a permissions system that controls who can read, change, or run each file. This is a security feature, not a bug. It prevents you (or a rogue program) from accidentally messing up important system files.
Most "Permission denied" errors happen because you're trying to do something that requires admin privileges — like installing software or editing a system config file.
sudo — "Do this as admin"
On Windows, you sometimes get a popup asking "Do you want to allow this app to make changes?" On Linux, the equivalent is sudo. It temporarily gives you admin powers for one command.
# This might fail with "Permission denied"
$ apt install firefox
# This works -- sudo gives you admin rights for this command
$ sudo apt install firefox
When you use sudo, you'll be asked for your password. Type it and press Enter. (You won't see the characters as you type — that's normal. It's a security feature, not a glitch.)
sudo when you actually need it. Don't just slap sudo in front of every command "just in case." Most everyday tasks (editing your own files, browsing folders, running programs) don't need it. If a command doesn't ask for it, you probably don't need it. Using sudo unnecessarily can create files owned by the admin account that your regular account can't access later.
Common situations where you need sudo
- Installing or removing software:
sudo apt install ... - Updating your system:
sudo apt update && sudo apt upgrade - Editing system config files:
sudo nano /etc/hostname - Managing system services:
sudo systemctl restart NetworkManager - Anything in /etc, /usr, /var, or /boot: These are system folders that need admin access to change.
If you're working inside your home folder (~/), you almost never need sudo.
Keyboard shortcuts that save time
These shortcuts work in virtually every Linux terminal. Once you learn them, you'll wonder how you lived without them.
| Shortcut | What it does | Why it's useful |
|---|---|---|
Tab |
Auto-complete file names, folder names, and commands | Start typing a file name and press Tab — the terminal fills in the rest. If there are multiple matches, press Tab twice to see them all. This is the single most useful shortcut. |
Up Arrow |
Scroll through your previous commands | Don't retype that long command — press Up to bring it back, then press Enter to run it again. |
Ctrl+C |
Cancel the current command | If a command is taking forever or you made a mistake, Ctrl+C stops it immediately. This is your emergency brake. |
Ctrl+R |
Search your command history | Press Ctrl+R and start typing — it finds previous commands that match. Press Enter to run it, or Ctrl+C to cancel. |
Ctrl+L |
Clear the screen | Same as typing clear. Your previous commands are still in history, the screen just looks tidier. |
Ctrl+A |
Jump to the beginning of the line | Forgot something at the start of a long command? Jump back instantly. |
Ctrl+E |
Jump to the end of the line | The counterpart to Ctrl+A. |
Ctrl+D |
Close the terminal (if the line is empty) | A quick way to exit. Same as typing exit. |
Ctrl+C doesn't copy — it cancels commands. To copy text in the terminal, use Ctrl+Shift+C. To paste, use Ctrl+Shift+V. This trips up everyone at first, but you'll get used to it fast.
Pipes and redirection (a sneak peek)
This is a slightly more advanced topic, but it's so useful that it's worth a quick look. You can connect commands together so that the output of one becomes the input of another. This is called "piping" and uses the | character.
The pipe: |
The pipe takes whatever one command outputs and feeds it into another command. Think of it as an assembly line — one command does its job, then passes the result to the next.
# List files, but only show ones that contain "photo"
$ ls | grep "photo"
# Show running processes and find one by name
$ ps aux | grep firefox
# Count how many .txt files are in a folder
$ ls *.txt | wc -l
Redirection: > and >>
You can also send a command's output to a file instead of showing it on screen:
# Save the output of ls to a file (overwrites if the file exists)
$ ls -l > file-list.txt
# Append to a file (adds to the end, doesn't overwrite)
$ echo "new note" >> notes.txt
> creates or overwrites the file. >> adds to the end of the file. Be careful with > on files you want to keep!
A real-world example
# Find all large files in your home folder and save the list
$ find ~ -size +100M 2>/dev/null > large-files.txt
# Search logs for errors and count them
$ grep -c "error" /var/log/syslog
You don't need to master this now. Just know that commands can be chained together, and you'll start to see it in guides and tutorials. When you're ready, it becomes one of the most powerful things about the Linux terminal.
Cheat sheet
Here's everything from this guide in one quick-reference table. Bookmark this page and come back whenever you forget a command.
Navigation
| Command | What it does | Example |
|---|---|---|
pwd | Show which folder you're in | pwd |
ls | List files in the current folder | ls -la |
cd | Change to a different folder | cd Documents |
cd .. | Go up one folder | cd .. |
cd ~ | Go to your home folder | cd ~ |
Files and folders
| Command | What it does | Example |
|---|---|---|
mkdir | Create a new folder | mkdir projects |
touch | Create an empty file | touch notes.txt |
cp | Copy a file or folder | cp file.txt backup.txt |
mv | Move or rename a file | mv old.txt new.txt |
rm | Delete a file | rm old.txt |
rm -r | Delete a folder and its contents | rm -r old-folder |
Reading files
| Command | What it does | Example |
|---|---|---|
cat | Print the entire file | cat notes.txt |
less | View a file page by page (press q to quit) | less longfile.txt |
head | Show the first 10 lines | head -n 5 log.txt |
tail | Show the last 10 lines | tail -n 20 log.txt |
Searching
| Command | What it does | Example |
|---|---|---|
find | Search for files by name | find ~ -name "*.jpg" |
grep | Search for text inside files | grep "error" log.txt |
grep -r | Search for text in all files in a folder | grep -r "TODO" ~/projects/ |
grep -i | Case-insensitive search | grep -i "hello" notes.txt |
Permissions and admin
| Command | What it does | Example |
|---|---|---|
sudo | Run a command with admin privileges | sudo apt install firefox |
chmod | Change file permissions | chmod +x script.sh |
Keyboard shortcuts
| Shortcut | What it does |
|---|---|
Tab | Auto-complete names and commands |
Up Arrow | Previous command |
Ctrl+C | Cancel current command |
Ctrl+R | Search command history |
Ctrl+L | Clear the screen |
Ctrl+Shift+C | Copy text in terminal |
Ctrl+Shift+V | Paste text in terminal |