Linux Command Line Basics
The Terminal and Your First Commands
The terminal (also called the shell, or the command line) is a text-based interface for controlling your computer. Instead of clicking, you type commands and press Enter.
Opening a terminal
- Ubuntu / Debian: press
Ctrl + Alt + T - macOS: press
Cmd + Space, type "Terminal" - Any Linux: look for an app called "Terminal", "Konsole", or "xterm"
The prompt
When the terminal opens you see something like this:
username@hostname:~$
This is the prompt. It is the shell's way of saying "I am ready for your command." The $ marks the end of the prompt — you type your commands after it.
username— the user you are logged in ashostname— the name of the machine~— your current directory. The tilde is shorthand for your home directory, e.g./home/username
Not the `$`
When tutorials show $ ls -la, the $ is just the prompt symbol. You type ls -la — not the dollar sign.
Your first command: pwd
pwd stands for print working directory — it shows where you are right now:
pwd
You should see your home directory:
/home/username
Listing files with ls
ls lists the contents of the current directory:
ls
To see hidden files (those starting with a dot, like .bashrc) and more detail:
ls -la
| Flag | Meaning |
|---|---|
-l |
Long format: permissions, owner, size, date |
-a |
Show all files, including hidden ones |
-h |
Human-readable sizes (1.4K instead of 1480) |
Combine flags
Flags can be combined: ls -lah does exactly what ls -l -a -h does.
Try it
- Run
pwdand note your current directory - Run
ls— what do you see? - Run
ls -la— notice the hidden files that appeared
Advertisement