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.

You don't have to use the terminal. Most everyday tasks on Linux can be done with a mouse, just like on Windows or Mac. But learning a few basic commands will make you faster at some things, and many Linux guides will ask you to copy-paste a command or two. That's all you need to get started.

Why bother with the terminal?

Opening the terminal

How you open it depends on your desktop environment, but it's always easy to find:

DesktopHow 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 desktopTry 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
Think of it like File Explorer. 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
Be careful with 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
What's that 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.)

Only use 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.

ShortcutWhat it doesWhy 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.
Copy and paste work differently in the terminal. 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

CommandWhat it doesExample
pwdShow which folder you're inpwd
lsList files in the current folderls -la
cdChange to a different foldercd Documents
cd ..Go up one foldercd ..
cd ~Go to your home foldercd ~

Files and folders

CommandWhat it doesExample
mkdirCreate a new foldermkdir projects
touchCreate an empty filetouch notes.txt
cpCopy a file or foldercp file.txt backup.txt
mvMove or rename a filemv old.txt new.txt
rmDelete a filerm old.txt
rm -rDelete a folder and its contentsrm -r old-folder

Reading files

CommandWhat it doesExample
catPrint the entire filecat notes.txt
lessView a file page by page (press q to quit)less longfile.txt
headShow the first 10 lineshead -n 5 log.txt
tailShow the last 10 linestail -n 20 log.txt

Searching

CommandWhat it doesExample
findSearch for files by namefind ~ -name "*.jpg"
grepSearch for text inside filesgrep "error" log.txt
grep -rSearch for text in all files in a foldergrep -r "TODO" ~/projects/
grep -iCase-insensitive searchgrep -i "hello" notes.txt

Permissions and admin

CommandWhat it doesExample
sudoRun a command with admin privilegessudo apt install firefox
chmodChange file permissionschmod +x script.sh

Keyboard shortcuts

ShortcutWhat it does
TabAuto-complete names and commands
Up ArrowPrevious command
Ctrl+CCancel current command
Ctrl+RSearch command history
Ctrl+LClear the screen
Ctrl+Shift+CCopy text in terminal
Ctrl+Shift+VPaste text in terminal