linux proces - ghdrako/doc_snipets GitHub Wiki

The daemon systemd process starts during boot time, and remains active until the shutdown. It's the parent process for all other process in the system.

Each process contains several main parts, such as: PID, state, virtual space address (memory), threads, network and file descriptors, scheduler information, and links. Processes are controlled and respond to signals. The states that a process can transition among are depicted below:

process-states

To observe the states and other information of the processes interactively, use the top command.

To run executables as background process (job), append an ampersand to it:

$ echo "Hi .. looping:" | sleep 10000 | echo "done." &

To view the current jobs, and their details run job, ps j commands respectively.

To bring back a job in the foreground in the current session, and send it back use the following:

$ fg %<job-no>
$ ctrl+z
$ bg %<job-no>

Use the command kill -l to see the available signals to send to processes, like interrupt, terminate, resume, etc.

$ kill -l
$ kill -9 5921
$ kill -SIGTERM 6152

Use killall to operate on multiple processes using their executable name. Use pkill for filtering with more options.

$ killall -15 nginx
$ pkill -U tester

Finally, use pstree and pgrep to view process parent/child tree and search for processes by pattern.

$ psgrep -u abdullah -l
⚠️ **GitHub.com Fallback** ⚠️