Questions tagged [tmp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
175
votes
6answers
170k 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?
144
votes
4answers
96k 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?
90
votes
1answer
50k 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 ...
84
votes
3answers
149k 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 ...
50
votes
7answers
165k 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 ...
48
votes
3answers
24k 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 ...
42
votes
3answers
7k 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
31
votes
4answers
31k 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 ...
29
votes
6answers
31k 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/* ?
27
votes
2answers
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. ...
26
votes
3answers
31k 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 ...
17
votes
4answers
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 ...
17
votes
2answers
4k 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. ...
14
votes
2answers
6k 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 ...
14
votes
2answers
26k 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/....
11
votes
3answers
19k 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 -...
11
votes
3answers
743 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 / ...
10
votes
4answers
2k 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 ...
10
votes
5answers
3k 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 ...
9
votes
3answers
3k 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 ...
9
votes
1answer
20k 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,...
9
votes
1answer
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 ...
8
votes
1answer
3k 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 ...
8
votes
1answer
465 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 ...
8
votes
1answer
824 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 ...
7
votes
1answer
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 "...
6
votes
4answers
1k 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 ...
6
votes
2answers
4k 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? ...
6
votes
1answer
8k 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?
6
votes
1answer
13k 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 ...
5
votes
2answers
43k 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 ...
5
votes
2answers
6k 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 /...
5
votes
0answers
1k 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-...
4
votes
3answers
12k 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 ...
4
votes
2answers
949 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 ...
4
votes
1answer
2k 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 ...
4
votes
2answers
2k 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 ...
4
votes
2answers
876 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
1answer
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 ...
4
votes
2answers
3k 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 ...
4
votes
3answers
3k 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. ...
3
votes
3answers
9k 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/...
3
votes
2answers
3k 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'...
3
votes
2answers
550 views

How to intercept temporary files created by a program? [duplicate]

TL;DR: I know a program creates and then deletes files in /tmp. How can I intercept them for examination ? Context: There's a particular .jar file, which I don't trust; for some reason its source ...
3
votes
1answer
3k views

Command(s) to install tempfile on CentOS 6.4

I'm looking to install the package for tempfile but am not finding it? possibly use mktemp but I'm not sure if there is a difference in behaviour besides a dot notation in the temp name? $ tempfile # ...
3
votes
1answer
1k views

Is a subdirectory of /tmp a suitable place for Unix sockets?

I am looking for a secure place to put Unix domain sockets that will be used to control a REPL. On Linux, I would use /run/user/$UID, which meets all requirements except for portability. I need the ...
3
votes
1answer
656 views

How do I clean out my /tmp directory upon reboot?

I’m using Amazon Linux. Below is the uname info … [davea@mymachine ~]$ uname -a Linux sandbox.mydomain.com 4.4.18-35.99.amzn1.x86_64 #1 SMP Wed Jul 27 22:37:49 UTC 2016 x86_64 x86_64 x86_64 GNU/...
3
votes
1answer
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 ...
3
votes
1answer
2k 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/...
3
votes
1answer
2k views

Unable to re-create /tmp directory

Recently, I have found that my debian 8.2 (jessie) installation is taking forever to boot because systemd will hang for several minutes on a start job is running for create volatile files and ...