更改 linux 中的临时文件夹位置(对于系统上的所有内容)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3803679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:18:08  来源:igfitidea点击:

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

linuxredhattemporary-directory

提问by siliconpi

Currently its /tmp

目前它的 /tmp

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

如何将其设置为 /anythingelse 以便所有应用程序随后都使用它?

采纳答案by Matt Joiner

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

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

或者,将环境变量设置为TMPDIR尽可能高的级别。对于环境,或每个用户。

回答by Ignacio Vazquez-Abrams

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

特定的应用程序可能有用于此的配置选项或环境变量,但通常 *nix 系统应该/tmp用于临时文件,并且不能更改。

回答by David Gelhar

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

如果您真的坚持,您可以将/tmp其设为指向您想要的任何位置的符号链接(Matt Joiner 的回答给出了执行此操作的特定命令)。

For example, on Mac OS, /tmpis 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 /privatepartition on a local disk.

例如,在 Mac OS 上,/tmp是指向/private/tmp. 这种安排可用于促进 NFS 挂载/(大概是只读)的能力,同时将无法共享的系统特定文件(/etc、/tmp 等)保存在/private本地磁盘的分区中。