Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#linux-server-cheatsheet

Linux Server Administration Cheatsheet

A quick reference for day-to-day Linux server administration, covering system info, user management, and service control.

System Information

uname -a                  # Print all system information
cat /etc/os-release       # Show OS distribution info
uptime                    # Show how long the system has been running and load average
hostname                  # Show system hostname
hostnamectl set-hostname <name> # Set a new hostname
lscpu                     # Display CPU architecture information
free -m                   # Show free and used memory in MB

Monitoring & Performance

top                       # Real-time process viewer
htop                      # Improved, interactive process viewer (needs installation)
vmstat 1                  # Report virtual memory statistics every 1 second
iostat -xz 1              # CPU and I/O statistics (from sysstat package)
dmesg -T                  # Print kernel & boot messages with human-readable timestamps
watch -n 2 <command>      # Execute a command every 2 seconds and display output

User and Group Management

# Users
id username               # Print user and group IDs
whoami                    # Print current user
sudo adduser username     # Create a new user (interactive)
sudo useradd -m username  # Create a new user (non-interactive, creates home dir)
sudo usermod -aG sudo username # Add user to the sudo group (Ubuntu/Debian)
sudo usermod -aG wheel username # Add user to the wheel group (RHEL/CentOS)
sudo deluser username     # Delete user
sudo passwd username      # Change user password
 
# Groups
groups username           # Show groups for a user
sudo addgroup groupname   # Create a new group

File Permissions

chmod 755 file            # Owner: rwx, Group: r-x, Others: r-x
chmod +x file             # Make file executable
chown user:group file     # Change owner and group of a file
chown -R user:group dir/  # Recursively change owner and group

Service Management (Systemd)

Systemd is the default init system for modern Linux distributions.

sudo systemctl start <service>     # Start a service
sudo systemctl stop <service>      # Stop a service
sudo systemctl restart <service>   # Restart a service
sudo systemctl reload <service>    # Reload configuration without stopping
sudo systemctl enable <service>    # Enable service to start on boot
sudo systemctl disable <service>   # Disable service from starting on boot
sudo systemctl status <service>    # Check service status
sudo systemctl list-units --type=service # List all running services

Logs (Journalctl)

sudo journalctl -u <service>       # Show logs for a specific service
sudo journalctl -f                 # Follow logs in real-time (like tail -f)
sudo journalctl -xe                # Show recent errors with explanations