Basic Linux Commands
Linux is very powerful because of its command-line interface. In this section, you'll learn the most important basic commands you will use every day.
Introduction
The terminal is where you type commands. The shell (like Bash or Zsh) is the program that reads your commands and runs them.
Terminal and shell
- You can open the terminal from your Linux desktop (e.g. Ctrl+Alt+T on Ubuntu).
- On WSL, open the Ubuntu app from the Start menu.
- Commands are usually lowercase and sensitive to spelling.
Navigation commands
These commands help you move around the Linux file system:
pwd– Print Working Directory (shows where you are).ls– List files and folders in the current directory.cd <folder>– Change directory.cd ..– Go one level up.cd ~– Go to your home directory.
Working with files and directories
Use these commands to create, view, and remove files or folders:
touch file.txt– Create an empty file or update its timestamp.mkdir projects– Create a new directory.cp file1 file2– Copy a file.mv oldname newname– Move or rename a file or directory.rm file.txt– Remove a file (careful, this does not use Recycle Bin).rm -r folder– Remove a directory and its contents (very careful).
Viewing file content
These commands help you read what's inside files:
cat file.txt– Show the full content (small files).less file.txt– Scroll through large files (pressqto quit).head file.txt– Show the first lines.tail file.txt– Show the last lines.
Getting help
Linux has built-in help so you can learn commands directly in the terminal:
man <command>– Open the manual page (e.g.man ls).<command> --help– Quick usage help (e.g.ls --help).
Tip: Practice is the best way to learn. Create a test folder in your home directory and play with these commands so you don't break anything important.
Common basic commands summary
Memorize these to feel at home in the terminal:
| Command | What it does |
|---|---|
pwd | Show current directory. |
ls | List files and folders. |
cd | Change directory. |
mkdir | Create a new directory. |
rm | Remove files (and with -r, directories). |
cp | Copy files or directories. |
mv | Move or rename files or directories. |
cat / less | View file contents. |
Practice questions
Open a terminal and write down the exact commands you used to create a folder called linux_practice and then create an empty file notes.txt inside it.
Hint: Think about mkdir, cd, and touch.
Which 3 commands do you think you will use the most in your daily Linux work, and why?
Hint: For example ls, cd, cat, less, etc. Explain your choice.
Quiz
Test your understanding. Click an answer to see if it's correct.
1. Which command shows the current directory you are in?
pwd means "print working directory" and shows your current path.
2. What is the safest way to go back to your home directory?
~ represents your home directory in most shells.
3. Which command will create a new directory called projects?
Use mkdir (make directory).
4. You want to see the content of a small text file named readme.txt. Which command is most suitable?
cat will print the content of the file to your terminal.
5. Which of these commands is dangerous if used carelessly?
rm -r / could delete important files; never run destructive commands you don't fully understand.
Nice work! You've learned the essential commands. Next, let's understand how the Linux file system is organized.