Wednesday, April 30, 2025

List of Essential Ubuntu Terminal Commands with Examples

 

List of Essential Ubuntu Terminal Commands with Examples

The Ubuntu terminal (Bash shell) is a powerful tool for managing files, installing software, and controlling system processes. Below is a comprehensive list of commonly used commands with practical examples.




1. File & Directory Operations

CommandDescriptionExample
lsList directory contentsls -l (detailed list)
cdChange directorycd /home/user/Documents
pwdPrint working directorypwd → /home/user
mkdirCreate a directorymkdir new_folder
rmdirRemove empty directoryrmdir empty_folder
rmRemove files/directoriesrm file.txt (file)
rm -r folder (recursive)
cpCopy files/directoriescp file.txt /backup/
mvMove/rename filesmv old.txt new.txt (rename)
mv file.txt /target/ (move)
touchCreate empty filetouch newfile.txt
catDisplay file contentcat notes.txt
nanoText editornano file.txt
chmodChange file permissionschmod +x script.sh (make executable)
chownChange file ownersudo chown user:group file.txt

2. System Information & Monitoring

CommandDescriptionExample
uname -aShow system infouname -a (kernel details)
df -hDisk space usagedf -h (human-readable)
free -hMemory usagefree -h (RAM info)
topReal-time process monitortop (press q to quit)
htopInteractive process viewersudo apt install htop then htop
neofetchDisplay system specssudo apt install neofetch then neofetch
uptimeSystem uptimeuptime

3. Package Management (APT)

CommandDescriptionExample
sudo apt updateUpdate package listsudo apt update
sudo apt upgradeUpgrade installed packagessudo apt upgrade
sudo apt installInstall a packagesudo apt install git
sudo apt removeRemove a packagesudo apt remove vim
sudo apt autoremoveRemove unused packagessudo apt autoremove
apt searchSearch for packagesapt search python
apt showShow package detailsapt show firefox

4. User & Permission Management

CommandDescriptionExample
sudoRun as superusersudo nano /etc/hosts
suSwitch usersu root
passwdChange passwordpasswd (current user)
sudo passwd username (another user)
whoamiShow current userwhoami
adduserAdd a new usersudo adduser bob
deluserDelete a usersudo deluser bob
usermodModify user (e.g., add to group)sudo usermod -aG sudo bob

5. Network & Connectivity

CommandDescriptionExample
pingTest network connectionping google.com
ifconfigNetwork interfaces (deprecated, use ip)ifconfig
ip aShow IP addressesip a
wgetDownload fileswget https://example.com/file.zip
curlFetch web contentcurl -O https://example.com/file.zip
sshRemote loginssh user@192.168.1.100
scpSecure file copyscp file.txt user@192.168.1.100:/home/user/
netstatNetwork statisticsnetstat -tuln (open ports)

6. Process Management

CommandDescriptionExample
psList running processesps aux (all processes)
killTerminate a processkill 1234 (PID)
kill -9 1234 (force kill)
pkillKill by process namepkill firefox
bg / fgBackground/Foreground processbg %1 (resume job #1 in background)
jobsList background jobsjobs

7. File Compression & Archiving

CommandDescriptionExample
tarArchive filestar -cvf archive.tar /folder (create)
tar -xvf archive.tar (extract)
gzipCompress filesgzip file.txt → file.txt.gz
gunzipDecompress .gz filesgunzip file.txt.gz
zip / unzipZIP compressionzip archive.zip file.txt
unzip archive.zip

8. Miscellaneous Useful Commands

CommandDescriptionExample
historyShow command historyhistory
grepSearch text in filesgrep "error" log.txt
findSearch for filesfind /home -name "*.txt"
aliasCreate command shortcutsalias ll='ls -la'
shutdownPower off/restartsudo shutdown now (power off)
sudo reboot (restart)

Conclusion

These commands cover file management, system monitoring, networking, package control, and more.

Pro Tips:

  • Use man for help (e.g., man ls).

  • Press Tab for auto-completion.

  • Ctrl+C cancels a running command.

No comments:

Post a Comment