Quantcast
Viewing all articles
Browse latest Browse all 2849

General Questions • Re: Have TMPDIR/TMP environment variables been deprecated

Hello,

Following on from @lindi's answer, this might be a useful addition:
  • systemd - Using /tmp/ and /var/tmp/
    /tmp/ and /var/tmp/ are two world-writable directories Linux systems provide for temporary files. The former is typically on tmpfs and thus backed by RAM/swap, and flushed out on each reboot. The latter is typically a proper, persistent file system, and thus backed by physical storage. This means:

    /tmp/ should be used for smaller, size-bounded files only; /var/tmp/ should be used for everything else.

    Data that shall survive a boot cycle shouldn’t be placed in /tmp/.

    If the $TMPDIR environment variable is set, use that path, and neither use /tmp/ nor /var/tmp/ directly.
According to file-hierarchy specifications from freedesktop.org[1]:
Runtime Data

/run/

A "tmpfs" file system for system packages to place runtime data, socket files, and similar. This directory is flushed on boot, and generally writable for privileged programs only. Always writable.

[..]

/run/user/

Contains per-user runtime directories, each usually individually mounted "tmpfs" instances. Always writable, flushed at each reboot and when the user logs out. User code should not reference this directory directly, but via the $XDG_RUNTIME_DIR environment variable, as documented in the XDG Base Directory Specification.
Hope this helps.

--
[1] https://www.freedesktop.org/software/sy ... archy.html

Statistics: Posted by Aki — 2024-07-31 19:10



Viewing all articles
Browse latest Browse all 2849

Trending Articles