Structured list of essential Linux commands you need when working on servers remotely via SSH. This isn't every command under the sun, but a practical toolbox covering systemd, networking, users, permissions, files, processes, and SSH.
- Connect to a server:
ssh user@hostname
- Connect with a key:
ssh -i ~/.ssh/id_rsa user@hostname - Copy files to server:
scp file.txt user@hostname:/path/to/dest
- Copy files from server:
scp user@hostname:/path/to/file.txt ./
- Keep tunnel alive:
ssh -o ServerAliveInterval=60 user@hostname
- Start a service:
sudo systemctl start servicename
- Stop a service:
sudo systemctl stop servicename
- Restart a service:
sudo systemctl restart servicename
- Enable service at boot:
sudo systemctl enable servicename - Disable service:
sudo systemctl disable servicename
- Check status:
systemctl status servicename
- Show logs:
journalctl -u servicename
- Launch TUI:
nmtui
- CLI interface:
nmcli device status nmcli connection show nmcli device wifi list nmcli device wifi connect "SSID" password "yourpassword"
- Restart networking:
sudo systemctl restart NetworkManager
- Add user:
sudo adduser username
- Delete user:
sudo deluser username
- Add user to group:
sudo usermod -aG groupname username
- Change password:
passwd username
- Check groups:
groups username
- Change file ownership:
sudo chown user:group file.txt
- Change file permissions:
chmod 755 script.sh chmod 644 file.txt
- Recursive apply:
chown -R user:group folder/ chmod -R 755 folder/
- List files:
ls -lah
- Change directory:
cd /path/to/dir - Copy:
cp file1 file2 cp -r dir1 dir2
- Move/rename:
mv file1 file2
- Delete:
rm file.txt rm -r folder/
- Debian/Ubuntu:
sudo apt update && sudo apt upgrade sudo apt install package sudo apt remove package - RHEL/Fedora:
sudo dnf update sudo dnf install package sudo dnf remove package
- Arch:
sudo pacman -Syu sudo pacman -S package sudo pacman -R package
- See running processes:
ps aux | grep processname - Kill process:
kill -9 PID - Live monitor:
top htop # (if installed) - Disk usage:
df -h du -sh folder/
- Memory usage:
free -h
- System logs:
journalctl -xe
- Follow live logs:
tail -f /var/log/syslog tail -f /var/log/messages
- Specific service logs:
journalctl -u ssh
- Find files:
find / -name filename.txt
- Search inside files:
grep "pattern" file.txt - Download file:
wget URL curl -O URL
- Tar & extract:
tar -czvf archive.tar.gz folder/ tar -xzvf archive.tar.gz
- Check open ports:
ss -tulpn netstat -tulpn # (if installed)