Systemd-tmpfiles is a systemd utility that programmaticly manages the creation, deletion, and cleanup of volatile and temporary files and directories using conf files. Systemd-tmpfiles is critical to the functioning of your Linux system and supports many critical functions that require the creation and deletion of ephemeral files for their operation.

I use systemd-tmpfiles to keep my systems clean and as tool to steer me towards automation and use of git.

On my Red Hat Linux servers I use systemd-tmpfiles to delete all files (excluding dot files) in interactive users home directories when they reach 7 days in age. Having a hard deadline encourages me to get changes into git quickly which reduces risk associated with dataloss and disclosure in the event a user and their home directory is compromised.

$ cat /var/home/adam/.local/share/user-tmpfiles.d/home.conf
  #Type	Path			Mode	User	Group	Age
  d	/var/home/adam/		-	    -	    -	    1w
  x	/var/home/adam/.*	-	    -	    -	    -

On my Fedora Silverblue desktops I use systemd-tmpfiles to delete downloaded files when they reach 14 days in age. Again this discourages the practice of leaving files where they may be lost and reduces clutter in my home directory.

My use of systemd-tmpfiles only scratches the surface of what is possible. The tmpfiles.d(5) manual page provides a great overview of all all the supports file types and common use cases.

I expect that as I migrate my systems to bootc that I will be using systemd-tmpfiles to assist with the dynamic creation and management of files in user home directories as I try my hand at building reproducible systems.

Look out for future posts around bootc coming in the next few weeks.