Skip to content

Instantly share code, notes, and snippets.

@souravrax
Created August 24, 2025 06:43
Show Gist options
  • Save souravrax/6b9c06063afc070089b2a23d66b1c93e to your computer and use it in GitHub Desktop.
Save souravrax/6b9c06063afc070089b2a23d66b1c93e to your computer and use it in GitHub Desktop.

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.


๐Ÿ“˜ Essential Linux Server Commands

1. SSH Basics

  • 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

2. System Management (systemd)

  • 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

3. Network Management (NetworkManager)

  • 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

4. User Management

  • 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

5. File Permissions

  • 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/

6. File & Directory Management

  • 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/

7. Package Management

  • 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

8. Process & Resource Management

  • 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

9. Logs & Monitoring

  • System logs:
    journalctl -xe
  • Follow live logs:
    tail -f /var/log/syslog
    tail -f /var/log/messages
  • Specific service logs:
    journalctl -u ssh

10. Misc Essentials

  • 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment