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

Display Current Working Directorypwd
Change Current Working Directorycd /path/to/directory
Show All Files in Current Directory (Including Hidden Ones)ls -la
Show Sizes of All Files and Directories in Current Directorydu -sh *
Show Available Disk Spacedf -h
Copy Filecp /source/file /destination/file
Move or Rename Filemv /source/file /destination/file
Create Directorymkdir myDirectory
Delete Filerm /path/to/file
Delete Directory Recursivelyrm -rf /path/to/directory
Change File Permissionssudo chmod 644 /path/to/file
Change Owner of Files / Directories (recursive)sudo chown -R user:group /my/path
File System Commands

Viewing and Editing Files

Display File Contentscat /path/to/file
Edit Filesudo nano /path/to/file
View End of Fileless +G /path/to/file
View End of File and Update Automaticallytail -f /path/to/file
Viewing and Editing Files

Package Management Commands

List Upgradable Packagesapt list --upgradable
Upgrade Installed Packagessudo apt upgrade
List All Installed Packagesapt list --installed
Show Version of Installed Packageapt list <package name>
Package Management Commands

Network / Internet / Firewall Commands

Check Host Availabilityping [IP or hostname]
Download Filecurl -O [URL]
List Open Portssudo lsof -i -P -n | grep LISTEN
Open Firewall to Specific Port from Local Subnetsudo ufw allow from to any port 22
Delete Firewall Rule by Numbersudo ufw status numbered
sudo ufw delete 42
Network and Firewall Commands