If you work with servers, cloud hosting, or backend development โ you will use these commands daily. No fluff, just the commands you actually need.
pwd # Where am I right now?
ls # What files are here?
ls -la # Show all files including hidden ones
cd folder # Go into a folder
cd .. # Go back one level
cd ~ # Go to home directory
touch file.txt # Create empty file
cat file.txt # Print file contents
nano file.txt # Edit file (Ctrl+S save, Ctrl+X exit)
rm file.txt # Delete file
cp file.txt copy.txt # Copy file
mv old.txt new.txt # Rename or move file
โ ๏ธ
rmis permanent. There's no recycle bin in Linux.
mkdir myfolder # Create folder
rm -r myfolder # Delete folder and everything inside
cp -r folder copy # Copy entire folder
find . -name "file.txt" # Find file by name
grep "word" file.txt # Find word inside file
grep -r "word" . # Search word in all files
whoami # Current logged-in user
chmod +x script.sh # Make file executable
chmod 600 file.txt # Only owner can read/write
sudo command # Run as admin
top # Live view of running processes (press Q to exit)
df -h # Disk space usage
free -h # RAM usage
uptime # How long server has been running
ping google.com # Test internet connection
ip a # Show your IP address
curl https://site # Fetch a URL from terminal
sudo apt update # Refresh package list
sudo apt install package_name # Install a package
sudo apt remove package_name # Remove a package
sudo systemctl start nginx # Start a service
sudo systemctl stop nginx # Stop a service
sudo systemctl restart nginx # Restart a service
sudo systemctl status nginx # Check if service is running
| Shortcut | What it does |
|---|---|
Ctrl + C |
Stop running command |
Ctrl + L |
Clear terminal screen |
Tab |
Auto-complete file/folder name |
โ arrow |
Repeat last command |