Frequently Used Linux Commands for Server Administration
1. Navigation and Filesystem
Command |
Description |
ls |
Lists files and directories. |
cd |
Changes the current directory. |
pwd |
Displays the current directory. |
mkdir |
Creates a new directory. |
rm |
Deletes files or directories (rm -r for directories). |
cp |
Copies files or directories (cp -r ). |
mv |
Moves or renames files. |
find |
Searches for files based on criteria. |
df -h |
Displays disk space usage of filesystems. |
du -sh |
Shows the size of a directory. |
2. User and Permission Management
Command |
Description |
whoami |
Displays the current user. |
id |
Displays user and group information. |
adduser |
Creates a new user. |
usermod |
Modifies user accounts (e.g., adding to groups). |
passwd |
Changes a user's password. |
chmod |
Changes file permissions. |
chown |
Changes the owner of a file or directory. |
groups |
Lists groups of the current user. |
3. Network Management
Command |
Description |
ip a |
Displays network configurations. |
ping |
Checks the reachability of a host. |
traceroute |
Shows the path a packet takes to a destination. |
netstat -tuln |
Displays open ports and connections. |
ss -tuln |
Displays detailed network connections. |
curl |
Executes HTTP requests. |
wget |
Downloads files from the internet. |
scp |
Copies files between hosts. |
rsync |
Synchronizes files between hosts. |
4. Process and System Monitoring
Command |
Description |
top |
Displays running processes and resource usage. |
htop |
Interactive process viewer. |
ps aux |
Lists all processes. |
kill |
Terminates processes by PID. |
uptime |
Displays system uptime. |
free -h |
Shows memory usage. |
vmstat |
Displays real-time system statistics. |
5. Package Management
Debian-based Systems (e.g., Ubuntu)
Command |
Description |
apt update |
Updates the package list. |
apt upgrade |
Installs available updates. |
apt install <package> |
Installs a package. |
apt remove <package> |
Removes a package. |
dpkg -l |
Lists installed packages. |
RHEL-based Systems (e.g., CentOS, Fedora)
Command |
Description |
dnf update |
Performs system updates. |
dnf install <package> |
Installs a package. |
dnf remove <package> |
Removes a package. |
rpm -qa |
Lists installed RPM packages. |
6. Security
Command |
Description |
ufw status |
Displays the status of the firewall (Ubuntu). |
ufw allow <port> |
Allows incoming traffic on a port. |
iptables |
Configures advanced firewall rules. |
fail2ban-client status |
Displays the status of Fail2ban. |
rkhunter --check |
Checks the system for rootkits. |
ssh-keygen |
Generates SSH key pairs. |
ssh-copy-id |
Copies SSH keys to a remote host. |
7. Log and Error Analysis
Command |
Description |
journalctl |
Displays system logs. |
dmesg |
Shows kernel messages. |
tail -f /var/log/syslog |
Monitors log files in real-time. |
grep <word> |
Searches files for a specific term. |
8. Backup and Restoration
Command |
Description |
tar -czvf <file>.tar.gz <folder> |
Creates a compressed archive. |
tar -xzvf <file>.tar.gz |
Extracts an archive. |
rsync -av <source> <destination> |
Synchronizes files. |
dd if=<source> of=<destination> |
Creates exact copies of disks. |
Conclusion
This is a collection of the most commonly used commands for Linux server administration. These commands will help you manage, troubleshoot, and optimize your system effectively.