$linuxjunkies
>

systemd-tmpfiles(8)

Create, delete, and clean up temporary files and directories according to systemd tmpfiles.d configuration files.

UbuntuDebianFedoraArch

Synopsis

systemd-tmpfiles [OPTIONS] [CONFIGURATION_FILE|DIRECTORY]...

Description

systemd-tmpfiles creates, deletes, and cleans up temporary files and directories as specified by tmpfiles.d configuration files. It is typically run early at boot and periodically via a timer to maintain system state, removing stale files and ensuring required directories exist with correct permissions.

Configuration files are read from /etc/tmpfiles.d/, /run/tmpfiles.d/, and /usr/lib/tmpfiles.d/ directories, defining file creation rules, permissions, ownership, and cleanup policies. Each line in a configuration file specifies an action type (f, d, L, p, etc.) and target path.

Common options

FlagWhat it does
-c, --createCreate files and directories as specified in configuration, but do not clean up
-r, --removeRemove files and directories marked for removal in configuration
-C, --cleanClean up files based on age specifications (atime, mtime criteria)
-d, --dry-runShow what would be done without making actual changes
-v, --verbosePrint verbose output for each operation performed
--root=PATHPrepend specified path as root for all operations (useful for chroots)
--bootOnly apply items marked with 'b' or 'B' flags (boot-time only)
-U, --userOnly apply files/directories owned by user systemd-tmpfiles runs as
--exclude-prefix=PREFIXIgnore paths starting with the specified prefix
--helpShow help message and exit

Examples

Create all temporary files and directories as configured in tmpfiles.d

systemd-tmpfiles --create

Clean up temporary files based on their age and configured retention rules

systemd-tmpfiles --clean

Preview what files would be created without actually creating them

systemd-tmpfiles --create --dry-run

Apply only the custom.conf configuration file instead of all defaults

systemd-tmpfiles --create /etc/tmpfiles.d/custom.conf

Create tmpfiles verbosely with /target as the filesystem root (for installations)

systemd-tmpfiles -v --root=/target --create

Create only boot-time temporary files (those marked with 'b' or 'B' in config)

systemd-tmpfiles --boot --create

Create tmpfiles while skipping anything under /var/tmp

systemd-tmpfiles --create --exclude-prefix=/var/tmp

Related commands