Temp Files Flashcards
Which service manages the lifecyle of temp files
systemd-tempfiles-setup
What does systemd-tmpfiles-setup service do?
create, delete, and clean up volatile and temporary files and directories.
where is the config that systemd uses to manage systemd-tmpfiles-setup service located?
/usr/lib/systemd/system/systemd-tmpfiles-setup.service
Diff between:
/usr/lib/systemd/system/systemd-tmfiles-setup.services
and files in
/usr/lib/tmpfiles.d/, /run/tmpfiles.d/, /etc/tmpfiles.d/
First is a config file for systemd telling it how to start and manage systemd-tmpfiles-setup
The second set of files are config files for systemd-tmpfiles-setup.
What are location of config files for systemd-tmpfiles-setup:
1) /usr/lib/tmpfiles.d/
2) /run/tmpfiles.d/
3) /etc/tmpfiles.d/
In what order are systemd-tmpfiles.setup config files evaluated?
1) /usr/lib/tmpfiles.d/.conf
2) /run/tmpfiles.d/.conf
3) /etc/tmpfiles.d/*.conf
Explain tmp file cleanup process
timer unit
systemd-tmpfiles-clean.timer
periodically call
systemd-tmpfiles-clean.service
to do the cleaup as per configurations in:
1) /usr/lib/tmpfiles.d/
2) /etc/tmpfiles.d/
3) /run/tmpfiles.d/
What are the different systemd unit types?
1) Service Units
2) Socket Units
3) Device Units
4) Mount Units
5) Automount Units
6) Target Units (.target):
7) Timer Units (.timer):
8) Path Units (.path):
9) Slice Units (.slice):
10) Scope Units (.scope):
Explain:
q /tmp 1777 root root 10d
tmpfile config of /usr/lib/tmfiles.d/tmp.conf
says that files under /tmp will be purged after 10d if not accessed.
How do you modify the content of
/usr/lib/tmfiles.d/tmp.conf
1) Copy it to following location and modify the copy. Then run the clean command.
/etc/tmfiles.d/tmp.conf
systemd-tmpfiles --clean etc/tmfiles.d/tmp.conf
Create a new folder and define its cleanup policy
echo 'q /home/student/momentary 0700 root root 30s' > /etc/tmpfiles.d/momentary.conf
systemd-tmpfiles --create /etc/tmp files.d/momentary.conf
What is special about the /run folder
exists only in memory
What command does systemd-tmpfiles-setup calls to do its job?
systemd-tmpfiles
Show the content of a timer unit
systemctl cat systemd-tmpfiles-clean.timer
How does a timer know when to invoke the service it is meant to invoke?
In the config file of the timer, there is a [Timer] section for this purpose
What fields are used to control when the timer will invoke the service it is supposed to control?
1) OnBootSec=15min
2) OnUnitActiveSec=1d
Explain the command:
d /run/systemd/seats 0755 root root -
1) create dir /run/systemd/seats
2) chown root:root
3) chmod 0755
4) If directory exists, do nothing.
5) systemd-tmpfiles does not purge this directory.
Explain the command:
D /home/student 0700 student student 1d
1) create dir /home/student directory
2) chown student:student
3) chmod 0700
4) If directory exists, wipe its content.
5) systemd-tmpfiles purges this directory after 1d inactivity.
Explain the command:
L /run/fstablink - root root - /etc/fstab
1) create link /run/fstablink pointing to /etc/fstab
2) chown root:root
3) systemd-tmpfiles never purges this link
OnBootSec=15min
Interval between system boot and first service activation
OnUnitActiveSec=1d
Interval between successive timer activations
Similarity between systemd-tmpfiles-setup and systemd-tmpfiles-clean services
They all use systemd-tmpfiles command to create, delete, purge.
Diff between systemd-tmpfiles-setup and systemd-tmpfiles-clean services
Setup runs at boot time, clean runs according to timer.