Take another look at last week’s notes.
No, I still haven’t finished grading the shell scripts. ☹
Also, it is amazing how many Linux references are on Pinterest.
Chapter 6 — systemd and init
Other references
- Wikipedia
- Understanding Systemd Units and Unit Files from Digital Ocean
- Managing Service with SystemD from Redhat
Section 6.4 — systemd
It isn’t easy to understand, but it much faster. Also, it is inevitable.
Login to your Pi or joe.cs.unca.edu to check it out.
- Systemd units (see man page for systemd.unit)
- Twelve types ‐ (eleven are listed on the man page)
- Configuration files end with the name of the type
- /usr/lib/systemd/system — provided by distribution
- /run/systemd/system — created at runtime
- /etc/systemd/system — created by systemctl enable and local modifications
- Try this command for more files:
find / /run /var -mount -type d -name systemd -exec ls -ld {} \; - Also try this:
find / /var -mount -type f -name "*.service" -exec ls -l {} \;
A systemd trail
It is doubtful you will ever write one of these.
- /lib/systemd/system/default.target
- /lib/systemd/system/graphical.target
- /lib/systemd/system/graphical.target.wants
- /lib/systemd/system/graphical.target.wants/systemd-update-utmp-runlevel.service
- /lib/systemd/system/systemd-update-utmp-runlevel.service
- /lib/systemd/systemd-update-utmp (a binary>
Controlling services with systemd
Use systemctl with commands listed on man page.
- systemctl start name.service
- systemctl stop name.service
- systemctl restart name.service
- systemctl service status
- systemctl
- systemctl --no-pager list-units --type service --all
- systemctl --no-pager show -p Wants basic.target
- systemctl --no-pager show -p Requires basic.target
Section 6.6 — System V init
Did that last month.
Section 6.7 — shutdown
Read the man page. Guess what the -k
option abbreviates.
Section 6.8 — initrd, initial root disk
Did that last month.
Chapter 7 — logging & login control
7.2 — system log
Take a look at /var/log. I use dmesg, auth.log, kern.log and sys.log. You will need to us sudo to view most of these.
7.3 — /etc/passwd and /etc/shadow
Look at these files. You will not find yourself because user authentication is handled by Kerberos and LDAP. If you are brave, you can rename /etc/passwd. You won’t be able to reboot unless you have a console.
7.6 to 7.7 — cron and at
cron is useful for scheduling backups. at is useful for making a web page invisible for a few hours.
7.8 — The three user ids
Try out the following command
    ls -l /usr/bin | grep "^[-]rws"
Now figure out why we need three different user ids.
7.9 to 7.10 — Identification, authentication and PAM
Getting LDAP, Kerberos, Active Directory
Chapter 8 — Controlling and monitoring processes
8.1 — ps (2.16) revisted
Take a look at Conquering the command line or The Geek stuff or go back to Section 2.16.
8.2 — lsof
Useful for figuring out which process is writing that huge file
8.3 — strace for OS students
Useful for figuring out why the program you downloaded keeps crashing.
8.4 — threads for every one
It is amazing how many threads a browser can run.
8.6 to 8.12 — What process is that
top is useful for figuring out what is using up all the cycles. w displays the system load and the logged in users. vmstat displays memory usage. iostat displays I/O operations. is useful for figuring out what is using up all the cycles. top is useful for figuring out which processing are hogging the most resources. Take a look at Alvin Alexander’s tutorial on top.