2

I've already read up on the differences between /tmp and /var/tmp, so note that this is not what this question is about. When I create a file in /tmp, it shows up in /var/tmp; however, neither directory shows as a sym-link of the other:

[root@l12662 /]# pwd; ll
/
total 32
lrwxrwxrwx.   1 root root    7 Aug 25  2017 bin -> usr/bin
dr-xr-xr-x.   4 root root 4096 Aug 25  2017 boot
drwxr-xr-x   21 root root 3560 Nov 18 23:32 dev
...
drwxrwxrwt.  27 root root 4096 Nov 24 08:18 tmp
...
[root@l12662 /]# cd /var
[root@l12662 var]# ll
total 12
drwxr-xr-x.  2 root root   19 Mar 28  2017 account
drwxr-xr-x.  2 root root    6 Mar 10  2016 adm
drwxr-xr-x. 10 root root  122 Aug 25  2017 cache
...
drwxrwxrwt. 27 root root 4096 Nov 24 08:18 tmp
...

How are they linked:

[root@l12662 tmp]# pwd; ls | grep test
/tmp
[root@l12662 tmp]# ls /var/tmp/ | grep test
[root@l12662 tmp]# pwd; touch test.me
/tmp
[root@l12662 tmp]# pwd; ls | grep test
/tmp
test.me
[root@l12662 tmp]# ls /var/tmp/ | grep test
test.me
[root@l12662 tmp]#

This is RHEL 7, btw:

[root@l12662 tmp]# cat /etc/*release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
4
  • Maybe one is a bind-mount of the other? Look at grep /tmp /proc/mounts and stat /tmp /var/tmp Commented Nov 24, 2021 at 15:28
  • That looks like the right answer. Make that an official answer so I can up-vote it.
    – JayRugMan
    Commented Nov 24, 2021 at 15:32
  • follow-up question, if you know... Will it follow the /tmp management rules, or the /var/tmp - cleared on reboot, etc...? Where would I check this out?
    – JayRugMan
    Commented Nov 24, 2021 at 15:36
  • It's an xfs filesystem, so it's persistent. If there's a script that deletes old files in /tmp on boot (which I think RHEL does by default), it'll delete old files in /tmp, it won't care that /tmp also happens to be visible at another location. Commented Nov 24, 2021 at 16:01

1 Answer 1

2

per @Gilles commented recommendations, it looks like /tmp and /var/tmp are mounted to the same virtual volume:

[root@l12662 tmp]# grep /tmp /proc/mounts
/dev/mapper/rootvg-tmplv /tmp xfs rw,nosuid,nodev,noexec,relatime,attr2,inode64,noquota 0 0
/dev/mapper/rootvg-tmplv /var/tmp xfs rw,nosuid,nodev,noexec,relatime,attr2,inode64,noquota 0 0
[root@l12662 tmp]# stat /tmp /var/tmp
  File: ‘/tmp’
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd05h/64773d    Inode: 64          Links: 27
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-11-24 08:30:34.016446287 -0700
Modify: 2021-11-24 08:30:55.398311353 -0700
Change: 2021-11-24 08:30:55.398311353 -0700
 Birth: -
  File: ‘/var/tmp’
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd05h/64773d    Inode: 64          Links: 27
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-11-24 08:30:34.016446287 -0700
Modify: 2021-11-24 08:30:55.398311353 -0700
Change: 2021-11-24 08:30:55.398311353 -0700
 Birth: -

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .