Server Operations Reference
Common Linux Server Commands
A practical quick-reference guide for common Linux server administration tasks: navigating the filesystem, checking services, reviewing logs, monitoring usage, managing packages, and troubleshooting everyday issues.
2. Files & Directories
| Command | What It Does |
|---|---|
mkdir foldername | Create a new directory. |
touch filename.txt | Create an empty file. |
cp file1 file2 | Copy a file. |
cp -r dir1 dir2 | Copy a directory recursively. |
mv oldname newname | Rename or move a file. |
rm filename | Delete a file. |
rm -r foldername | Delete a directory recursively. |
find /path -name "filename" | Search for a file by name. |
locate filename | Quickly find files if locate database is available. |
3. File Viewing & Editing
| Command | What It Does |
|---|---|
cat filename | Print a fileβs contents. |
less filename | View a file one screen at a time. |
head filename | Show the first lines of a file. |
tail filename | Show the last lines of a file. |
tail -f /var/log/syslog | Follow a log file in real time. |
nano filename | Edit a file with Nano. |
vim filename | Edit a file with Vim. |
grep "text" filename | Search for text inside a file. |
grep -R "text" /path | Search recursively through files. |
4. Permissions & Ownership
| Command | What It Does |
|---|---|
chmod 644 file | Set standard read/write permissions for a file. |
chmod 755 directory | Set standard executable directory permissions. |
chown user:user file | Change file owner and group. |
chown -R user:user folder | Change ownership recursively. |
ls -l | View permissions, owners, and groups. |
5. Processes & System Monitoring
| Command | What It Does |
|---|---|
top | Live view of running processes and resource usage. |
htop | Enhanced process viewer if installed. |
ps aux | List all running processes. |
ps aux | grep nginx | Find a running process by name. |
kill PID | Terminate a process by PID. |
kill -9 PID | Force kill a stuck process. |
uptime | Show uptime and system load. |
free -h | Display memory usage in human-readable format. |
vmstat | Show system performance stats. |
6. Services & systemd
| Command | What It Does |
|---|---|
systemctl status nginx | Check service status. |
systemctl restart nginx | Restart a service. |
systemctl reload nginx | Reload config without full restart if supported. |
systemctl stop nginx | Stop a service. |
systemctl start nginx | Start a service. |
systemctl enable nginx | Enable service at boot. |
systemctl disable nginx | Disable service at boot. |
journalctl -u nginx | Show logs for a specific service. |
journalctl -xe | View recent systemd-related errors. |
7. Logs
| Command | What It Does |
|---|---|
tail -f /var/log/syslog | Watch general system logs live. |
tail -f /var/log/auth.log | Watch authentication/login attempts. |
journalctl -f | Follow systemd journal in real time. |
journalctl --since "1 hour ago" | Show logs from the last hour. |
dmesg | tail | View recent kernel messages. |
8. Networking
| Command | What It Does |
|---|---|
ip a | Show IP addresses and interfaces. |
ip route | Show routing table. |
ping 8.8.8.8 | Test connectivity to a remote host. |
ss -tulpn | Show listening ports and associated processes. |
curl ifconfig.me | Show public IP address. |
curl -I https://example.com | Fetch only HTTP headers from a site. |
wget URL | Download a file from the command line. |
nslookup domain.com | Check DNS resolution. |
dig domain.com | Detailed DNS lookup. |
9. Disk & Storage
| Command | What It Does |
|---|---|
df -h | Show disk usage by mounted filesystem. |
du -sh * | Show size of items in current directory. |
du -sh /path/to/folder | Show total size of a folder. |
lsblk | List block devices and partitions. |
mount | Show mounted filesystems. |
10. Users & Identity
| Command | What It Does |
|---|---|
whoami | Show current user. |
id | Show user and group IDs. |
who | Show logged-in users. |
last | Show login history. |
passwd | Change current user password. |
sudo -i | Open a root shell if sudo is permitted. |
11. Packages & Updates
Debian / Ubuntu:
| Command | What It Does |
|---|---|
sudo apt update | Refresh package lists. |
sudo apt upgrade | Install available upgrades. |
sudo apt install package-name | Install a package. |
sudo apt remove package-name | Remove a package. |
sudo apt autoremove | Remove unused dependencies. |
RHEL / CentOS / Fedora:
| Command | What It Does |
|---|---|
sudo dnf check-update | Check for updates. |
sudo dnf upgrade | Install updates. |
sudo dnf install package-name | Install a package. |
sudo dnf remove package-name | Remove a package. |
12. Archives & Compression
| Command | What It Does |
|---|---|
tar -czf archive.tar.gz folder/ | Create a compressed tar archive. |
tar -xzf archive.tar.gz | Extract a compressed tar archive. |
zip -r archive.zip folder/ | Create a ZIP archive. |
unzip archive.zip | Extract a ZIP archive. |
13. Use With Caution
rm -rf foldernameβ Force delete recursively. Double-check before running.kill -9 PIDβ Force kill a process immediately.chmod -R 777 folderβ Generally unsafe on production systems.chown -R user:user /β Catastrophic if used incorrectly.ddβ Powerful disk utility; mistakes can destroy data.reboot/shutdown -h nowβ Only use when appropriate.
