๐ง 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/Documentslsโ List Files and Folders
Lists files in the current directory. Usels -lfor details. shellCopyEdit$ ls notes.txt projects image.pngcdโ Change Directory
Navigate to another directory. shellCopyEdit$ cd Downloadstreeโ 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_foldertouchโ Create New File shellCopyEdit$ touch myfile.txtcpโ Copy Files and Folders shellCopyEdit$ cp file.txt backup.txtmvโ Move or Rename shellCopyEdit$ mv oldname.txt newname.txtrmโ 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.txtless/moreโ Scroll Through Large Files rubyCopyEdit$ less bigfile.txthead,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 lssudoโ 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.txtfileโ Identify file type arduinoCopyEdit$ file image.pngfindโ 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 htopapt 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 sizetoporhtopโ Monitor system resources
๐ธ File Permissions & Ownership
ls -lโ View permissionschmodโ Change permissions shellCopyEdit$ chmod +x script.shchownโ Change file ownership shellCopyEdit$ sudo chown user:user file.txtumaskโ 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.txtawkโ Process column-based text rubyCopyEdit$ awk '{print $1}' users.txtsedโ 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 -tulnorssโ 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
