linux的run目录,Linux 中run 目录详细介绍

原标题:Linux 中run 目录详细介绍

/run 是各种各样数据的家园。例如,如果你查看 /run/user,你会注意到一组带有数字名称的目录。

$ ls /run/user

1000 1002 121

使用长文件列表可以发现这些数字的重要性。

$ ls -l

total 0

drwx------ 5 shs shs 120 Jun 16 12:44 1000

drwx------ 5 dory dory 120 Jun 16 16:14 1002

drwx------ 8 gdm gdm 220 Jun 14 12:18 121

我们看到每个目录与当前登录的用户或显示管理器 gdm 相关。数字代表他们的 UID。每个目录的内容都是运行中的进程所使用的文件。

/run/user 文件只是你在 /run 中找到的一小部分。还有很多其他文件。有一些文件包含了各种系统进程的进程 ID。

$ ls *.pid

acpid.pid atopacctd.pid crond.pid rsyslogd.pid

atd.pid atop.pid gdm3.pid sshd.pid

如下所示,上面列出的 sshd.pid 文件包含 ssh 守护程序(sshd)的进程 ID。

$ cat sshd.pid

1148

$ ps -ef | grep sshd

root 1148 1 0 Jun14 ? 00:00:00 /usr/sbin/sshd -D <==

root 10784 1148 0 12:44 ? 00:00:00 sshd: shs [priv]

shs 10922 10784 0 12:44 ? 00:00:00 sshd: shs@pts/0

root 18109 1148 0 16:13 ? 00:00:00 sshd: dory [priv]

dory 18232 18109 0 16:14 ? 00:00:00 sshd: dory@pts/1

shs 19276 10923 0 16:50 pts/0 00:00:00 grep --color=auto sshd

/run 中的某些子目录只能使用 root 权限访问,例如 /run/sudo。例如,以 root 身份运行我们可以看到一些与真实或尝试使用 sudo 相关的文件:

/run/sudo/ts# ls -l

total 8

-rw------- 1 root dory 112 Jun 16 16:37 dory

-rw------- 1 root shs 168 Jun 17 08:33 shs

为了与 /run 的变化保持一致,一些运行时数据的旧位置现在是符号链接。/var/run 现在是指向 /run 的指针,/var/lock 指向 /run/lock 的指针,可以保证旧的引用按预期工作。

$ ls -l /var

total 52

drwxr-xr-x 2 root root 4096 Jun 17 07:36 backups

drwxr-xr-x 19 root root 4096 Apr 18 13:46 cache

drwxrwsrwt 2 root whoopsie 4096 Jun 13 07:39 crash

drwxr-xr-x 75 root root 4096 Jun 9 15:14 lib

drwxrwsr-x 2 root staff 4096 Oct 16 2017 local

lrwxrwxrwx 1 root root 9 May 14 2018 lock -> /run/lock

drwxrwxr-x 17 root syslog 4096 Jun 17 00:00 log

drwxrwsrwt 2 root mail 4096 Jun 13 12:10 mail

drwxrwsrwt 2 root whoopsie 4096 Jan 5 2018 metrics

drwxr-xr-x 2 root root 4096 Jan 5 2018 opt

lrwxrwxrwx 1 root root 4 May 14 2018 run -> /run

drwxr-xr-x 9 root root 4096 Jun 16 2018 snap

drwxr-xr-x 9 root root 4096 Jun 9 15:14 spool

drwxrwxrwt 8 root root 4096 Jun 17 00:00 tmp

drwxr-xr-x 3 root root 4096 Jan 19 12:14 www

虽然技术上的变化很小,但转换到使用 /run 只是为了在 Linux 文件系统中更好地组织运行时数据。返回搜狐,查看更多

责任编辑:

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值