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 foldernameCreate a new directory.
touch filename.txtCreate an empty file.
cp file1 file2Copy a file.
cp -r dir1 dir2Copy a directory recursively.
mv oldname newnameRename or move a file.
rm filenameDelete a file.
rm -r foldernameDelete a directory recursively.
find /path -name "filename"Search for a file by name.
locate filenameQuickly find files if locate database is available.

3. File Viewing & Editing

Command What It Does
cat filenamePrint a file’s contents.
less filenameView a file one screen at a time.
head filenameShow the first lines of a file.
tail filenameShow the last lines of a file.
tail -f /var/log/syslogFollow a log file in real time.
nano filenameEdit a file with Nano.
vim filenameEdit a file with Vim.
grep "text" filenameSearch for text inside a file.
grep -R "text" /pathSearch recursively through files.

4. Permissions & Ownership

Command What It Does
chmod 644 fileSet standard read/write permissions for a file.
chmod 755 directorySet standard executable directory permissions.
chown user:user fileChange file owner and group.
chown -R user:user folderChange ownership recursively.
ls -lView permissions, owners, and groups.

5. Processes & System Monitoring

Command What It Does
topLive view of running processes and resource usage.
htopEnhanced process viewer if installed.
ps auxList all running processes.
ps aux | grep nginxFind a running process by name.
kill PIDTerminate a process by PID.
kill -9 PIDForce kill a stuck process.
uptimeShow uptime and system load.
free -hDisplay memory usage in human-readable format.
vmstatShow system performance stats.

6. Services & systemd

Command What It Does
systemctl status nginxCheck service status.
systemctl restart nginxRestart a service.
systemctl reload nginxReload config without full restart if supported.
systemctl stop nginxStop a service.
systemctl start nginxStart a service.
systemctl enable nginxEnable service at boot.
systemctl disable nginxDisable service at boot.
journalctl -u nginxShow logs for a specific service.
journalctl -xeView recent systemd-related errors.

7. Logs

Command What It Does
tail -f /var/log/syslogWatch general system logs live.
tail -f /var/log/auth.logWatch authentication/login attempts.
journalctl -fFollow systemd journal in real time.
journalctl --since "1 hour ago"Show logs from the last hour.
dmesg | tailView recent kernel messages.

8. Networking

Command What It Does
ip aShow IP addresses and interfaces.
ip routeShow routing table.
ping 8.8.8.8Test connectivity to a remote host.
ss -tulpnShow listening ports and associated processes.
curl ifconfig.meShow public IP address.
curl -I https://example.comFetch only HTTP headers from a site.
wget URLDownload a file from the command line.
nslookup domain.comCheck DNS resolution.
dig domain.comDetailed DNS lookup.

9. Disk & Storage

Command What It Does
df -hShow disk usage by mounted filesystem.
du -sh *Show size of items in current directory.
du -sh /path/to/folderShow total size of a folder.
lsblkList block devices and partitions.
mountShow mounted filesystems.

10. Users & Identity

Command What It Does
whoamiShow current user.
idShow user and group IDs.
whoShow logged-in users.
lastShow login history.
passwdChange current user password.
sudo -iOpen a root shell if sudo is permitted.

11. Packages & Updates

Debian / Ubuntu:

Command What It Does
sudo apt updateRefresh package lists.
sudo apt upgradeInstall available upgrades.
sudo apt install package-nameInstall a package.
sudo apt remove package-nameRemove a package.
sudo apt autoremoveRemove unused dependencies.

RHEL / CentOS / Fedora:

Command What It Does
sudo dnf check-updateCheck for updates.
sudo dnf upgradeInstall updates.
sudo dnf install package-nameInstall a package.
sudo dnf remove package-nameRemove a package.

12. Archives & Compression

Command What It Does
tar -czf archive.tar.gz folder/Create a compressed tar archive.
tar -xzf archive.tar.gzExtract a compressed tar archive.
zip -r archive.zip folder/Create a ZIP archive.
unzip archive.zipExtract 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.