Lesson 10: Processes — ps, top, and kill
Every running program on the server is a 'process', and each process has a unique ID number — its PID. When a process gets stuck, eats too many resources, or holds a port you need, you first want to find it and then stop it. We'll meet ps, which lists the processes (and with the pipe and search we a
A process is like an open app, and each has a number. ps is opening the list of running apps, top is watching them live by how hard they work, and kill is closing one by its number.
- process (PID)
- A program that's currently running. Each process has a unique ID number, the PID, used to refer to it (e.g. to stop it).
- ps
- Lists the processes. ps aux shows them all; combine with a pipe and search to find one: ps aux | grep nginx.
- top
- A live, continuously-updating view of the processes, sorted by CPU use — like a 'task manager'. Quit with q.
- kill
- Stops a process by its PID: kill 4821. Always verify it's the right PID. kill -9 is a forced stop, a last resort.