AI Hints
Home›Linux Tutorial›Processes
Linux · Lesson 79 of 120

Processes

Programs that are running.

⏱ 2 min read▶ Video at 1:44:53🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

A program sitting on the disk is just a file. When you run it, Linux loads it into memory, and it becomes a process. At any moment, a Linux computer is running dozens, or even hundreds, of processes.

Processes
From the video: Processes
  • A program on disk is a file
  • Running, it's a process
  • Dozens run at once

What every process has

Every process gets a number, called its process ID, or PID. It belongs to a user, which decides what it's allowed to touch. It has a parent, the process that started it. And it uses some of the computer's processor and memory.

PIDits unique number
Userwhose permissions it has
Parentwho started it
CPU and memorywhat it uses

Your processes

PS shows processes. On its own, it shows the ones started from this terminal. Bash, your shell, a backup script, two sleeps, and PS itself. Dash EF shows every process on the system, with the user, the PID, the parent's PID, and the command. Our computer is very quiet. A normal desktop would show hundreds of lines here.

Terminal
ps
  PID TTY          TIME CMD
    1 ?        00:00:00 bash
   21 ?        00:00:00 backup.sh
   23 ?        00:00:00 sleep
   27 ?        00:00:00 sleep
   36 ?        00:00:00 ps
ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
sam          1     0 11 09:00 ?        00:00:00 bash -s
sam         21     1  0 09:00 ?        00:00:00 /bin/bash ./backup.sh
sam         23     1  0 09:00 ?        00:00:00 sleep 5000
sam         27    21  0 09:00 ?        00:00:00 sleep 5
sam         47     1  0 09:00 ?        00:00:00 ps -ef

Where processes come from

Every process is started by another one. When you type a command, your shell starts it as a child process, waits for it to finish, and then shows the prompt again. Follow the parents all the way up, and you reach process one, the very first process, started when the computer boots.

keyvalue
Your commanda child of bash
basha child of the terminal
PID 1the first process
pstreedraws the family tree

Summary

A running program is a process, with a PID, a user, and a parent. PS shows your processes, and PS dash EF shows them all. Next, watching processes live.

Key takeaways
  • Process = running program
  • PID
  • ps, ps -ef
Next up: Watching Processes — top and ps aux