(Usage hints for this presentation)
IT Systems, Summer Term 2024
Dr. Jens Lechtenbörger (License Information)
(Based on Chapter 7 and Section 8.3 of (Hailperin 2019))
ps
chmod
to modify file permissions
/proc
Figure © 2018 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.
First approximation: Process ≈ program in execution
Recall: Command line as interface to OS to execute processes
Command line can (1) execute builtin commands and (2) create processes for other commands
help
to execute one and see all of themcat
, grep
, less
, man
, ps
Linux kernel offers /proc
(drawing)
(man page
offers details)
Pseudo-filesystem as interface to Linux kernel data structures
Subdirectories per process ID (e.g., /proc/42
) with
details of process control block for process with ID 42
Process listing command ps
inspects /proc
man ps
for implementation-specific details, following
options are for GNU/Linux)
ps -e
shows some details on all processes (IDs, time,
etc.)
-L
adds thread information, option -f
for
“full format”, e.g.: ps -eLf
LWP
shows thread IDs)
ps -C <name>
shows some details on all processes with the
given name
cd clmystery/mystery
head crimescene | grep Alice
crimescene
\(\leadsto\) head
\(\leadsto\) grep
\(\leadsto\) console output
head crimescene > first10lines
grep Alice < first10lines
crimescene
\(\leadsto\) head
\(\leadsto\)
first10lines
\(\leadsto\) grep
\(\leadsto\) console output
OS represents open files via integer numbers called file descriptors
File abstraction includes “real” files, directories, devices, network access, and more
open
, close
, read
, write
POSIX standard describes three descriptors (numbered 0, 1, 2) for every process
“Standard file descriptors” by Jens Lechtenbörger under CC BY-SA 4.0; using UXWing icons: keyboard, monitor, operations; from GitLab
stdin
(e.g., keyboard input)stdout
(e.g., print to screen/terminal)stderr
(e.g., print error message to terminal)
File descriptors
Figure © 2018 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.
Streams of bytes can be redirected
head names.txt > first10names.txt
head
invokes system calls
open
file names.txt
, results in newly allocated file descriptorread
from file descriptor for names.txt
write
to stdout
(opened automatically by default)>
redirects stdout
of process to file
first10names.txt
stdin
head < names.txt
<
redirects file to stdin
of process;
here, access of names.txt
via stdin
stdout
of one process to stdin
of another
head names.txt | grep "Steve"
head
sends its stdout
via
pipe operator (|
) to stdin
of process for grep
Pipes
Figure © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.
/proc
For process with ID <pid>
, subdirectory /proc/<pid>/fd
indicates its file descriptors
Entries are symbolic links pointing to real destination
Use ls -l
to see numbers and their destinations, e.g.:
lrwx------ 1 jens jens 64 Jun 26 15:34 0 -> /dev/pts/3
lrwx------ 1 jens jens 64 Jun 26 15:34 1 -> /dev/pts/3
lrwx------ 1 jens jens 64 Jun 26 15:34 2 -> /dev/pts/3
lr-x------ 1 jens jens 64 Jun 26 15:34 3 -> /dev/tty
lr-x------ 1 jens jens 64 Jun 26 15:34 4 -> /etc/passwd
/dev/pts/3
(a so-called pseudo-terminal,
which represents user interaction with the command line)
for stdin
, stdout
, and stderr
/etc/passwd
via file descriptor 4/dev/tty
is
mostly the same
as /dev/pts/3
here)Who is allowed to do what?
System controls access to objects by subjects
Subject = active entity using objects: process
In general, dependent on object type, e.g.:
Transfer of rights from principal JDoe to process P_1
Figure 7.12 (a) of (Hailperin 2019): copy rights
F_1 | F_2 | JDoe | P_1 | … | |
---|---|---|---|---|---|
JDoe | read | write | |||
P_1 | read | write | |||
⋮ |
Figure 7.12 (b) of (Hailperin 2019): special right for transfer of rights
F_1 | F_2 | JDoe | P_1 | … | |
---|---|---|---|---|---|
JDoe | read | write | |||
P_1 | use rights of | ||||
⋮ |
ls
lists files and directories
-l
in “long” form
-
), directory (d
), symbolic link (l
), …r
), write (w
), execute (x
) (for directories,
“execute” means “traverse”)s
), sticky bit (t
)ls -l /etc/shadow /usr/bin/passwd
-
rw-
r--
---
1
root
shadow
2206 Jan 11 2024 /etc/shadow
-
rws
r-x
r-x
1
root
root
68208 Feb 6 13:49 /usr/bin/passwd*
ls -ld /tmp
d
rwx
rwx
rwt
14
root
root
20480 Jun 8 13:20 /tmp
Unix permissions
Figure © 2018 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.
chmod
man chmod
help umask
in bash)r
, w
, x
u
, g
, o
for user, group, others, resp.,+
or -
to add or remove a permission,r
, w
, x
, s
, t
(and more)chmod g+w file.txt
adds write permissions for
group members on file.txt
Source files are available on GitLab (check out embedded submodules) under free licenses. Icons of custom controls are by @fontawesome, released under CC BY 4.0.
Except where otherwise noted, the work “Processes”, © 2017-2024 Jens Lechtenbörger, is published under the Creative Commons license CC BY-SA 4.0.