🐧 The Ultimate Guide to Linux Terminal Commands – From Beginner to Pro
Whether you’re new to Linux or you’re trying to level up your skills, mastering the Linux terminal is essential. The terminal gives you powerful control over your system, from managing files to automating tasks and securing your machine.
In this guide, you’ll go from zero to hero — covering basic, intermediate, and advanced terminal commands — all explained clearly with examples.
🧭 Why the Terminal?
While most Linux distributions offer user-friendly graphical interfaces, the terminal is where the real power lies. It’s faster, more flexible, and essential for:
- System maintenance and troubleshooting
- Software installation and configuration
- Working on servers and remote systems
- Writing powerful shell scripts
- Automating tasks
🟢 Part 1: Beginner Commands – Getting Comfortable
These are the most essential commands to start using Linux effectively.
🔹 Navigation Commands
pwd
– Print Working Directory
Shows your current folder path. bashCopyEdit$ pwd /home/user/Documents
ls
– List Files and Folders
Lists files in the current directory. Usels -l
for details. shellCopyEdit$ ls notes.txt projects image.png
cd
– Change Directory
Navigate to another directory. shellCopyEdit$ cd Downloads
tree
– Show Directory Structure
Shows a visual structure of folders (install withsudo apt install tree
). rubyCopyEdit$ tree
🔹 File & Folder Management
mkdir
– Make Directory shellCopyEdit$ mkdir new_folder
touch
– Create New File shellCopyEdit$ touch myfile.txt
cp
– Copy Files and Folders shellCopyEdit$ cp file.txt backup.txt
mv
– Move or Rename shellCopyEdit$ mv oldname.txt newname.txt
rm
– Remove Files or Folders
Use caution! This deletes files. shellCopyEdit$ rm unwanted.txt $ rm -r folder_to_delete
🔹 Viewing Files
cat
– Show File Contents shellCopyEdit$ cat file.txt
less
/more
– Scroll Through Large Files rubyCopyEdit$ less bigfile.txt
head
,tail
– View Start/End of File shellCopyEdit$ head -n 10 file.txt $ tail -n 5 log.txt
🔹 Terminal Basics
clear
– Clear the screenexit
– Close the terminal sessionman
– Manual pages for commands shellCopyEdit$ man ls
sudo
– Run as Superuser (Admin)
Required for system-level changes. rubyCopyEdit$ sudo apt update
🟡 Part 2: Intermediate Commands – Doing More
Once you’re comfortable, these commands unlock more control and system interaction.
🔸 File Info and Search
stat
– Show detailed file info shellCopyEdit$ stat file.txt
file
– Identify file type arduinoCopyEdit$ file image.png
find
– Search for files and folders arduinoCopyEdit$ find . -name "*.txt"
🔸 Package Management (Ubuntu/Debian)
apt update
– Update package listapt upgrade
– Install available updatesapt install <package>
– Install software rubyCopyEdit$ sudo apt install htop
apt remove
,apt purge
– Uninstall programsdpkg -i
– Install downloaded .deb packages
🔸 System Monitoring
whoami
– Current usernameuname -a
– OS and kernel infouptime
– System runtimedf -h
– Disk space usagedu -sh folder/
– Folder sizetop
orhtop
– Monitor system resources
🔸 File Permissions & Ownership
ls -l
– View permissionschmod
– Change permissions shellCopyEdit$ chmod +x script.sh
chown
– Change file ownership shellCopyEdit$ sudo chown user:user file.txt
umask
– Set default permissions
🔴 Part 3: Advanced Commands – Become a Terminal Pro
These commands make you look like a wizard and save hours of work.
🔹 Text Processing
grep
– Search inside files perlCopyEdit$ grep "error" logfile.txt
awk
– Process column-based text rubyCopyEdit$ awk '{print $1}' users.txt
sed
– Find and replace in files rubyCopyEdit$ sed 's/old/new/g' file.txt
🔹 Bash Scripting Basics
- Variables: bashCopyEdit
name="Aadnanda" echo "Hello, $name"
- Loops: bashCopyEdit
for file in *.txt; do echo $file done
- Conditions: bashCopyEdit
if [ -f file.txt ]; then echo "File exists" fi
🔹 Scheduling with Crontab
Use crontab -e
to edit scheduled tasks.
Example: Run backup.sh every day at 2am
arduinoCopyEdit0 2 * * * /home/user/backup.sh
Or use systemd timers for modern scheduling.
🔹 Networking Tools
ping google.com
– Test internet connectiontraceroute
– Trace network pathip a
– Show IP addressesnetstat -tuln
orss
– List open portsnmap
– Network scanner (install withsudo apt install nmap
)wget
,curl
– Download files from the web
🔹 rsync – Smart File Syncing
Efficiently copy or back up files, locally or remotely.
bashCopyEditrsync -av --progress source/ destination/
rsync -avz user@host:/remote/path /local/backup
🔹 tmux – Terminal Multiplexing
Keep sessions alive, split terminals, and multitask.
- Start:
tmux
- New pane:
Ctrl+B %
- Detach:
Ctrl+B D
- Reattach:
tmux attach
⚡ Power User Tips & Shortcuts
Shortcut | Function |
---|---|
!! | Run last command again |
Ctrl+C | Stop running command |
Ctrl+R | Reverse search command history |
Tab | Autocomplete file/command |
history | Show command history |
alias | Create shortcuts |
bashCopyEditalias update='sudo apt update && sudo apt upgrade'
✅ Final Thoughts
The Linux terminal may seem intimidating at first, but with time, it becomes your most powerful tool. Whether you’re managing files, configuring your system, or automating workflows, the command line is fast, efficient, and limitless.
💡 What Next?
- Create your first Bash script
- Set up daily backups with cron
- Explore advanced tools like
git
,docker
, andjournalctl
- Customize your terminal with
zsh
,Oh My Zsh
, and themes