Apply for Free VPS

Linux Command Cheat Sheet

Everyday server commands, searchable, with copy buttons.

Files and folders

ls -lahList files with sizes and hidden entries
cd /var/logChange directory
cp -r src/ dest/Copy a folder
mv old newMove or rename
rm -i fileDelete a file, asking first
find /var -name "*.log" -size +100MFind large log files
tar -czf backup.tar.gz /srv/appCreate a compressed archive

Viewing and searching

less /var/log/syslogPage through a file
tail -f /var/log/nginx/error.logFollow a log live
grep -rin "error" /var/logSearch text recursively

System and resources

uptimeLoad average and running time
free -hMemory use
df -hDisk space per filesystem
du -xh --max-depth=1 / | sort -hLargest folders
topLive process view
journalctl -p err -bErrors since boot

Services (systemd)

systemctl status nginxCheck a service
sudo systemctl restart nginxRestart a service
sudo systemctl enable --now nginxStart now and at boot
journalctl -u nginx -fFollow service logs

Packages (Debian/Ubuntu)

sudo apt updateRefresh package lists
sudo apt upgradeInstall updates
sudo apt install nginxInstall a package
sudo apt autoremoveRemove unused dependencies

Packages (AlmaLinux/Rocky)

sudo dnf upgradeInstall updates
sudo dnf install nginxInstall a package

Networking

ip -brief addressNetwork addresses
ss -tulpnListening ports and processes
curl -I https://example.comFetch response headers
ping -c 4 1.1.1.1Test connectivity
dig example.com +shortDNS lookup

Users, permissions and SSH

sudo adduser deployCreate a user
sudo usermod -aG sudo deployAllow sudo (Debian/Ubuntu)
chmod 600 ~/.ssh/authorized_keysRestrict key file permissions
sudo chown -R www-data:www-data /var/www/siteChange ownership
ssh-keygen -t ed25519Create a key pair (on your computer)
sudo sshd -tValidate SSH configuration before reloading

See VPS plans More tools