0
0
Linux CLIscripting~5 mins

Why sysadmin skills manage production servers in Linux CLI - Why It Works

Choose your learning style9 modes available
Introduction
Managing production servers means keeping the computers that run important apps safe and working well. Sysadmin skills help you fix problems fast, keep things running smoothly, and make sure users can always access the services they need.
When a website suddenly stops working and you need to find and fix the problem quickly.
When you want to update software on a server without causing downtime for users.
When you need to check server health and resource use to prevent crashes.
When you want to automate backups to protect important data.
When you need to set up security rules to keep hackers out of your servers.
Commands
This command shows how long the server has been running and its current load. It helps you check if the server is stable or overloaded.
Terminal
uptime
Expected OutputExpected
10:15:42 up 5 days, 3:22, 2 users, load average: 0.15, 0.10, 0.05
Runs the top command in batch mode to show current processes and resource use once. Useful for checking what is using CPU and memory.
Terminal
top -b -n 1
Expected OutputExpected
top - 10:15:42 up 5 days, 3:22, 2 users, load average: 0.15, 0.10, 0.05 Tasks: 120 total, 1 running, 119 sleeping, 0 stopped, 0 zombie %Cpu(s): 5.0 us, 2.0 sy, 0.0 ni, 92.0 id, 1.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 2048000 total, 500000 free, 800000 used, 748000 buff/cache KiB Swap: 1024000 total, 1024000 free, 0 used. 1000000 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1234 root 20 0 500000 30000 10000 S 2.0 1.5 0:01.23 my-app 5678 user 20 0 300000 20000 5000 S 1.0 1.0 0:00.45 worker
-b - Run in batch mode for scripting or single snapshot
-n 1 - Show output once and exit
Shows disk space usage in a human-readable format. Helps you see if the server is running out of storage.
Terminal
df -h
Expected OutputExpected
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 20G 28G 42% / tmpfs 1.9G 0 1.9G 0% /dev/shm
-h - Show sizes in human-readable format (e.g., GB, MB)
Restarts the nginx web server service. Useful after configuration changes or to fix issues without rebooting the server.
Terminal
sudo systemctl restart nginx
Expected OutputExpected
No output (command runs silently)
restart - Stop and start the service to apply changes
Shows the last 10 log entries for the nginx service without paging. Helps you quickly check recent errors or status messages.
Terminal
journalctl -u nginx -n 10 --no-pager
Expected OutputExpected
Jun 10 10:10:00 my-server systemd[1]: Starting A high performance web server and a reverse proxy server... Jun 10 10:10:01 my-server systemd[1]: Started A high performance web server and a reverse proxy server. Jun 10 10:15:00 my-server nginx[1234]: 2024/06/10 10:15:00 [notice] 1234#0: signal process started
-u nginx - Show logs for the nginx service
-n 10 - Show last 10 log lines
--no-pager - Show output directly without paging
Key Concept

If you remember nothing else from this pattern, remember: sysadmin commands help you check server health, fix problems fast, and keep services running smoothly.

Common Mistakes
Running commands without sudo when root access is needed
Commands like restarting services or viewing some logs require root permissions and will fail without sudo.
Use sudo before commands that need higher privileges, like 'sudo systemctl restart nginx'.
Ignoring disk space warnings from df command
If disk space runs out, servers can crash or stop working properly.
Regularly check disk space with 'df -h' and clean up or add storage before it fills up.
Not checking logs after restarting services
If a service fails to start, you won't know why without checking logs.
Always check recent logs with 'journalctl -u servicename -n 10' after restarting.
Summary
Use uptime and top to monitor server load and resource use.
Check disk space with df -h to avoid storage problems.
Restart services safely with systemctl and verify with logs.