更改 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
Changing temporary file folder location in linux (for everything on the system)?
提问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 TMPDIR
at 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 /tmp
for temporary files, and this cannot be changed.
特定的应用程序可能有用于此的配置选项或环境变量,但通常 *nix 系统应该/tmp
用于临时文件,并且不能更改。
回答by David Gelhar
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).
如果您真的坚持,您可以将/tmp
其设为指向您想要的任何位置的符号链接(Matt Joiner 的回答给出了执行此操作的特定命令)。
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.
例如,在 Mac OS 上,/tmp
是指向/private/tmp
. 这种安排可用于促进 NFS 挂载/
(大概是只读)的能力,同时将无法共享的系统特定文件(/etc、/tmp 等)保存在/private
本地磁盘的分区中。