/tmp 如何链接到 /var/tmp

/tmp 如何链接到 /var/tmp

我已经阅读了 /tmp 和 /var/tmp 之间的差异,因此请注意,这不是这个问题的内容。当我在 /tmp 中创建文件时,它会显示在 /var/tmp 中;但是,两个目录都不会显示为另一个目录的符号链接:

[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
...

它们是如何链接的:

[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]#

顺便说一句,这是 RHEL 7:

[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)"

答案1

根据 @Gilles 评论的建议,看起来 /tmp 和 /var/tmp 已安装到同一虚拟卷:

[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: -

相关内容