Questions tagged [tmp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
302 votes
7 answers
309k views

How create a temporary file in shell script?

While running a script, I want to create a temporary file in /tmp directory. After execution of that script, that will be cleaned by that script. How to do that in shell script?
  • 3,155
183 votes
4 answers
155k views

What is the difference between /tmp and /var/tmp?

On most FHS systems, there is a /tmp folder as well as a /var/tmp folder. What is the functional difference between the two?
  • 13.8k
116 votes
1 answer
82k views

What happens when you 'mount over' an existing folder with contents?

Right now /tmp has some temporary files in it. When I mount my hard drive (/dev/sdc1) on top of /tmp, I can see the files on the hard drive. What happens to the actual content of /tmp when my hard ...
  • 1,529
108 votes
3 answers
213k views

What are correct permissions for /tmp ? I unintentionally set it all public recursively

I have created a really really short life temporary directory that I wanted to share between some users for a few hours : /some/path/tmp Unfortunately I have launched sudo chown 777 -R /tmp instead ...
86 votes
12 answers
304k views

Tab completion errors: bash: cannot create temp file for here-document: No space left on device

When using the tab bar, I keep getting this error: bash: cannot create temp file for here-document: No space left on device" Any ideas? I have been doing some research, and many people talk about ...
62 votes
3 answers
41k views

Finding the correct tmp dir on multiple platforms

I have a script that needs to create temporary files for its work, and clean up after itself. My question is about finding the right base directory for the temporary files. The script needs to work ...
  • 11k
45 votes
4 answers
57k views

How to make a temporary file in RAM?

I have a script that will pipe its output to |tee scriptnameYYMMDD.txt. After each cycle of the for loop in which the output is generated, I'll be reversing the file contents with tac ...
  • 2,399
43 votes
3 answers
11k views

is /tmp guaranteed to exist?

Do I need to check & create /tmp before writing to a file inside of it? Assume that no one has run sudo rm -rf /tmp because that's a very rare case
  • 4,467
33 votes
6 answers
40k views

Is it safe to rm -rf /tmp/*?

This is something I used to do a lot on Windows, but after my recent fiasco I want to make sure. Is it safe to do sudo rm -rf /tmp/* ?
  • 30.4k
28 votes
3 answers
36k views

Overflow /tmp mounted when there is free space on /

I recently faced an "overflow" issue on /tmp. I don't have a separate /tmp partition, and there is 17% free in / – then why did I get an overflow tmp filesystem? # /etc/fstab: static file ...
  • 23.8k
27 votes
2 answers
9k views

I made a mistake last night, which deleted 1800GB of my File-Server unintentionally

I ran this command yesterday, I thought on a test machine, but it was a File-Server connected through SSH. sudo rm -rf /tmp/* !(lost+found) My terminal emulator is Konsole. My system is Debian 7. ...
22 votes
4 answers
2k views

How can I copy a /tmp/ directory that is created & deleted by a process?

I am investigating the behavior of a binary on Oracle Linux 9 (XFS filesystem). This binary, when called by a process, creates a directory under /tmp and copies some files to it. This directory gets a ...
19 votes
2 answers
11k views

How can I safely create and access temp files from shell scripts?

I've read that redirecting output to a fixed name file in /tmp can be a security risk, because if an attacker (or malcontent) notices that a file /tmp/tmpfileformyscript.tmp is created when I run my ...
  • 34.7k
18 votes
2 answers
5k views

hook a script to apt-get

I have /tmp on a separate partition, and mounted with noexec. I am using Debian. The installation of some packages fails, because the post-installation scripts of some packages need to run from /tmp. ...
  • 3,833
18 votes
1 answer
50k views

Can you remount /tmp partition to exec while live?

I have a server I need to re mount the /tmp partition to run exec. The code I want to use is: mount -o remount,exec /tmp Run the program that needs it. Than change it back. mount -o remount,...
17 votes
4 answers
1k views

Which folder should I write to for my intermediate files, as a dev?

I'm starting to write a few bash scripts for my project and they need some intermediate files or variables to be written. I want to know which folders can I be sure of having access to when someone ...
16 votes
3 answers
26k views

Generic way to get temp path?

I heard about $TEMP and $TMP, but I think they are not standard for every distro. As far as I know, the best way to get the temp dir is just /tmp, is there any distro that won't work using that path?
14 votes
3 answers
29k views

Shall I save my crontab file in /tmp?

I ssh to a server, and want to add some daily jobs (specifially to renew Kerberos tickets even when I log out and I still want my programs in screen or tmux continue to run) to cron. So I run crontab -...
  • 95.7k
14 votes
2 answers
29k views

When exactly does tmpwatch clear out files I place in /tmp?

CentOS 6.x I'm confused on when exactly files I place in /tmp/ are deleted. /etc/cron.daily/tmpwatch has the following: #! /bin/sh flags=-umc /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/....
  • 8,639
12 votes
4 answers
5k views

Prevent a directory in /tmp from being deleted

I often use the /tmp directory on my Linux machine for storing temporary files (e.g. PDFs from a site that wants me to download it first etc.) and I often create a directory with my username. But at ...
  • 195
12 votes
3 answers
947 views

bash: Some issue when using read <<<"$VARIABLE" on a read-only root partition. Any known workarounds?

Just by coincidence I had to use my ATA-ID-to-device-name script (found here: https://serverfault.com/questions/244944/linux-ata-errors-translating-to-a-device-name/426561#426561) on a read-only / ...
  • 2,206
12 votes
1 answer
1k views

bash process substitution with temporary file

Some programs needs their files to be seekable, for example objdump does. $ objdump -D -b binary -m i8086 <(echo 0xea 0x5b 0xe0 0x00 0xf0|xxd -r -p) objdump: Warning: '/proc/self/fd/11' is not an ...
11 votes
1 answer
6k views

What can go wrong if /var/tmp is on a temporary filesystem?

I have read that I should not mount /var/tmp as a temporary filesystem (e.g., as tmpfs), because files in /var/tmp must not be deleted on reboot. Is that correct? Suppose I did mount /var/tmp as a ...
  • 3,802
10 votes
4 answers
16k views

Why is `systemd-tmpfiles --clean` not working?

I have the following configuration to clean up temporary files (default for CentOS 7), which says that files in /tmp should be removed if they are more than 10 days old. [root]# tail -n +10 /usr/lib/...
  • 439
10 votes
3 answers
4k views

Watch /tmp for file creation and prevent deletion of files? [duplicate]

I have a binary that creates some files in /tmp/*some folder* and runs them. This same binary deletes these files right after running them. Is there any way to intercept these files? I can't make the ...
  • 203
10 votes
5 answers
4k views

saving in /tmp is not really saving?

Open e.g. a mail attachment from Firefox (without previously saving it); this is a Libre Office document, you edit it, and then push save (not save as) and close both text editor and browser. Then the ...
  • 283
10 votes
0 answers
3k views

Is it possible to change systemd private tmp directory?

I am running some programs on both Debian and Fedora. When I ls the /tmp directory, I see many directories with extremely long name like systemd-private-d85027...-bluetooth.service-qxzMGm systemd-...
9 votes
1 answer
20k views

Yum user temp files (/var/tmp/yum*) fills up with repo data

On my rhel6 system, non-sudo users can do yum check-update. Files are then placed in /var/tmp/yum[user]*/ . The repodata there gets quite large. Can I: Configure the location? Configure yum so it ...
  • 1,408
9 votes
1 answer
3k views

OEL6 Slow boot && Millions of socket files in /tmp/orbit-gdm

Background on question Lately I've been having some trouble with slow booting on the servers, sometimes over 2 hours to boot stuck on "Enabling Local Filesystem Quotas:" After searching I managed to ...
  • 63
8 votes
3 answers
18k views

How can I check to see if the /tmp directory on my CentOS 5.x system is mounted on tmpfs?

CentOS 5.x My understanding is that the contents of /tmp/ in CentOS 5.x can/are automatically purged by the OS via one of two methods: A daily cron task running tmpwatch If /tmp/is mounted on a ...
  • 8,639
8 votes
1 answer
778 views

permissions of symlinks inside /tmp

I have 2 users in my machine: linuxlite and otheruser. otheruser has a file: otheruser@linuxlite:~$ ls -l a -rw-rw-r-- 1 otheruser otheruser 6 Mar 31 12:47 a otheruser@linuxlite:~$ cat a hello ...
  • 208
8 votes
1 answer
3k views

Can LVM snapshots be writable? (and used for temporary experiments)

It seems that usually it is talked about snapshots as read-only. (In a scenario where one creates a snapshot, then does some experiments with the main volume, and then restores the old state by "...
7 votes
2 answers
5k views

Is it OK to store /var/tmp on a SSD? [duplicate]

I have read that you should not store /tmp on a SSD, because the frequent writes will shorten the lifetime of the SSD. But what about /var/tmp? Is it reasonable for /var/tmp to be stored on a SSD? ...
  • 3,802
7 votes
1 answer
9k views

How to edit the timer for systemd-tmpfiles-clean?

I'm trying to change the cleanup interval for Apache PrivateTmp files from the default 30 days to 6 hours. I read that to edit the time intervals, I should set up an override file in /etc/tmpfiles.d/...
  • 173
7 votes
2 answers
9k views

why php can not see /tmp files

i have simple test.php page: <pre><?php system("ls -la /tmp"); ?></pre> which always shows just: . and .. folders and nothing else in browser. in the command line: 1) ls -la /...
7 votes
3 answers
9k views

Which filesystem / filesystem option to use for /tmp partition

When using a separate disk partition for /tmp, ie /dev/sda4, what filesystem is most suitable ? ext4 seems inappropriate: I don't need journal, I don't need that lost+found directory there either. ...
6 votes
4 answers
2k views

Using the /tmp folder for backups, recommended?

Is it safe to put my temporary manual backups of my website codebase and database into the /tmp folder? I'm running Debian 8. I want to leave them there for a couple days. I am not sure if this ...
  • 215
6 votes
2 answers
8k views

tmpfs does not overflow to swap

I've configured tmp in /etc/fstab like this: tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 2 The problem is that now /tmp is limited to half of the machine's memory, and when it reaches that limit I'...
  • 2,455
6 votes
2 answers
12k views

How to create / delete $XDG_RUNTIME_DIR at login / logoff

Today I was surprised to ssh into my box running Arch Linux and find that /run/user/$(id -u) didn't exist. The XDG Base Directory Specification says: $XDG_RUNTIME_DIR defines the base directory ...
  • 27.3k
6 votes
2 answers
5k views

Firefox temporary files

In Firefox, when I choose to open a file without saving it and without an internal plugin (like a pdf or a doc file) the default behavior is that the file is saved in /tmp as a temporary file and that ...
  • 63
5 votes
4 answers
2k views

Is it possible to boot in a way that doesn't delete /tmp?

Say I'm running some lengthy process, consisting of two steps: a generates a big intermediate file, say /tmp/aoutput, then b reads that file and does something further with it. Now the system crashed ...
5 votes
2 answers
46k views

"bash: cannot create temp file for here-document: No space left on device"

My / only has about 800MB free space left. I guess it is the reason that $ convert * book.pdf Segmentation fault (core dumped) bash: cannot create temp file for here-document: No space left on device ...
  • 95.7k
5 votes
1 answer
2k views

SUID-bit not working for executables within /tmp directory

Printing the value of getuid() and geteuid() from an executable with SUID-bit (chmod +s) turned-on, seems to result with the original caller ID instead of the owner id if the executable is located ...
  • 51
4 votes
2 answers
4k views

Linux + files & folders cleanup under /tmp

On all my Red Hat Linux machines version 7.2 we saw that systemd-tmpfiles-clean.service is inactive: systemctl status systemd-tmpfiles-clean.service ● systemd-tmpfiles-clean.service - Cleanup of ...
  • 12.1k
4 votes
1 answer
3k views

When are files from /tmp deleted?

I'd like to investigate when files in /tmp get removed. I run CentOS 7. Policy regarding deleting files from that directory is governed as follows: RHEL7 and RedHat-like with systemd it's ...
  • 270
4 votes
2 answers
1k views

Single process accessible temporary file

I want to create a file that is only accessible to the process that created it (and potentially its children), and that disappears when the process exits, ideally never persisting the file to disk. As ...
4 votes
2 answers
353 views

Should TMPDIR have a trailing slash?

In Unix/POSIX/Linux systems it's possible to set the temporary directory via the TMPDIR variable. Wikipedia references a specification by the Open Group mentioning this. What this doesn't answer for ...
  • 101
4 votes
2 answers
3k views

Could you explain this "chroot" /tmp directory creation?

In the following linked article they explain how to create a "chroot" /tmp directory. I'm a bit confused by what they did. Could someone explain what the following commands are doing? Noexec and /tmp ...
  • 143
4 votes
1 answer
2k views

Paritioning Scheme: Arch Linux server & laptop

What would be a good partitioning scheme for an Arch Linux installation, on a server and on a laptop? My current basic scheme: / [root] ext4 /home ext4 swap I know ...
4 votes
1 answer
1k views

curl not able to write to /tmp directory owned by user

I tried running the script as instructed in https://docs.docker.com/engine/security/rootless/: $ curl -fsSL https://get.docker.com/rootless | sh But the script crashed in the following line: curl -L -...