Processes and services
Every running program is a process. Servers are mostly long-running processes (web servers, databases, your app) that need to start on boot, restart when they crash and be stopped cleanly, and Linux has tools for each of those jobs.
What a process is
When you run a command, the kernel creates a process: a running copy of that program with its own memory, open files and a unique number called the PID (process ID). Every process is started by another one, its parent, so they form a tree. At the very top is PID 1, which on modern systems is systemd, the program that boots the system and supervises services.
Seeing what is running
$ ps aux # snapshot of every process
$ ps aux | grep nginx # just the nginx ones
$ top # live view, sorted by CPU (q to quit)
$ htop # friendlier live view, if installed
$ free -h # memory used / free
$ uptime # running time + load average
In ps aux the useful columns are USER, PID, %CPU, %MEM and COMMAND. The load average in uptime (three numbers: last 1, 5 and 15 minutes) is roughly how many processes were waiting for CPU. Compare it with the number of CPU cores: a load of 4 on a 4-core machine means it is fully busy.
Stopping processes: signals
You don't really "kill" a process, you send it a signal. kill PID sends SIGTERM (15), a polite request: the program can finish writing files, close connections and exit cleanly. kill -9 PID sends SIGKILL, which the kernel enforces immediately and the program can't catch, so nothing gets cleaned up. Always try the polite one first; use -9 only for something that's stuck. pkill nginx signals processes by name instead of number, and Ctrl+C in a terminal sends SIGINT to whatever is running in the foreground.
Foreground and background
A normal command holds your terminal until it finishes. Add & to run it in the background (./long-task.sh &), see background jobs with jobs and bring one back with fg. Background jobs still die when you close the SSH session; nohup command & keeps them running, but for anything that should stay up permanently you want a service.
Services with systemd
A service (or daemon) is a background program that systemd starts, watches and restarts. Each one is described by a unit file, for example /etc/systemd/system/myapp.service, which says which command to run, as which user, and what to do if it crashes.
$ sudo systemctl status nginx # running? recent log lines?
$ sudo systemctl start nginx # start now
$ sudo systemctl stop nginx # stop now
$ sudo systemctl restart nginx # stop + start (after config changes)
$ sudo systemctl reload nginx # re-read config without dropping connections
$ sudo systemctl enable nginx # start automatically on every boot
$ sudo systemctl disable nginx # don't start on boot
$ journalctl -u nginx -f # that service's logs, live
start and enable are different things: start affects right now, enable affects the next boot. A fresh install usually needs both (systemctl enable --now nginx does both at once).For Node.js apps you'll also meet PM2, a process manager that keeps the app running, restarts it on crash and can register itself with systemd, which is what the Traversy server-setup video uses.
Scheduled jobs with cron
cron runs commands on a schedule. crontab -e opens your list of jobs; each line has five time fields followed by the command:
# minute hour day-of-month month day-of-week command
0 3 * * * /home/demee/backup.sh # every day at 03:00
*/15 * * * * /usr/local/bin/healthcheck # every 15 minutes
0 9 * * 1 /home/demee/report.sh # Mondays at 09:00
* means "every", and */15 means "every 15th". Cron jobs run with a minimal environment, so use full paths in them.