https://cs.nyu.edu/~gottlieb/courses/2000s/2000-01-spring/os/chapters/chapter-2.html
https://unix.bpowers.net/ https://browsix.org/ https://win95.ajf.me/
https://jvns.ca/blog/2016/06/13/should-you-be-scared-of-signals/
https://dlang.org/blog/2020/01/28/wc-in-d-712-characters-without-a-single-branch/ https://chrispenner.ca/posts/wc
https://kukuruku.co/post/processes-paralleling-to-speed-up-computing-and-tasks-execution-in-linux/
https://idea.popcount.org/2012-12-11-linux-process-states/ https://homepages.uc.edu/~thomam/Intro_Unix_Text/Process2.html https://tldp.org/LDP/intro-linux/html/sect_04_01.html#sect_04_01_02
How work gets organized, directed and communicated about
Marek Šuppa
Ondrej Jariabka
Adrián Matejov
https://cs.nyu.edu/~gottlieb/courses/2000s/2000-01-spring/os/chapters/chapter-2.html
https://unix.bpowers.net/ https://browsix.org/ https://win95.ajf.me/
https://jvns.ca/blog/2016/06/13/should-you-be-scared-of-signals/
https://dlang.org/blog/2020/01/28/wc-in-d-712-characters-without-a-single-branch/ https://chrispenner.ca/posts/wc
https://kukuruku.co/post/processes-paralleling-to-speed-up-computing-and-tasks-execution-in-linux/
https://idea.popcount.org/2012-12-11-linux-process-states/ https://homepages.uc.edu/~thomam/Intro_Unix_Text/Process2.html https://tldp.org/LDP/intro-linux/html/sect_04_01.html#sect_04_01_02
There is a very good chance you'll work with significant data loads
Often times larger than the RAM available on your boxes
There is a very good chance you'll work with significant data loads
Often times larger than the RAM available on your boxes
Being able to understand, control and especially stop what is going (i.e. the process) on will be critical
There is a very good chance you'll work with significant data loads
Often times larger than the RAM available on your boxes
Being able to understand, control and especially stop what is going (i.e. the process) on will be critical
batch operating systems
single-process operating systems
batch operating systems
single-process operating systems
multi-process/time-sharing operating systems
identified by a unique Process ID (PID)
and a ton of attributes:
PPID - the PID of its parent processSTIME)TTY)TIME)CMD)R: running or runnable (on run queue)D: uninterruptible sleepS: interruptible sleep (waiting for an event to complete)T: stopped by job control signalZ: defunct ("zombie") process, terminated but not reaped by its parent
Image from https://cloudchef.medium.com/linux-process-states-and-signals-a967d18fab64
The best source is probably /proc/<PID>/status
$ cat /proc/1382/status | headName: sshUmask: 0022State: S (sleeping)Tgid: 540038Ngid: 0Pid: 540038PPid: 37564TracerPid: 0Uid: 1000 1000 1000 1000Gid: 1000 1000 1000 1000ps$ ps PID TTY TIME CMD3583901 pts/39 00:00:00 bash3583948 pts/39 00:00:00 ps-e (or -A) lists all processes
-f does full-format listing
$ ps -e -fUID PID PPID C STIME TTY TIME CMDroot 1 0 0 Oct12 ? 00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 34root 2 0 0 Oct12 ? 00:00:00 [kthreadd]root 3 2 0 Oct12 ? 00:00:00 [rcu_gp]root 4 2 0 Oct12 ? 00:00:00 [rcu_par_gp]root 6 2 0 Oct12 ? 00:00:00 [kworker/0:0H-kblockd]root 9 2 0 Oct12 ? 00:00:00 [mm_percpu_wq]root 10 2 0 Oct12 ? 00:00:10 [ksoftirqd/0]root 11 2 0 Oct12 ? 00:02:10 [rcu_sched]root 12 2 0 Oct12 ? 00:00:00 [migration/0][ ... output omitted ... ]mrshu 550723 550241 0 13:32 pts/9 00:00:00 ps -e -f-o lists specific fields, such ascmdpidppidstateuserman page$ ps -o pid,state,cmd PID S CMD 550241 S -fish 551637 S bash 551709 R ps -o pid,state,cmd-H makes ps show the processes in a "tree" view.$ ps -H 47754 pts/13 00:00:00 zsh 47827 pts/13 00:00:00 bash 553122 pts/13 00:00:00 bash 553182 pts/13 00:00:00 ps-H makes ps show the processes in a "tree" view.$ ps -H 47754 pts/13 00:00:00 zsh 47827 pts/13 00:00:00 bash 553122 pts/13 00:00:00 bash 553182 pts/13 00:00:00 psIn the listing above we have zsh which runs bash, which runs bash which
runs ps.
This can also be visualized using the pstree command.
PIDs-p pidlistPIDs are in the comma-separated pidlist$ ps -p 552921,549013,547031 PID TTY TIME CMD 547031 ? 00:00:05 python3 549013 ? 00:00:08 firefox 552921 ? 00:00:00 gnome-calendar-u userlist userlist$ ps -u joe123 PID TTY TIME CMD 138565 pts/4 00:04:23 vimx 138580 ? 00:00:51 python3 138594 ? 00:00:38 python3 138595 ? 00:00:16 python3 138596 ? 00:00:25 python3 138597 ? 00:00:18 python3A way for processes to communicate
Takes place on the kernel level (i.e. it's very fast)
The bandwidth is limited though (you don't send a video this way)
SIGSTOP (19)
SIGCONT (18)SIGHUP (1) -- "signal hang up"
SIGTERM (15)
SIGKILL (9)
SIGSTOP (19)
SIGCONT (18)SIGHUP (1) -- "signal hang up"
SIGTERM (15)
SIGKILL (9)
Except for SIGSTOP and SIGKILL programs can handle these signals in their
own way.
On most Linux distributions, this is done via the kill command.
kill -s signal pidsignal is the name of the signal (like SIGKILL)pid is the PID of the process to send the signal to$ kill -s SIGKILL 3215There is also a shorter version:
$ kill -SIGKILL 3215$ kill -KILL 3215On most Linux distributions, this is done via the kill command.
kill -s signal pidsignal is the name of the signal (like SIGKILL)pid is the PID of the process to send the signal to$ kill -s SIGKILL 3215There is also a shorter version:
$ kill -SIGKILL 3215$ kill -KILL 3215kill -L$ kill -L 1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 6 IOT 7 BUS 8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM 15 TERM 16 STKFLT 17 CHLD 17 CLD 18 CONT 19 STOP 20 TSTP 21 TTIN 22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH 29 IO 29 POLL 30 PWR 31 SYS 34 RTMIN 64 RTMAXOnce again, this is well within the UNIX/Posix philosophy. Shorter yet expressive is better than verbose and redundant, mostly because typing used to be rather expensive.
The standard approach is to first send SIGTERM (15) to a process we want to
terminate
This is done so that the process can finish up cleanly
$ kill -15 3215The standard approach is to first send SIGTERM (15) to a process we want to
terminate
This is done so that the process can finish up cleanly
$ kill -15 3215SIGKILL (9)$ kill -9 3215The standard approach is to first send SIGTERM (15) to a process we want to
terminate
This is done so that the process can finish up cleanly
$ kill -15 3215SIGKILL (9)$ kill -9 3215killall processprocess)SIGTERM by defaultkill$ killall firefoxThe standard approach is to first send SIGTERM (15) to a process we want to
terminate
This is done so that the process can finish up cleanly
$ kill -15 3215SIGKILL (9)$ kill -9 3215killall processprocess)SIGTERM by defaultkill$ killall firefoxAnd if that does not help...
$ killall -9 firefoxIn other words, how to use signals to control processes form Bash
A "normal" process in bash is said to be started in the foreground
Ctrl+C
SIGINT (2) signal (similar to SIGTERM)Ctrl+Z
SIGTSTP (20) signal (similar to SIGSTOP)Let's consider a long-running command like cp movie.mp4 ~/Movies
cp movie.mp4 ~/MoviesCtrl+C will terminate itCtrl+Z will "suspend" the process (it will be stopped)bg will resume its execution in the backgroundfg will resume its execution in the foregroundLet's consider a long-running command like cp movie.mp4 ~/Movies
cp movie.mp4 ~/Movies
Ctrl+C will terminate itCtrl+Z will "suspend" the process (it will be stopped)bg will resume its execution in the backgroundfg will resume its execution in the foregroundcp movie.mp4 ~/Movies &
Ctrl+C won't work on it (it is not in the foreground)fg will bring it to the foregroundjobsjobsfg, bg or kill, e.g. fg %1fg and bg take the first job from the tablejobsjobsfg, bg or kill, e.g. fg %1fg and bg take the first job from the table$ man ps[1]+ Stopped man ps$ eog &[2] 32165$ jobs[1]+ Stopped man ps[2]- Running eog &$ kill -15 %2[2]- Terminated eog$ fgman pswc$ wc /etc/passwd 54 134 3062 /etc/passwd$ wc -l /etc/passwd54 /etc/passwd$ wc -w /etc/passwd134 /etc/passwd$ wc -m /etc/passwd3062 /etc/passwdwc$ wc /etc/passwd 54 134 3062 /etc/passwd$ wc -l /etc/passwd54 /etc/passwd$ wc -w /etc/passwd134 /etc/passwd$ wc -m /etc/passwd3062 /etc/passwdWorks with data piped in from other commands as well:
$ cat /etc/passwd | wc -m3062Keyboard shortcuts
| ↑, ←, Pg Up, k | Go to previous slide |
| ↓, →, Pg Dn, Space, j | Go to next slide |
| Home | Go to first slide |
| End | Go to last slide |
| Number + Return | Go to specific slide |
| b / m / f | Toggle blackout / mirrored / fullscreen mode |
| c | Clone slideshow |
| p | Toggle presenter mode |
| t | Restart the presentation timer |
| ?, h | Toggle this help |
| Esc | Back to slideshow |