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

Use systemd-tmpfiles rules when you need systemd to create, set attributes on, or clean up paths such as /run/example-app and entries under /tmp. A rule describes the filesystem state; the distinct --create, --clean, and --remove operations determine what happens when it is applied. Because /run is volatile, paths there that must exist after a reboot need a suitable creation mechanism.

When systemd-tmpfiles is the right tool

systemd-tmpfiles creates, deletes, and cleans files and directories using the configuration format and locations defined by tmpfiles.d(5). System units invoke it for filesystem setup and system-wide cleanup; the tool itself only performs actions when invoked with the relevant operation. The systemd project’s systemd-tmpfiles manual describes its purpose this way.

This is useful for declaring repeatable ownership, permissions, creation, or age-based cleanup for paths. A comment in the systemd implementation source says the feature is intended to create properly owned directories beneath volatile /tmp, /var/tmp, and /run so they can be recreated on boot; that is an implementation comment, not a guarantee that any particular application path is configured on every Linux system. See systemd’s tmpfiles.c source.

Do not treat tmpfiles as a replacement for mount configuration, a service’s lifecycle management, or application logic for persistent state. If a directory is needed only while a particular service runs, a service-manager runtime-directory directive or application-managed setup may be a better fit. The right choice depends on when the path must exist, who owns it, and how it should be removed.

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.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

How to write a tmpfiles.d rule

A rule generally has one line per path, with fields for type, path, mode, user, group, age, and any argument:

#Type Path Mode User Group Age Argument...

The documented format permits C-style escapes; fields other than the argument may be quoted. Whitespace after the start of the argument belongs to the argument. Use a dash for a field that does not apply, including the argument when the rule has no argument. Full syntax and rule types are documented in tmpfiles.d(5).

Documented syntax examples

d /run/user 0755 root root 10d -
L /tmp/foobar - - - - /dev/null

The first line is the manual’s directory-rule example and includes a 10-day age field; it is not a recommendation to impose that age on every system. The second is a symlink rule. Consult the rule-type definitions in the manual before adapting either example.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Illustrative application directory

# /etc/tmpfiles.d/example-app.conf
d /run/example-app 0750 example example - -

This illustrative rule declares a directory at /run/example-app, intended to have mode 0750 and owner and group example. Put administrator-managed system rules in /etc/tmpfiles.d/. The named user and group must exist when the rule is applied. The example demonstrates documented syntax; it is not a claim that a distribution installs this file or account.

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.

Choose the operation that matches the task

Operation Purpose Practical use
--create Creates or writes entries and applies ownership, mode, and related settings for applicable rule types. Set up declared paths, including runtime directories that need to be recreated.
--clean Processes entries with an age parameter. Apply configured age-based cleanup; this is not a universal instruction to empty /tmp.
--remove Removes entries marked for removal, subject to documented lock behavior. Perform the removal work declared by applicable rules.

These operations are not interchangeable. A rule’s presence does not by itself mean it runs immediately, and running one operation does not imply that the other two have run.

How to create a directory under /run at boot

  1. Create a system rule, for example /etc/tmpfiles.d/example-app.conf, with a directory rule such as d /run/example-app 0750 example example - -. Confirm the user and group exist and choose permissions appropriate to the application.
  2. Check the installed tmpfiles.d(5) manual and systemd unit configuration to understand which setup operation applies the rule on your distribution. Systemd provides setup and cleanup units, but their exact behavior and ordering are version- and distribution-dependent.
  3. If you need to apply the rule immediately, use the appropriate systemd-tmpfiles --create invocation after reviewing the applicable rules. For a new systemd version with dry-run support, first preview it as described below.
  4. Verify that the resulting path has the intended owner, group, and mode. Since /run is volatile, confirm that the relevant setup mechanism will recreate the path after reboot rather than relying on a one-time manual creation.

Do not assume that restarting a cleanup service reruns every setup action. The systemd manual notes that changes safe to execute at runtime can be reapplied by restarting systemd-tmpfiles-clean.service; inspect the local service configuration and manual first. Boot-only actions and rules tied to a different operation are not necessarily repeated by that restart.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

How to test a rule without changing files

On systemd version 256 and later, --dry-run can show intended operations without modifying the filesystem. Check systemd-tmpfiles --help or the local manual first: older installations may not support this option.

systemd-tmpfiles --create --dry-run

To limit which rule paths are considered, the utility also supports --prefix=/run/example-app; --exclude-prefix can exclude rules under a specified prefix. These are path-selection controls, not a substitute for reading the rules they select or exclude. Check the installed systemd-tmpfiles manual for exact option syntax and availability before relying on them.

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

Review the proposed actions and the matching configuration before running a modifying operation. Be especially careful with broad cleanup or removal: the systemd manual describes system-wide --purge as usually not the desired command and recommends pairing it with dry-run first. Do not run cleanup against broad paths without understanding the applicable rules and age behavior.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

How /tmp cleanup works—and why its age varies

Cleanup depends on rules with age fields and invocation of --clean. There is no single retention age or timer cadence that applies to all Linux distributions. Installed defaults, local overrides, systemd version, and timer or service configuration on the target machine determine what is cleaned and when.

  1. Read the active system and user tmpfiles configuration locations described by the local tmpfiles.d(5) manual.
  2. Inspect the relevant cleanup service and timer configuration on that host to establish when cleanup runs.
  3. Review the age fields and rule types affecting the paths you care about before invoking --clean.

A user-level tmpfiles configuration does not shield files in shared /tmp from system-wide cleanup. The system instance performs global cleanup, and its rules can affect files created by user processes.

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

System rules, user rules, and precedence

System services use system-wide configuration, while user services use a distinct configuration set that can include user-controlled locations such as ~/.config/user-tmpfiles.d/ and ~/.local/share/user-tmpfiles.d/, as well as administrator-provided user rules. Available directories, precedence, and details have evolved over systemd versions. Use the tmpfiles.d(5) manual matching your installed systemd version instead of relying on precedence instructions written for another distribution or release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Keep the distinction in mind when setting policy: user configuration applies to the user instance’s rules; system-wide cleanup of shared paths such as /tmp remains a system-level action.

Choosing between tmpfiles, service setup, and application logic

Approach Lifecycle fit Ownership and cleanup considerations
systemd-tmpfiles Declarative filesystem setup or cleanup when the corresponding operation is invoked, including system setup and age-based cleanup. System and user instances have separate configuration scopes; age fields govern cleanup behavior where applicable.
Service-manager runtime-directory configuration Potentially suitable when a directory should follow a particular service’s lifecycle. Use when service-specific ownership or lifecycle is the requirement; consult that service manager’s documentation for exact behavior.
Application logic or explicit service setup Suitable when creation depends on application-specific startup conditions or state. The application or service must manage the needed permissions and removal behavior.

There is no universal winner for every runtime path. Choose based on whether the directory is system-wide or service-specific, whether it must exist at boot or only during a service run, and whether cleanup should be age-based or explicit.

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.