Skip to content

Managing Services and Processes on a Linux Server

A practical guide to managing services and processes on a Linux VPS: understanding systemd and service states (active/inactive/failed), systemctl commands (start/stop/restart/enable/status), reading logs with journalctl, monitoring processes with ps, top and htop, ending processes with kill, priorities with nice, custom systemd units, and scheduling with cron and systemd timers, with commands and tables.

VPSيوسف الحربي30 min read
Illustration of a terminal beside a list of services with status lights and toggles, representing managing Linux services
On this page

Once you have finished setting up your first VPS from scratch and secured your login with SSH basics for beginners, the real stage begins: running software and keeping it alive. A server is no use to you as a silent box; its value lies in the services it provides: a website that works, a database that responds, a job that runs on schedule. This guide takes you from the basic concepts to writing a custom systemd unit and scheduling jobs, step by step and with real commands you can copy.

The difference between a service and a process

Before any command, we need to clear up a common confusion. A process is any program being executed at a given moment; it has a unique identifier called a PID, an owner (a user), memory and a share of the CPU. When you type a command in the terminal, the system creates a process to run it, and it may finish after a few seconds or keep running for days.

A service, sometimes called a daemon, is a program designed to run permanently in the background without direct intervention from you, and it usually starts automatically when the system boots. The Nginx server is a service, the MySQL database is a service, and the SSH server itself (sshd) is a service. At its core, a service is a process (or a group of processes), but the system manages it on your behalf: it starts it, monitors it and restarts it if it crashes.

The relationship between them is hierarchical: when you start the Nginx service, systemd creates a master process that may spawn worker processes. Managing the service means managing its high-level lifecycle (start/stop/enable), while managing a process means dealing with one specific running instance (monitoring it, ending it or lowering its priority).

ConceptDefinitionHow you handle itExample
ProcessA program being executed, with a PIDps, top, killA tar command compressing a file right now
Service (daemon)A permanent background process managed by the systemsystemctl, journalctlNginx, MySQL, sshd
Unitsystemd's definition of a manageable resource.service and .timer filesnginx.service
SignalA short message sent to a process to direct itkill, pkillSIGTERM, SIGKILL

Grasping this distinction saves you costly mistakes. For example, "killing" a running Nginx process with kill may cause systemd to restart it immediately (because its job is to keep it alive), whereas the right way to actually stop it is through the service with systemctl stop.

What systemd is and why it dominates Linux

systemd is the first process that runs when a modern Linux system boots; it always has PID 1 and is the "parent" of all other processes. Its core job is to be the init system: it decides what runs, in what order, and how it is managed throughout the server's life. systemd replaced the old SysVinit system in most major distributions from around 2015, and today it is the de facto standard on Ubuntu, Debian, CentOS, AlmaLinux, Rocky Linux, Fedora and openSUSE.

It dominates because it is more than just a boot loader: it is an integrated framework for managing resources. It handles everything through a unified concept called a unit, which is a text file that describes a manageable resource. There are many unit types, but the most important ones for day-to-day operators are:

Unit typeExtensionPurpose
service.serviceA service or daemon (the most commonly used)
socket.socketA network port or socket that activates a service on demand
timer.timerSchedules a unit to run (a modern alternative to cron)
target.targetA group of units representing a system state (such as multi-user)
mount.mountA file system mount point
path.pathRuns a unit when a file/folder changes

The systemd features that matter to you directly: starting services in parallel (faster boot), automatic restarts of crashed services, unified central logging through journald, and precise dependency management (the database service doesn't start before the network is ready). Every command you type with systemctl is really a conversation with this central manager.

A note on old distributions: some very old systems or stripped-down containers may not use systemd (they rely on OpenRC or SysVinit). But any modern commercial VPS on Ubuntu 20.04+, Debian 11+ or AlmaLinux 8+ comes with systemd by default, which is what we assume throughout this guide.

Service states and the systemctl status command

Every service in systemd is in a specific state at any moment. Understanding these states is the starting point of any diagnosis, because the first question is always: "Is the service even running?" The command that answers it is systemctl status:

bash
systemctl status nginx

It shows you rich output: the first line carries the overall state (such as active (running)), followed by whether the service is enabled at boot, when it started, the main process ID (Main PID), memory usage and the last few lines of its log. This output alone is often enough to diagnose 80% of problems.

The states you will see in the Active field:

StateMeaningWhat to do
active (running)The service is running normally right nowNothing; everything is fine
active (exited)Ran once and finished successfully (a one-time job)Normal for setup services
active (waiting)Running but waiting for an event (a socket, for example)Normal
inactive (dead)Stopped, not runningStart it if you need it
failedTried to run but crashed or exited with an errorRead the log immediately
activatingCurrently starting upWait a moment, then check
deactivatingCurrently stoppingWait for the stop to complete

The most important distinction here is between inactive and failed. The first means the service is quietly stopped (perhaps because you stopped it or it never started), while failed means it tried to run and failed, which is a red flag that calls for reading the log. Don't confuse a service being "enabled" with it being "active": enabling means it will start automatically at the next boot, but it doesn't start it now. A service can be enabled and inactive at the same time (enabled, but the system hasn't been rebooted yet, or you stopped it manually).

Linux service states and managing them with systemdsystemctl enableStarts automatically at bootRunning (active)The service is running nowStopped (inactive)Not runningFailedStopped with an errorsystemctl startsystemctl stopCrashstatus: state · start/stop/restart: control · enable: boot · journalctl: log
systemd service states: stopped ↔ active via start/stop, a crash moves it to failed; enable makes it start automatically at boot, and status/journalctl are for inspection and logs.

A service's lifecycle moves between these states through systemctl commands: from inactive to active with start, and back with stop, and from active to active (a restart) with restart. If it crashes while running, it moves to failed, and from there it goes back to active with restart after you fix the cause, or with reset-failed to clear the failure flag without starting it.

Essential systemctl commands

systemctl is your Swiss Army knife for managing services. Learning a handful of its commands is enough to run a whole server. Here is the reference you will keep coming back to:

CommandWhat it does
systemctl start nginxStarts the service now (doesn't affect boot)
systemctl stop nginxStops the service now
systemctl restart nginxStops it, then starts it (to apply fundamental changes)
systemctl reload nginxRe-reads the configuration without stopping (doesn't cut connections)
systemctl reload-or-restart nginxReloads if possible, otherwise restarts
systemctl status nginxShows its detailed status and the latest log lines
systemctl enable nginxMakes it start automatically at boot
systemctl disable nginxCancels its automatic start at boot
systemctl enable --now nginxEnables it and starts it now in one command
systemctl disable --now nginxDisables it and stops it now in one command
systemctl is-active nginxPrints only active or inactive (useful in scripts)
systemctl is-enabled nginxPrints enabled or disabled
systemctl mask nginxPrevents it from running at all, even manually (a strict lock)
systemctl unmask nginxLifts the lock
systemctl daemon-reloadRe-reads unit files after editing them

The difference between restart and reload deserves a pause, because it is the most misunderstood. restart kills the process completely and starts from scratch, which cuts all ongoing connections for a few seconds. reload sends a signal to the service to re-read its configuration file without stopping, so the current connections stay alive. The practical rule: for simple configuration changes (such as adding a new site in Nginx), use reload; for upgrading the program itself or fundamental changes, use restart. But note: not all services support reload, which is why reload-or-restart exists to choose the right one automatically.

To see all services and their states at once:

bash
systemctl list-units --type=service

And to see only the services enabled at boot:

bash
systemctl list-unit-files --type=service --state=enabled

And to show only the failed services, the first thing I check when there is any problem:

bash
systemctl --failed

Enabling at boot: the crucial difference

A point where beginners often go wrong: starting a service with start doesn't make it start after a reboot. If you reboot the server, you'll find your site down because you forgot enable. The golden rule for any production service: always use enable --now to make sure it runs now and will run after every boot:

bash
systemctl enable --now nginx

The reverse is also true: a service you don't need should be disabled with disable --now to free up resources and prevent it from starting at boot. But be careful about disabling services whose function you don't know: disabling a vital system service (such as the network service or log management) can make your server unreachable after the next boot. The rule: don't disable what you don't understand.

Reading logs with journalctl

When a service fails, the very next question is "why?", and the answer is always in the logs. In the systemd world, all service logs are collected in a central logging system called journald and read with the journalctl command. This is one of the most powerful diagnostic tools, and mastering it saves hours of searching.

The simplest use is to read a specific service's log with the -u (unit) option:

bash
journalctl -u nginx

But the log can be huge. What is most useful in practice is following the log live while the problem is happening, by adding -f (follow), just like watching a constantly updating event feed:

bash
journalctl -u nginx -f

Leave this command running in one window, then restart the service or send a request to the site in another window, and watch the errors appear in real time. This is the fastest way to link a particular action to the error it causes.

A reference of the most important journalctl options:

OptionWhat it does
-u nginxLimits the log to a specific unit
-fFollows the log live (live tail)
-bThe current boot's log only
-b -1The previous boot's log
-p errErrors only (priority = error and above)
-n 50Only the last 50 lines
--since "1 hour ago"Since an hour ago
--since todaySince the start of the day
--since "2026-06-13 09:00"Since a specific time
-rReverse order (newest first)
-kKernel messages only, like dmesg
--no-pagerNo pager, for copying and scripts
--disk-usageDisk size of the logs

Common practical examples. To see all errors since the last boot, the first thing I check when the system behaves strangely:

bash
journalctl -p err -b

And to check what happened to a service in the last hour only, so you focus on the period that matters:

bash
journalctl -u mysql --since "1 hour ago"

The priority levels in -p go from most to least severe: emerg, then alert, crit, err, warning, notice, info and debug. When you write -p err, you are asking for everything at the err level or more severe.

Managing log size

journald keeps logs on disk, and over time they can grow until they eat up a considerable amount of space on a VPS with limited storage. To check the current size:

bash
journalctl --disk-usage

And to shrink them, for example keeping only the last 200 megabytes or deleting anything older than two weeks:

bash
sudo journalctl --vacuum-size=200M
sudo journalctl --vacuum-time=2weeks

For a permanent setting, edit /etc/systemd/journald.conf and set SystemMaxUse=200M, then restart the journald service. This is a small step, but it saves you from the disk suddenly filling up, a common cause of failure on servers that weren't monitored well. Systematically monitoring disk space is an essential part of monitoring a VPS.

Monitoring processes: ps, top, htop and free

We now move from services (the high level) to processes (the low level). When your server slows down or uses up all its memory, you need to see what is actually happening: which process is devouring the CPU or memory? This is where the monitoring tools come in.

The snapshot tool: ps

ps takes an instant "snapshot" of the running processes. The most commonly used form is ps aux, which shows all processes for all users:

bash
ps aux

The important output columns: USER (the owner), PID (the identifier), %CPU and %MEM (usage percentages), STAT (the process state) and COMMAND (the full command). The real power of ps shows up with sorting. To find the ten processes using the most memory, a very common question when RAM runs out:

bash
ps aux --sort=-%mem | head

And for the CPU instead of memory, switch the key to -%cpu:

bash
ps aux --sort=-%cpu | head

The minus sign before %mem means descending order (largest first), and head keeps only the top ten. These two commands are among the ones you will repeat most in practice.

The live tool: top

While ps is a static snapshot, top is a dashboard that refreshes every two seconds, showing the system as it breathes:

bash
top

The top line shows the load average (we explain it shortly), followed by a summary of memory and CPU, then the list of processes, sorted by default by CPU usage. Inside top you can press M to sort by memory, P for CPU, k to send a kill signal to a process, and q to quit. It comes preinstalled on almost every distribution, so there are no extra dependencies.

The favorite tool: htop

htop is top with a much nicer and easier interface: colors, usage bars for each CPU core, horizontal and vertical scrolling with the arrow keys, and ending processes at the press of a key without noting the PID. It isn't always preinstalled, so install it first:

bash
sudo apt install htop   # On Ubuntu/Debian
sudo dnf install htop   # On AlmaLinux/CentOS/RHEL
htop

Inside htop: the arrow keys move between processes, F6 sorts by a column, F9 sends a signal (kill), F5 shows a tree view of the parent-child relationships between processes, and F10 or q quits. For most users, htop is the favorite day-to-day tool for monitoring resources visually.

Memory: free

To see the memory state alone clearly, use free with -h (human-readable) to show the numbers in readable units:

bash
free -h

You will see the columns total (total memory), used, free and available (actually available to new applications). An important point that often confuses beginners: don't panic if you see a very low free. Linux uses spare memory as a cache to speed up the disk, but it releases it immediately when needed. The column that really matters to you is available, not free.

ToolTypeStrengthWhen to use it
psStatic snapshotFast, sortable and scriptableA quick query or inside a script
topLive, refreshingInstalled everywhere, no dependenciesQuick monitoring when htop isn't available
htopLive, interactiveColors, tree view, easy killingDay-to-day visual monitoring
freeA memory snapshotFocused on RAM and swapChecking memory pressure
VPS monitoring: metrics and alertsVPS serverCollected fromMonitored metricsCPUMemory (RAM)DiskNetworkLoadUptimeDashboard + alertsWhen thresholds are exceededWatch the trends and set threshold alerts, so you act before the site goes down
VPS monitoring: metrics (CPU, RAM, disk, network, load, availability) are collected from the server into a dashboard, with alerts fired when thresholds are exceeded.

Understanding load average

At the top of the output of top, htop and uptime, you will find three numbers such as 0.52, 0.43, 0.38. This is the load average: the average number of processes waiting for the CPU (or using it) over the last minute, five minutes and fifteen minutes, respectively. Reading it is simple but crucial: compare the number with the number of CPU cores.

If your server has one core, a load of 1.0 means the CPU is 100% busy with nothing waiting (the ideal limit). Above 1.0 means processes are waiting their turn (congestion). If you have 4 cores, a load of 4.0 is the full limit, and 2.0 means half capacity. To find the number of cores:

bash
nproc

The practical rule: a load average below the number of cores = healthy; equal to it = at the limit; persistently above it = the server is loaded beyond its capacity and needs optimization or an upgrade. Looking at the three numbers together reveals the trend: if the first number (one minute) is much higher than the third (15 minutes), the load is rising now; the reverse means a passing peak is subsiding.

Ending processes and signals

Sometimes a process freezes or consumes resources wildly, and you need to end it. In Linux we don't "kill" processes in the crude sense; we send them signals, short messages that ask them for a particular behavior. The main tool is kill, and its name is a little misleading, because it actually sends any signal, not just a kill.

The most important signals you will use:

SignalNumberMeaningBehavior
SIGTERM15Polite termination (the default)Asks the process to shut down cleanly
SIGKILL9Immediate forced killEnds it immediately without cleanup
SIGHUP1Re-read the configurationUsually reloads the settings
SIGINT2InterruptEquivalent to Ctrl+C in the terminal
SIGSTOP19PauseFreezes the process (cannot be ignored)
SIGCONT18ResumeContinues a process paused with SIGSTOP

The golden rule: always start with SIGTERM. The kill command without an option sends SIGTERM by default, which asks the process to close itself cleanly: it saves its files, closes its connections and then exits:

bash
kill 1234

If the process is completely frozen and doesn't respond to SIGTERM, only then do you resort to SIGKILL (number 9), a forced termination that the process can neither ignore nor respond to gracefully:

bash
kill -9 1234

A common, dangerous mistake: rushing to kill -9 as if it were the default solution. SIGKILL gives the process no chance to save its data or close its files, and it can leave corrupted temporary files or a database in an inconsistent state. Use it only as a last resort after SIGTERM fails, and wait a few seconds between the two attempts to give the process a chance to respond.

Killing by name: killall and pkill

Sometimes you don't know the PID but you know the program's name. killall ends all processes with the exact full name, and pkill is more flexible because it accepts partial patterns:

bash
killall firefox          # Ends all processes named exactly firefox
pkill -f "python script"  # Ends any process whose command line matches the pattern
pkill -u www-data         # Ends all processes of the www-data user

The -f option in pkill matches the full command line, not just the name, which is useful for Python or Node processes that all carry the generic name python or node. But be very careful here: a loose pattern in pkill can end processes you didn't intend. The preventive rule: use pgrep first (the same syntax as pkill, but it only prints the matches without killing) to make sure you are targeting what you want:

bash
pgrep -fa "python script"   # Shows what will be killed before you kill it

Remember the most important warning from the start of this guide: if the process belongs to a managed systemd service (such as Nginx), killing it with kill is usually pointless because systemd will restart it. The right way is systemctl stop, not chasing the PID.

Priorities: nice and renice

Not all processes are equally important. A heavy backup process should not slow down the web server serving your visitors. This is where the concept of priority (niceness) comes in: a value that tells the kernel scheduler how "nice" a process is toward others when sharing the CPU.

The niceness value ranges from -20 (highest priority, selfish) to +19 (lowest priority, generous), and the default is 0. The naming logic is inverted and can be confusing: the higher the value (the "nicer" the process), the lower the priority, because the process "yields" the CPU to others.

nice valuePriorityPractical meaning
-20HighestHogs the CPU; rarely used
-10HighFor time-sensitive tasks
0NormalThe default for all processes
+10LowFor non-urgent background tasks
+19LowestRuns only when nobody else wants the CPU

To start a process with low priority from the beginning, use nice (negative values require root privileges):

bash
nice -n 15 tar -czf backup.tar.gz /var/www

This runs the backup command at priority +15, so it doesn't compete with important services and runs quietly in the background. To change the priority of a process that is already running, use renice with the PID:

bash
renice -n 10 -p 1234

Or for all processes of a particular user at once:

bash
sudo renice -n 10 -u backupuser

An expert tip: lowering the priority (nice) of heavy recurring tasks, such as backups, log compression and virus scans, is an excellent habit that keeps your server responsive under pressure. Conversely, raising priority (negative values) is rarely the right fix; it is usually better to address the cause of the slowness or upgrade resources rather than forcing the kernel to favor one process at the expense of the rest. To secure the server under load, also see the practices in VPS security hardening to stop malicious processes from draining resources in the first place.

Writing a custom systemd unit

So far we have managed ready-made services. But the real power of systemd shows when you turn your own application into a managed service: it starts automatically, restarts on a crash and logs to journald. This is far cleaner than running the application with nohup or screen and leaving it to chance.

Suppose you have a Node.js application listening on a port. Create a unit file in /etc/systemd/system/:

bash
sudo nano /etc/systemd/system/myapp.service

And put the following definition in it:

ini
[Unit]
Description=My Node.js Application
After=network.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/myapp
ExecStart=/usr/bin/node /var/www/myapp/server.js
Restart=on-failure
RestartSec=5
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

Let's break this file down, because every line is deliberate:

  • [Unit] describes the unit and its relationships. Description is text shown in status. After=network.target makes sure your service doesn't start before the network is ready.
  • [Service] is the heart of the definition. Type=simple means ExecStart is the main process directly. User sets the user the service runs as (don't run it as root unless necessary: the principle of least privilege). WorkingDirectory is the working folder. ExecStart is the full command with absolute paths. Restart=on-failure makes systemd restart it automatically if it crashes, and RestartSec=5 waits 5 seconds between attempts. Environment passes environment variables.
  • [Install] specifies when it is activated on enable. WantedBy=multi-user.target means it starts in the normal multi-user operating mode.

After creating or editing the file, you must tell systemd to re-read the units, then enable and start the service:

bash
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
sudo systemctl status myapp

A very common mistake: forgetting daemon-reload after editing the unit file. systemd stores a copy of the definition in memory, so it won't see your changes until you force it to re-read. If you edited the file and the change seems not to have been applied, the first thing to check is whether you ran daemon-reload. Another mistake is relative paths in ExecStart; systemd doesn't assume a working directory, so always use full absolute paths for the program and its files.

The Restart values are worth knowing: no (no restart), on-failure (only on exiting with an error, the most common), always (always, even on a normal exit) and on-abnormal (on a crash or being killed by a signal). For most web applications, on-failure is the balanced choice.

Scheduling: cron vs. systemd timers

Many server tasks are recurring: a nightly backup, cleaning up temporary files, renewing SSL certificates. There are two ways to schedule them: the classic cron and the modern systemd timers.

Classic cron

cron is a scheduling service that has existed for decades, simple and reliable. You edit your job table with:

bash
crontab -e

Each job line consists of five time fields followed by the command. The five fields, in order:

FieldRangeMeaning
First0-59Minute
Second0-23Hour
Third1-31Day of month
Fourth1-12Month
Fifth0-7Day of week (0 and 7 = Sunday)

The * symbol means "every value." An example that runs a backup script every day at 3:30 a.m.:

bash
30 3 * * * /usr/local/bin/backup.sh

Other common pattern examples: */15 * * * * every 15 minutes, 0 * * * * every hour on the hour, 0 0 * * 0 every Sunday at midnight, 0 2 1 * * on the first of every month at 2 a.m. A practical tip: redirect the script's output to a log file (>> /var/log/backup.log 2>&1), because cron runs silently, and without this you won't know whether the job failed.

Modern systemd timers

The modern alternative is timers, which are systemd units that run a service at specific times. You need two files: a service (.service) describing what runs, and a timer (.timer) describing when. First create /etc/systemd/system/backup.service:

ini
[Unit]
Description=Daily Backup Job

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh

Then the timer /etc/systemd/system/backup.timer:

ini
[Unit]
Description=Run backup daily at 3:30 AM

[Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true

[Install]
WantedBy=timers.target

OnCalendar sets the schedule in systemd's time syntax (here: every day at 3:30 a.m.). Persistent=true is a powerful feature: if the server is off at the scheduled time, the job runs as soon as it next boots instead of being missed, which cron doesn't do. Enable the timer (note that you enable the .timer, not the .service):

bash
sudo systemctl daemon-reload
sudo systemctl enable --now backup.timer
systemctl list-timers

The list-timers command shows all timers and when they will next run, an excellent tracking dashboard. When should you choose which? The comparison:

Criterioncronsystemd timer
SimplicitySimpler, one lineMore complex, two files
Missed jobsMissed if the server is offRun later with Persistent
LoggingManual, to a fileAutomatic, in journald
DependenciesNot supportedSupports After/Requires
MonitoringNo unified toollist-timers and status
AvailabilityEverywhereRequires systemd

The practical rule: for a simple, quick job, cron is enough and familiar. For an important job that needs reliable logging, must not be missed or depends on other services, choose a systemd timer. Both are valid; choose according to importance and complexity.

Diagnosing a failed service: a practical method

Let's bring everything together in a real-world scenario. You visit your site and find it down. Here is an organized, step-by-step method instead of floundering.

Step 1: Check the status. Always start with status to know where you stand:

bash
systemctl status nginx

If you see failed, go straight to the log. Step 2: Read the cause. The last lines of status give hints, but the full log tells the whole story:

bash
journalctl -u nginx -n 50 --no-pager

Look for words such as error, failed, permission denied or address already in use. These point directly to the cause: a configuration error, a missing permission, or a port taken by another process.

Step 3: Check the configuration before restarting. Many services provide a configuration test. Nginx, for example:

bash
sudo nginx -t

If it reports an error on a particular line, fix it before any attempt to start: restarting a service with a broken configuration will not succeed.

Step 4: Look for port conflicts. If the error is "address already in use," find out what is occupying the port:

bash
sudo ss -tlnp | grep :80

Step 5: Restart and watch. After the fix, restart and follow the log live to confirm that it starts successfully this time:

bash
sudo systemctl restart nginx
journalctl -u nginx -f

If it returns to active (running) and stays stable for a few seconds, you have succeeded. If it keeps entering a fail-and-restart loop, the cause hasn't been fixed yet, and you need to go back to the log in more depth. This method (status, log, configuration, port, restart while watching) solves the vast majority of service failures.

Frequently asked questions

What is the difference between systemctl restart and reload? restart stops the service completely and then starts it again, cutting ongoing connections for a few seconds and applying any change, however fundamental. reload asks the service to re-read its configuration file without stopping, so connections stay alive, but it only suits configuration changes that support hot reloading. The rule: reload for simple changes, restart for upgrades and fundamental changes.

My service runs, but it doesn't start after a reboot. Why? Because you only started it with systemctl start, and that doesn't make it permanent. start runs it in the current session only, while enable is what adds it to the list of services that start automatically at boot. The fix: run systemctl enable --now nginx to make sure it runs now and after every boot.

When should I use kill -9, and when should I avoid it? Use it only as a last resort. Always start with a regular kill (which sends SIGTERM), which asks the process to shut down cleanly and save its data. If it stays frozen and doesn't respond after a few seconds, only then use kill -9 (SIGKILL), which ends it forcibly. Overusing -9 can corrupt files or leave databases in an inconsistent state, because it gives the process no chance to clean up.

How do I find the process that is eating all the memory? Use ps aux --sort=-%mem | head to see the top ten memory-consuming processes instantly, or open htop and press F6 to sort by the MEM column. Remember that the column that matters in free -h is available, not free, because Linux uses spare memory as a cache that it releases when needed.

I edited a systemd unit file and nothing changed. Why? Because you didn't run sudo systemctl daemon-reload after the edit. systemd keeps a copy of the unit definition in memory, so it doesn't see your changes to the file until you force it to re-read the units. After daemon-reload, run systemctl restart for the service to actually apply the new definition to the running instance.

What does load average mean, and how do I know my server is overloaded? It is the average number of processes using or waiting for the CPU over the last one, five and fifteen minutes. Compare it with the number of cores (which you get with nproc): if it is lower than the number of cores, the server is healthy; if it is persistently higher, the server is loaded beyond its capacity and you need to optimize performance or upgrade resources. Comparing the three numbers shows whether the load is rising or falling.

What is the difference between cron and a systemd timer, and which should I choose? cron is simpler (one line), familiar and available everywhere, but it misses jobs if the server is off at the scheduled time and doesn't log automatically. A systemd timer is more complex (it needs two files), but it logs to journald, supports running missed jobs through Persistent=true, and integrates with service dependencies. Choose cron for simple jobs, and a timer for critical jobs that must not be missed or that need reliable tracking.

How do I stop a system service properly instead of killing its processes? Don't chase the PID with kill, because systemd will restart the service immediately, since its job is to keep it alive. The right way is systemctl stop nginx to stop it temporarily, or systemctl disable --now nginx to stop it and prevent it from starting at boot. To prevent it from running at all, even manually, use systemctl mask, and unmask to lift the lock.

Frequently asked questions

What is the difference between systemctl restart and reload?

restart stops the service completely and then starts it again, cutting ongoing connections for a few seconds and applying any change, however fundamental. reload asks the service to re-read its configuration file without stopping, so connections stay alive, but it only suits configuration changes that support hot reloading. The rule: reload for simple changes, restart for upgrades and fundamental changes.

My service runs, but it doesn't start after a reboot. Why?

Because you only started it with systemctl start, and that doesn't make it permanent. start runs it in the current session only, while enable is what adds it to the list of services that start automatically at boot. The fix: run systemctl enable --now nginx to make sure it runs now and after every boot.

When should I use kill -9, and when should I avoid it?

Use it only as a last resort. Always start with a regular kill (which sends SIGTERM), which asks the process to shut down cleanly and save its data. If it stays frozen and doesn't respond after a few seconds, only then use kill -9 (SIGKILL), which ends it forcibly. Overusing -9 can corrupt files or leave databases in an inconsistent state, because it gives the process no chance to clean up.

How do I find the process that is eating all the memory?

Use ps aux --sort=-%mem | head to see the top ten memory-consuming processes instantly, or open htop and press F6 to sort by the MEM column. Remember that the column that matters in free -h is available, not free, because Linux uses spare memory as a cache that it releases when needed.

I edited a systemd unit file and nothing changed. Why?

Because you didn't run sudo systemctl daemon-reload after the edit. systemd keeps a copy of the unit definition in memory, so it doesn't see your changes to the file until you force it to re-read the units. After daemon-reload, run systemctl restart for the service to actually apply the new definition to the running instance.

What does load average mean, and how do I know my server is overloaded?

It is the average number of processes using or waiting for the CPU over the last one, five and fifteen minutes. Compare it with the number of cores (which you get with nproc): if it is lower than the number of cores, the server is healthy; if it is persistently higher, the server is loaded beyond its capacity and you need to optimize performance or upgrade resources. Comparing the three numbers shows whether the load is rising or falling.

What is the difference between cron and a systemd timer, and which should I choose?

cron is simpler (one line), familiar and available everywhere, but it misses jobs if the server is off at the scheduled time and doesn't log automatically. A systemd timer is more complex (it needs two files), but it logs to journald, supports running missed jobs through Persistent=true, and integrates with service dependencies. Choose cron for simple jobs, and a timer for critical jobs that must not be missed or that need reliable tracking.

How do I stop a system service properly instead of killing its processes?

Don't chase the PID with kill, because systemd will restart the service immediately, since its job is to keep it alive. The right way is systemctl stop nginx to stop it temporarily, or systemctl disable --now nginx to stop it and prevent it from starting at boot. To prevent it from running at all, even manually, use systemctl mask, and unmask to lift the lock.