A program is a file. When the program runs, it becomes a process. A process is a program that is running now.
/usr/bin/basha file
run
bash processPID 1201
/usr/bin/bashthe same file
run again
another bash processPID 1544
The PID
The computer gives each process a number, its process ID, or PID. Two processes that run at the same time never have the same PID.
When a process ends, its PID is free again.
ps: list processes
ps lists the processes of your terminal:
text
learner@tidepool:~$ ps
PID TTY TIME CMD
1201 pts/0 00:00:00 bash
1305 pts/0 00:00:00 ps| Column | Means |
|---|---|
PID | The process ID |
TTY | The terminal of the process. pts/0 is your terminal. ? means no terminal |
TIME | How much processor time it used |
CMD | The program |
Two processes: your shell, bash, and ps itself. Run ps again, and ps has a new PID. It is a new process.
ps -e: every process
Many processes run with no terminal. They start when the computer starts and do their work in the background. ps -e lists every process:
text
learner@tidepool:~$ ps -e
PID TTY TIME CMD
1 ? 00:00:00 systemd
412 ? 00:00:00 cron
530 ? 00:00:00 sshd
1201 pts/0 00:00:00 bash
1306 pts/0 00:00:00 psUse a pipe to find one program: ps -e | grep cron.