October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Manage Temporary Files and Directories with systemd-tmpfiles

A practical guide to inspecting tmpfiles.d rules and choosing safe systemd-tmpfiles operations for creation, cleanup, and removal.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

systemd-tmpfiles applies rules defined in tmpfiles.d to create, adjust, clean, or remove filesystem paths. To use it safely, first inspect the effective configuration, choose the operation that matches your goal, and preview risky changes where the installed systemd version supports it.

What systemd-tmpfiles does

systemd-tmpfiles is the command-line utility; tmpfiles.d is the configuration format and set of locations from which it reads rules. The official systemd-tmpfiles manual describes it as a tool that “creates, deletes, and cleans up files and directories.” Although it was designed for volatile and temporary files, its rules can manage other filesystem paths too.

As an Amazon Associate I earn from qualifying purchases.

That distinction matters: running the command does not itself specify which paths to manage. The rules determine the target paths and actions, while the command-line operation determines which kinds of rules to apply. For exact rule syntax and configuration locations, consult the tmpfiles.d(5) manual installed on the machine you are administering; syntax and available options can vary by systemd release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the operation that matches your goal

Operation What it does Use it for
--create Applies creation, writing, ownership, mode, and security-label actions specified by applicable rules. Setting up or correcting configured paths and their attributes.
--clean Processes entries with configured age limits. Applying age-based cleanup rules.
--remove Applies configured removal actions. Removing paths or directory contents designated by rules.
--purge Targets entries marked with $ in explicitly specified configuration files. Only when you specifically need that behavior and have reviewed the targets.

When --create, --clean, and --remove are combined, removal and cleanup run before creation. For example, the manual gives systemd-tmpfiles --remove --create as a boot-time setup invocation. Do not assume that combining options makes a command safer: the selected rules and target paths still determine the effects.

Inspect configuration before applying it

Start by finding out which rules the command can see. On versions that support these options, use:

  • systemd-tmpfiles --cat-config to display configuration contents along with file names.
  • systemd-tmpfiles --tldr to display configuration without comments and blank lines.

These views help identify the rules behind an operation, but they do not replace checking their syntax against the target machine’s tmpfiles.d(5) documentation. A rule accepted by one installation may not be accepted by another, so validate the syntax and supported features on the host where it will run.

Understand system and user scope

The system instance and user instances read separate configuration. The --user option selects user configuration; it was added in systemd version 236 according to the manual. Check the installed version before relying on it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate configuration does not mean separate filesystems. A user-created file under a shared path such as /tmp/ can still be affected by system-wide age-based cleanup configured for that location. When diagnosing an unexpected deletion, consider both the rule’s configuration scope and the path’s exposure to cleanup from another instance.

Preview before cleanup or removal

Where supported, --dry-run prints the operations that would be performed without changing the filesystem. The manual says --dry-run was added in systemd version 256, so verify availability on older or distribution-specific installations before using it as a safety check.

Be especially cautious with --purge. It requires explicitly named configuration files or standard input, operates on entries marked with $, and the manual warns that --remove is usually the command administrators want instead. The manual recommends previewing a purge first. --purge was also added in version 256.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apply changes at the appropriate time

For runtime-safe changes

For changes that are safe to apply while the system is running, restart systemd-tmpfiles-clean.service to reapply its settings. Avoid treating this as a substitute for understanding the rules: inspect the configuration and confirm that its cleanup effects are appropriate before restarting the service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For work intended only for early boot

Rules prefixed with ! are intended for work that is unsafe on an already-running system. They are enabled with --boot, an option added in systemd version 209 according to the manual. Do not use early-boot rules as a way to force a runtime operation; their timing is part of their safety design.

Check errors and interpret the result

Review both the command’s messages and its exit status. The manual distinguishes several outcomes:

  • 65: configuration was syntactically invalid and lines had to be ignored, with no other errors occurring.
  • 73: configuration was valid, but it could not be executed.
  • 1: another failure occurred.

Not every mismatch is necessarily fatal: the manual notes that certain target mismatches without forced operation can produce a message and otherwise be ignored. When troubleshooting, use increased logging on a direct invocation and read the messages in context rather than assuming that every warning means the entire operation failed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.