Create temporary files usable by multiple programs.
Do not assume they will survive a reboot.
Which hierarchy is most appropriate?
/tmp is for temporary files. Programs must not rely on those files being retained across a reboot.
Detailed explanation
/usr/tmpdataIncorrect. /usr is for installed software and shareable data.
Incorrect. /usr is for installed software and shareable data.
/tmpCorrect. /tmp is the conventional shared temporary-file directory.
Correct. /tmp is the conventional shared temporary-file directory.
/etc/tmpIncorrect. /etc is for system configuration.
Incorrect. /etc is for system configuration.
/srv/tmpIncorrect. /srv stores service data rather than general temporary files.
Incorrect. /srv stores service data rather than general temporary files.
Try it yourself
An example you can run in a temporary verification environment.
stat -c '%A %n' /tmpExpected result
一般的なLinuxではsticky bitを持つ共有一時ディレクトリKey points
- Temporary
- No persistence guarantee
- Shared use
Notes
- Environment: FHS 3.0/Linux
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.