Changing temporary file folder location in linux (for everything on the system)?

19,251

Solution 1

sudo rmdir /tmp && ln -s /some/other/loc /tmp

Alternatively, set the environment variable TMPDIR at the highest level possible. For the environment, or per user.

Solution 2

Specific applications may have configuration options or environment variables for this, but in general *nix systems are supposed to use /tmp for temporary files, and this cannot be changed.

Solution 3

You can, if you really insist, make /tmp be a symbolic link to whatever location you want (Matt Joiner's answer gives the specific command to do that).

For example, on Mac OS, /tmp is a symlink to /private/tmp. This arrangement can be used to facilitate the ability to NFS-mount / (presumably read-only) while keeping system-specific files that can't be shared (/etc, /tmp, and so forth) in a /private partition on a local disk.

Share:
19,251
siliconpi
Author by

siliconpi

Updated on August 31, 2022

Comments

  • siliconpi
    siliconpi over 1 year

    Currently its /tmp

    How can I set it to /anythingelse so that all applications use that subsequently?

    • Mark Embling
      Mark Embling over 13 years
      Why would you want to do this?
  • Ignacio Vazquez-Abrams
    Ignacio Vazquez-Abrams over 13 years
    This does not change it from /tmp. This merely changes where /tmp points.
  • Matt Joiner
    Matt Joiner over 13 years
    The clue is in "all applications subsequently". It doesn't get sweeter.
  • Matt Joiner
    Matt Joiner over 10 years
    Changing TMPDIR, does change it from /tmp.
  • CodeBy
    CodeBy almost 3 years
    after doing that some apps didn't run: "cannot create temporary directory for the root file system: Permission denied"
  • Matt Joiner
    Matt Joiner almost 3 years
    You will probably need to create the directory in advance, and give everyone permissions.