Why Learn the Linux Command Line?
The terminal might look intimidating at first, but it's one of the most powerful tools available to any Linux user. Once you learn a handful of fundamental commands, you'll be able to navigate your system, manage files, install software, and troubleshoot problems far more efficiently than clicking through menus. This guide covers the essential commands to get you started.
Opening the Terminal
In Ubuntu, you can open the terminal with the keyboard shortcut Ctrl + Alt + T, or by searching for "Terminal" in the Applications menu. The terminal prompt typically looks like this:
username@hostname:~$
The ~ symbol represents your home directory. Everything after the $ is where you type commands.
Navigating the File System
pwd — Print Working Directory
Shows you exactly where you are in the file system:
pwd
ls — List Files and Directories
ls # basic listing
ls -l # detailed listing with permissions and sizes
ls -la # include hidden files (those starting with a dot)
cd — Change Directory
cd Documents # navigate into a folder
cd .. # go up one level
cd ~ # return to your home directory
cd /etc # navigate to an absolute path
Working with Files and Directories
mkdir — Make a Directory
mkdir projects # create a folder
mkdir -p projects/web/css # create nested folders at once
touch — Create an Empty File
touch notes.txt
cp — Copy Files
cp file.txt backup.txt # copy a file
cp -r myfolder/ newfolder/ # copy a directory recursively
mv — Move or Rename Files
mv oldname.txt newname.txt # rename a file
mv file.txt ~/Documents/ # move a file to another directory
rm — Remove Files and Directories
rm file.txt # delete a file
rm -r myfolder/ # delete a folder and its contents
⚠️ Warning: There is no Recycle Bin in the terminal. Deleted files are gone immediately. Double-check before using rm.
Viewing File Contents
cat file.txt # print entire file to screen
less file.txt # scrollable viewer (press q to quit)
head file.txt # show first 10 lines
tail file.txt # show last 10 lines
tail -f logfile.log # watch a file update in real time
Package Management (Ubuntu/Debian)
sudo apt update # refresh the package list
sudo apt upgrade # install all available updates
sudo apt install packagename # install a package
sudo apt remove packagename # remove a package
apt search keyword # search for available packages
Getting Help
Every command has a built-in manual. Use these to learn more:
man ls # full manual for the ls command
ls --help # shorter help summary
Essential Keyboard Shortcuts
- Tab — Autocomplete file/folder names
- ↑ / ↓ arrow keys — Browse command history
- Ctrl + C — Stop a running command
- Ctrl + L — Clear the terminal screen
- Ctrl + R — Search through command history
Practice Makes Perfect
The best way to get comfortable with the command line is to use it daily for small tasks — browsing files, checking updates, or reading logs. You don't need to memorize everything at once; most experienced Linux users look things up regularly. Bookmark this guide and refer back to it whenever you need a refresher.