List of Useful Linux Commands

This post contains a collection of useful Linux commands for the Ubuntu distribution. The list is extended every time I find a new handy command. Most of the commands are also applicable to other Linux distributions.

File System Commands

Description EXAMPLE
Display Current Working Directory pwd
Change Current Working Directory cd /path/to/directory
Show All Files in Current Directory (Including Hidden Ones) ls -la
Show Sizes of All Files and Directories in Current Directory du -sh *
Show Available Disk Space df -h
Copy File cp /source/file /destination/file
Move or Rename File mv /source/file /destination/file
Create Directory mkdir myDirectory
Delete File rm /path/to/file
Delete Directory Recursively rm -rf /path/to/directory
Create Symbolic Link ln -s /path/to/target /path/to/symlink
Change File Permissions sudo chmod 644 /path/to/file
Change Owner of Files / Directories (recursive) sudo chown -R user:group /my/path
Show All Disks and Partitions lsblk
Mount USB Stick pmount /dev/sdf1
Unmount USB Stick pumount /dev/sdf1
File System Commands

Viewing, Editing and Comparing Files

Description Example
Display File Contents cat /path/to/file
Edit File sudo nano /path/to/file
View End of File less +G /path/to/file
View End of File and Update Automatically tail -f /path/to/file
Compare Files in Two Directories Recursively diff -rq /path/to/dir1 /path/to/dir2
Viewing, Editing and Comparing Files

Package Management Commands

Description Example
List Upgradable Packages apt list --upgradable
Upgrade Installed Packages sudo apt upgrade
List All Installed Packages apt list --installed
Show Version of Installed Package apt list <package name>
Package Management Commands

Network / Internet / Firewall Commands

Description Example
Check Host Availability ping [IP or hostname]
Download File curl -O [URL]
List Open Ports sudo lsof -i -P -n | grep LISTEN
Open Firewall to Specific Port from Local Subnet sudo ufw allow from to any port 22
Delete Firewall Rule by Number sudo ufw status numbered
sudo ufw delete 42
Network and Firewall Commands