systemd-tmpfiles(8)
Create, delete, and clean up temporary files and directories according to systemd tmpfiles.d configuration files.
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
| Flag | What it does |
|---|---|
-c, --create | Create files and directories as specified in configuration, but do not clean up |
-r, --remove | Remove files and directories marked for removal in configuration |
-C, --clean | Clean up files based on age specifications (atime, mtime criteria) |
-d, --dry-run | Show what would be done without making actual changes |
-v, --verbose | Print verbose output for each operation performed |
--root=PATH | Prepend specified path as root for all operations (useful for chroots) |
--boot | Only apply items marked with 'b' or 'B' flags (boot-time only) |
-U, --user | Only apply files/directories owned by user systemd-tmpfiles runs as |
--exclude-prefix=PREFIX | Ignore paths starting with the specified prefix |
--help | Show help message and exit |
Examples
Create all temporary files and directories as configured in tmpfiles.d
systemd-tmpfiles --createClean up temporary files based on their age and configured retention rules
systemd-tmpfiles --cleanPreview what files would be created without actually creating them
systemd-tmpfiles --create --dry-runApply only the custom.conf configuration file instead of all defaults
systemd-tmpfiles --create /etc/tmpfiles.d/custom.confCreate tmpfiles verbosely with /target as the filesystem root (for installations)
systemd-tmpfiles -v --root=/target --createCreate only boot-time temporary files (those marked with 'b' or 'B' in config)
systemd-tmpfiles --boot --createCreate tmpfiles while skipping anything under /var/tmp
systemd-tmpfiles --create --exclude-prefix=/var/tmp