You can learn the Linux terminal in about an hour, and you only need around 15 basic Linux commands to get real work done. This tutorial teaches 18 of them, one small lesson at a time, in the order you’ll actually use them. Open a terminal, type along, and do the short “Try it” box at the end of each lesson.
Here’s the promise: nothing in this lesson can break your computer. Every exercise happens inside a practice folder in your own home folder. There is exactly one command that needs care, rm (delete), and you’ll see a clear warning before we use it.
This page is a lesson, not a reference. When you want every option in one place, keep our Linux commands cheat sheet open in another tab. Everything here was written for Ubuntu and Debian-family systems such as Linux Mint, Pop!_OS, Debian and Raspberry Pi OS, all of which use the bash shell by default.
Lesson 0: Open the terminal and read the prompt
The terminal is a window where you type commands instead of clicking icons. On Ubuntu, Linux Mint and most Ubuntu-family desktops, press Ctrl+Alt+T. If nothing happens, open your app menu and search for “Terminal.” On a Raspberry Pi, click the terminal icon in the top bar. If you’re connecting to a homelab server over SSH, you’re already in one.
A window opens with a single line of text and a blinking cursor. That line is the prompt, and it’s the terminal saying “ready, type something.” It looks something like this:
sam@ubuntu-laptop:~$Read it left to right:
| Part | Means |
|---|---|
sam | Your username |
@ubuntu-laptop | The computer’s name (the hostname) |
: | Separator |
~ | Where you are right now. ~ is shorthand for your home folder. |
$ | You’re a regular user. Type after this. |
Your name and computer name will be different, and some systems add colors or a space before the $. That’s fine.

What if the prompt ends in #? A # means you’re the root user, the all-powerful administrator account. For everything in this tutorial you want $. If you ever see # and didn’t mean to, type exit and press Enter to drop back to your normal account.
To run a command, type it after the prompt and press Enter. Linux usually says nothing when a command succeeds; silence is good news. One tip for Windows switchers: in most Linux terminals, copy is Ctrl+Shift+C and paste is Ctrl+Shift+V. Plain Ctrl+C means “stop,” which you’ll learn in Lesson 5.
New to the different flavors of Linux? Our guide to what a Linux distro means explains why Ubuntu, Mint and Raspberry Pi OS all behave the same here.
The map: how Linux folders are organized
Linux keeps everything in one upside-down tree of folders (Linux calls them directories). The top of the tree is a single slash, /, called the root directory. There are no drive letters like C:.
/ the top of everything
├── home/
│ └── sam/ your home folder (~)
├── etc/ system settings
├── var/ logs and changing data
└── tmp/ temporary files
| Folder | In plain words | Should you touch it? |
|---|---|---|
/ | The root: every file lives somewhere under it | Look, don’t change |
/home | Holds one home folder per user, like /home/sam | Yes, your folder is yours |
/etc | System-wide settings files | Look only for now |
/var | Data that changes as the system runs, such as logs in /var/log | Look only |
/tmp | Scratch space for temporary files, usually cleared on restart | Fine for throwaway files |
Paths: the address of a file
A path is a file or folder’s address. There are two kinds.
- An absolute path starts with
/and works from anywhere, like a full street address:/home/sam/Documents/notes.txt. - A relative path starts from wherever you are now, like saying “two doors down”: if you’re in
/home/sam, thenDocuments/notes.txtpoints to the same file.
Three shortcuts show up constantly:
| Shortcut | Means | Example, if you’re in /home/sam/Documents |
|---|---|---|
. | This folder | ./notes.txt = /home/sam/Documents/notes.txt |
.. | The folder one level up (the parent) | .. = /home/sam |
~ | Your home folder, from anywhere | ~/Downloads = /home/sam/Downloads |
So what does /home/sam mean? Start at the root /, go into home, then into sam. Hold onto that, and the next lesson will feel easy.
Lesson 1: Where am I? (pwd, ls, cd)
Three commands answer “where am I, what’s here, and how do I go somewhere else?” Sample output in this guide is illustrative: your names, dates and sizes will differ.
pwd: print where you are
pwd stands for print working directory. It shows the folder you’re in right now as an absolute path.
$ pwd
/home/samls: list what’s here
ls lists the files and folders in your current folder.
$ ls
Desktop Documents Downloads Music Pictures Public snap Templates VideosCommands take options (also called flags) that start with a dash. Two are worth knowing on day one:
ls -lgives a long listing, one item per line with details.ls -ashows all files, including hidden ones whose names start with a dot.
$ ls -l
total 36
drwxr-xr-x 2 sam sam 4096 Oct 20 14:02 Desktop
drwxr-xr-x 2 sam sam 4096 Oct 20 14:02 Documents
drwxr-xr-x 2 sam sam 4096 Oct 21 09:15 Downloads
...You don’t need to decode every column yet. The first letter is d for a directory or - for a regular file, then come permissions, the owner (sam), the size, the date it last changed, and the name.
$ ls -a
. .. .bash_history .bash_logout .bashrc .cache .config Desktop Documents ...Those dot-files are settings files that stay hidden so they don’t clutter your view. Notice . and .. at the start: they’re the “this folder” and “parent folder” shortcuts from the map. You can combine options, so ls -la gives a long listing of everything. You can also list a folder without going there: ls /etc.
cd: change directory
cd moves you into another folder. Watch the prompt change as you move.
sam@ubuntu-laptop:~$ cd Documents
sam@ubuntu-laptop:~/Documents$ pwd
/home/sam/DocumentsFour moves cover almost everything:
| Command | Takes you to |
|---|---|
cd Documents | A folder inside where you are (relative path) |
cd .. | One level up, to the parent folder |
cd ~ (or just cd) | Your home folder, from anywhere |
cd - | Back to the folder you were in before (it prints that path) |
And cd /var/log works from anywhere because it’s an absolute path. Feeling lost? Type cd and press Enter. You’re home.
Try it: Lesson 1
Type each line, then compare with what you should see.
cd /tmp → prompt now shows /tmp
pwd → /tmp
cd .. → you're at the root; prompt shows /
ls → bin boot dev etc home ... (the top-level folders)
cd - → prints /tmp and takes you back there
cd → home again; prompt shows ~Lesson 2: Making things (mkdir, touch, echo, cat)
Now you’ll create a practice folder so every experiment stays in one safe place.
mkdir: make a folder
$ mkdir ~/practice
$ cd ~/practice
sam@ubuntu-laptop:~/practice$mkdir (make directory) creates a folder. If the folder already exists, you’ll see mkdir: cannot create directory '...': File exists, which just means it’s already there.
touch: make an empty file
$ touch notes.txt
$ ls -l
-rw-rw-r-- 1 sam sam 0 Oct 22 10:05 notes.txttouch creates an empty file (size 0). If the file already exists, it only updates the timestamp and leaves the contents alone, so it’s harmless.
echo with >: put text in a file
echo prints text back to you. Add > and the text goes into a file instead of the screen.
$ echo "Hello, Linux"
Hello, Linux
$ echo "Hello, Linux" > hello.txtThe second command prints nothing because the text went into hello.txt. One important detail: > replaces whatever was in the file. To add a line to the end instead, use two arrows, >>.
cat: read a file back
$ cat hello.txt
Hello, Linuxcat prints a file’s contents to the screen. It’s perfect for short files; for long ones you’ll use less in Lesson 4.
Try it: Lesson 2
Stay in ~/practice.
mkdir drafts → no output
echo "Buy milk" > todo.txt → no output
echo "Water the plants" >> todo.txt → no output
cat todo.txt → Buy milk
Water the plants
ls → drafts hello.txt notes.txt todo.txtIf cat shows only “Water the plants,” you typed one > on the second line instead of two. Run both echo lines again.
Lesson 3: Copying, moving and deleting (cp, mv, rm)
These three commands do what drag-and-drop and the Delete key do in a file manager, with one big difference covered below.
cp: copy
The pattern is cp source destination.
$ cp hello.txt hello-copy.txt # copy to a new name
$ cp hello.txt drafts/ # copy into a folder, same name
$ cp -r drafts drafts-backup # copy a whole folder (needs -r)Folders need -r (recursive), meaning “the folder and everything inside it.” Without it, you’ll see cp: -r not specified; omitting directory 'drafts'.
mv: move, and the rename trick
mv uses the same pattern. Moving into a folder moves the file; “moving” to a new name in the same place renames it. There’s no separate rename command.
$ mv hello-copy.txt drafts/ # move into a folder
$ mv notes.txt journal.txt # renameHeads-up: if the destination name already exists, cp and mv overwrite it without asking. Add -i (cp -i, mv -i) and they’ll ask first.
rm: delete, with an honest warning
Read this before you use rm. The terminal has no trash can. A file removed with
rmis gone; there is no undo. Before deleting, runlsto check you’re in the right folder, and type the name exactly. Never runrmcommands copied from forums or videos unless you understand every part, and never pointrm -rat/,~, or a lone*.
While you’re learning, use rm -i, the training-wheels version. It asks before every deletion; type y and Enter to confirm, or anything else to keep the file.
$ rm -i journal.txt
rm: remove regular empty file 'journal.txt'? yTo delete a folder and its contents, add -r. With -i you’ll be asked at each step:
$ rm -ri drafts-backup
rm: descend into directory 'drafts-backup'? y
rm: remove regular file 'drafts-backup/hello.txt'? y
rm: remove directory 'drafts-backup'? yTry it: Lesson 3
cp todo.txt todo-old.txt → no output
mv todo-old.txt drafts/ → no output
ls drafts → hello-copy.txt hello.txt todo-old.txt
rm -i drafts/todo-old.txt → asks to remove; type y
ls → drafts hello.txt todo.txtLesson 4: Looking inside files (less, head, tail, grep, nano)
cat dumps a whole file at once, which is useless for a file hundreds of lines long. These commands let you scroll, peek, search and edit. For practice we’ll read /etc/services, a long, harmless list of network service names that ships with Ubuntu and Debian.
less: scroll through a long file
$ less /etc/servicesThe file opens one screen at a time. Nothing you do in less changes the file.
| Key | Does |
|---|---|
| Space / b | Next page / back a page |
| Up and Down arrows | Scroll one line |
/ssh then Enter | Search for “ssh” (press n for the next match) |
q | Quit back to the prompt |
head and tail: the first or last lines
head shows the first 10 lines of a file and tail shows the last 10. Add -n and a number to choose how many.
$ head -n 3 /etc/services
# Network services, Internet style
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/...tail is the one you’ll reach for with log files, because the newest entries are at the bottom.
grep: find lines that contain a word
grep searches inside files and prints only the lines that match. The pattern is grep word file.
$ grep milk todo.txt
Buy milk
$ grep ssh /etc/services
ssh 22/tcp # SSH Remote Login Protocolgrep is case-sensitive, so grep Milk todo.txt finds nothing. Add -i to ignore case: grep -i milk todo.txt.
nano: the beginner-friendly editor
nano is a simple text editor that runs inside the terminal and comes preinstalled on Ubuntu, Mint, Debian and Raspberry Pi OS. Run it from your practice folder:
$ cd ~/practice
$ nano todo.txt- Use the arrow keys to move the cursor (the mouse won’t place it), then type normally.
- Press Ctrl+O to save (“Write Out”). nano shows
File Name to Write: todo.txtat the bottom; press Enter to confirm. - Press Ctrl+X to exit.
The menu at the bottom uses ^ for Ctrl, so ^X Exit means Ctrl+X. If you press Ctrl+X with unsaved changes, nano asks whether to save the modified buffer: press Y then Enter to save, or N to throw the changes away.
Try it: Lesson 4
nano todo.txt → add a third line, "Call Mom", then Ctrl+O, Enter, Ctrl+X
cat todo.txt → Buy milk
Water the plants
Call Mom
tail -n 1 todo.txt → Call Mom
grep -i water todo.txt → Water the plantsLesson 5: Getting help and fixing mistakes
Every Linux user gets errors constantly. What separates beginners from everyone else is knowing how to read them and where to look up the fix.
man and –help: the built-in manual
$ man lsman opens the full manual page for a command. It scrolls like less: Space for the next page, / to search, q to quit. For a shorter summary, most commands accept --help:
$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
...Four keyboard habits that save hours
- Tab completion: type the first few letters of a file or command and press Tab; bash finishes it for you. Type
cat to, press Tab, and it becomescat todo.txt. If nothing happens, press Tab twice to see all the matches. It also prevents typos. - Up arrow: scrolls back through commands you’ve already run. Press Enter to run one again, or edit it first.
- Ctrl+C: stops whatever is running and gives you the prompt back. Try it: type
catwith no file name and press Enter. The terminal seems frozen becausecatis waiting for you to type input. Press Ctrl+C to escape. - Ctrl+L or
clear: wipes the screen clean. Your files and history are untouched.
The three classic beginner errors (and their fixes)
1. Wrong case: “No such file or directory”
Linux is case-sensitive: Todo.txt and todo.txt are two different names, and so are Documents and documents.
$ cat Todo.txt
cat: Todo.txt: No such file or directory
$ cd documents
bash: cd: documents: No such file or directoryFix: run ls and copy the exact spelling, or use Tab completion so bash types the name for you.
2. Spaces in names
The shell splits commands at spaces, so mkdir my notes makes two folders, my and notes. To use a name with a space, wrap it in quotes or put a backslash before the space:
$ mkdir "my notes"
$ cd my\ notesTab completion adds the backslashes automatically. Easier still: name files with dashes or underscores, like my-notes.
3. “Permission denied” and what sudo really is
$ touch /etc/test.txt
touch: cannot touch '/etc/test.txt': Permission deniedThis isn’t a bug. Regular users can change files in their own home folder, while system folders like /etc belong to the administrator account, root. sudo (“superuser do”) runs one command with root’s powers after asking for your password; as you type it, nothing or only asterisks appear, which is normal. You need it for genuine admin jobs such as installing updates (sudo apt update). Do not use it to force past an error you don’t understand, on files in your own home folder, together with rm, or on commands copied from strangers: root can delete or overwrite anything, with no confirmation. For this tutorial, the right fix for “Permission denied” is simply to work inside ~/practice.
When you hit an error that isn’t one of these three, read the message slowly. It almost always names the command, the file and the problem. Our Linux commands cheat sheet lists the common options for every command you’ve learned so far.
Putting it together: a 10-minute practice project
This project uses only the commands you’ve learned. You’ll build a small learning log, back it up, search it, and clean up after yourself.
- Make a project folder and step into it.
““
$ cd ~
$ mkdir project
$ cd project
$ pwd
/home/sam/project
- Create a file with two lines.
““
$ echo "Linux practice log" > log.txt
$ echo "Learned pwd, ls and cd" >> log.txt
- Edit it in nano. Run
nano log.txt, add a line that saysLearned grep and nano, then press Ctrl+O, Enter, Ctrl+X. Check it withcat log.txt; you should see three lines. - Make a backup and give it a clearer name.
““
$ cp log.txt log-copy.txt
$ mv log-copy.txt backup.txt
$ ls
backup.txt log.txt
- Search inside it and peek at the top.
““
$ grep nano log.txt
Learned grep and nano
$ head -n 1 log.txt
Linux practice log
- Step back out and confirm the folder is there. Run
cd .., thenls. You should seeprojectalongside Desktop, Documents and the rest. - Tidy up carefully. Use the training-wheels delete and answer
yto each question:
““
$ rm -ri project
rm: descend into directory 'project'? y
rm: remove regular file 'project/log.txt'? y
rm: remove regular file 'project/backup.txt'? y
rm: remove directory 'project'? y
The files may be asked about in a different order; that’s fine. Run ls once more and project is gone. Keep ~/practice as your sandbox for experiments, or remove it the same way with rm -ri practice.
If you got through all seven steps, you’ve used every one of the basic Linux commands in this guide for real work. That’s the first hour done.
Where to go next
- Bookmark the reference: our Linux commands cheat sheet puts the options for these commands, plus the next ones you’ll want, in quick-scan tables.
- Understand your system: if you’re still choosing between Ubuntu, Mint and others, read what a Linux distro means.
- Put your skills to work: a Raspberry Pi or an old PC running Linux is the perfect place to practice daily. Our homelab guide shows what you can build once the terminal feels normal.
The best next step is simply habit: open the terminal for one small job a day, such as finding a file with ls or reading a note with cat. In a week it stops feeling foreign.
FAQ: basic Linux commands
What are the most basic Linux commands to learn first?
Start with pwd, ls and cd to find your way around, then mkdir, touch, cp, mv and rm to manage files, and cat, less and nano to read and edit them. Add man for help. Those cover most everyday terminal work.
How long does it take to learn the Linux terminal?
About an hour gets you comfortable with the essentials if you type along and do the practice tasks. Real fluency comes from a few weeks of using it for small daily jobs.
Can I break my computer with Linux commands?
Not by following this tutorial. As a regular user you can only change files in your own home folder. The real risks are rm, which deletes without a trash can, and sudo, which removes the safety limits. Use rm -i while learning, and use sudo only when you understand the command.
What’s the difference between the terminal, the shell and bash?
The terminal is the window. The shell is the program inside it that reads your commands and runs them. Bash is the specific shell Ubuntu, Mint, Debian and Raspberry Pi OS use by default.
Is there a recycle bin for files deleted in the terminal?
No. Files removed with rm skip the desktop Trash and can’t be restored with a simple undo. Check with ls first and use rm -i so you’re asked before each deletion.
Why doesn’t my password show when I use sudo?
It’s a security feature so people nearby can’t see its length. Depending on your system, nothing appears or each key shows an asterisk. Type the password and press Enter.
Why does the terminal say “command not found”?
Usually the command is misspelled or has the wrong case, since LS is not ls. Less often, the program simply isn’t installed on your system.
Do these commands work on a Mac or in Windows WSL?
Yes, the commands in this guide work in Windows Subsystem for Linux with an Ubuntu install. macOS uses the zsh shell and slightly different versions of some tools, so the basics match but a few options and outputs differ.





