为什么不能ls
使用我的脚本 cron /dev 中的某些文件?
从命令行运行时,该脚本可以完整列出 /dev。从任一 cron 设置运行的相同脚本无法看到 (list, ls) /dev 中的大部分文件。无论哪种方式,脚本都以 root 身份运行,具有几乎相同的 env 值,结果却大不相同。/dev 中大约有 100 个文件无法访问,包括所有磁盘,因此mount
无法从 cron 进行操作。(Debian 11.6 最小网络全新安装,没有 SELinux 或 Apparmor,没有容器。)
下面是一个揭示这种令人费解的行为的诊断脚本。脚本本身除了说明和阐明这些行为外没有任何用处,但是 cron 任务查看某些关键文件(例如,挂载文件系统、使用 df 检查空间等)的能力是至关重要的。
#!/bin/bash
# turn on some tracing, get a timestamp, printenv, whoami
set -xa
echo "timestamp: $(date)"
echo "env values:"
printenv
whoami
cd /
echo "ls -la"
ls -la
cd /dev
echo "cd to /dev, then ls -la"
ls -la
cd disk
echo "cd to /dev/disk, then ls -la"
ls -la
echo " "
echo "just because someone might ask, try to ls /dev/disk directly from /"
cd /
ls -la /dev/disk
命令行输出:
++ date
+ echo 'timestamp: Thu 16 Feb 2023 10:05:33 PM CST'
timestamp: Thu 16 Feb 2023 10:05:33 PM CST
+ echo 'env values:'
env values:
+ printenv
SHELL=/bin/bash
PWD=/usr/local/bin
LOGNAME=root
TEMPDIR=/tmp/user/0
HOME=/root
LANG=en_US.UTF-8
TMPDIR=/tmp/user/0
TERM=xterm-256color
USER=root
TEMP=/tmp/user/0
SHLVL=2
TMP=/tmp/user/0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
OLDPWD=/
_=/usr/bin/printenv
+ whoami
root
+ cd /
+ echo 'ls -la'
ls -la
+ ls -la
total 68
drwxr-xr-x 18 root root 4096 Feb 16 21:19 .
drwxr-xr-x 18 root root 4096 Feb 16 21:19 ..
lrwxrwxrwx 1 root root 7 Feb 7 19:48 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Feb 12 20:57 boot
drwxr-xr-x 17 root root 3300 Feb 16 16:53 dev
drwxr-xr-x 99 root root 4096 Feb 16 17:09 etc
drwxr-xr-x 4 root root 4096 Feb 9 18:58 home
lrwxrwxrwx 1 root root 31 Feb 7 19:51 initrd.img -> boot/initrd.img-5.10.0-21-amd64
lrwxrwxrwx 1 root root 31 Feb 7 19:49 initrd.img.old -> boot/initrd.img-5.10.0-20-amd64
lrwxrwxrwx 1 root root 7 Feb 7 19:48 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Feb 7 19:48 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Feb 7 19:48 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Feb 7 19:48 libx32 -> usr/libx32
drwx------ 2 root root 16384 Feb 7 19:48 lost+found
drwxr-xr-x 3 root root 4096 Feb 7 19:49 media
drwxr-xr-x 7 root root 4096 Feb 16 20:42 mnt
drwxr-xr-x 2 root root 4096 Feb 7 19:48 opt
dr-xr-xr-x 182 root root 0 Feb 16 16:53 proc
drwx------ 5 root root 4096 Feb 16 21:05 root
drwxr-xr-x 24 root root 780 Feb 16 16:58 run
lrwxrwxrwx 1 root root 8 Feb 7 19:48 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Feb 7 19:48 srv
dr-xr-xr-x 13 root root 0 Feb 16 16:53 sys
drwxrwxrwt 11 root root 4096 Feb 16 22:04 tmp
drwxr-xr-x 14 root root 4096 Feb 7 19:48 usr
drwxr-xr-x 12 root root 4096 Feb 7 20:14 var
lrwxrwxrwx 1 root root 28 Feb 7 19:51 vmlinuz -> boot/vmlinuz-5.10.0-21-amd64
lrwxrwxrwx 1 root root 28 Feb 7 19:49 vmlinuz.old -> boot/vmlinuz-5.10.0-20-amd64
+ cd /dev
+ echo 'cd to /dev, then ls -la'
cd to /dev, then ls -la
+ ls -la
total 4
drwxr-xr-x 17 root root 3.3K Feb 16 16:53 .
drwxr-xr-x 18 root root 4.0K Feb 16 21:19 ..
crw-r--r-- 1 root root 10, 235 Feb 16 16:53 autofs
drwxr-xr-x 2 root root 200 Feb 16 16:53 block
drwxr-xr-x 2 root root 80 Feb 16 16:53 bsg
crw------- 1 root root 10, 234 Feb 16 16:53 btrfs-control
drwxr-xr-x 3 root root 60 Feb 16 16:53 bus
drwxr-xr-x 2 root root 3.1K Feb 16 16:53 char
crw--w---- 1 root tty 5, 1 Feb 16 16:53 console
lrwxrwxrwx 1 root root 11 Feb 16 16:53 core -> /proc/kcore
crw------- 1 root root 10, 62 Feb 16 16:53 cpu_dma_latency
crw------- 1 root root 10, 203 Feb 16 16:53 cuse
drwxr-xr-x 7 root root 140 Feb 16 16:53 disk
drwxr-xr-x 3 root root 100 Feb 16 16:53 dri
crw------- 1 root root 246, 0 Feb 16 16:53 drm_dp_aux0
lrwxrwxrwx 1 root root 13 Feb 16 16:53 fd -> /proc/self/fd
crw-rw-rw- 1 root root 1, 7 Feb 16 16:53 full
crw-rw-rw- 1 root root 10, 229 Feb 16 16:53 fuse
crw------- 1 root root 10, 228 Feb 16 16:53 hpet
drwxr-xr-x 2 root root 0 Feb 16 16:53 hugepages
crw------- 1 root root 10, 183 Feb 16 16:53 hwrng
lrwxrwxrwx 1 root root 12 Feb 16 16:53 initctl -> /run/initctl
drwxr-xr-x 3 root root 280 Feb 16 16:53 input
crw-r--r-- 1 root root 1, 11 Feb 16 16:53 kmsg
crw-rw---- 1 root kvm 10, 232 Feb 16 16:53 kvm
lrwxrwxrwx 1 root root 28 Feb 16 16:53 log -> /run/systemd/journal/dev-log
crw-rw---- 1 root disk 10, 237 Feb 16 16:53 loop-control
drwxr-xr-x 2 root root 60 Feb 16 16:53 mapper
crw------- 1 root root 249, 0 Feb 16 16:53 mei0
crw-r----- 1 root kmem 1, 1 Feb 16 16:53 mem
drwxrwxrwt 2 root root 40 Feb 16 16:53 mqueue
drwxr-xr-x 2 root root 60 Feb 16 16:53 net
crw-rw-rw- 1 root root 1, 3 Feb 16 16:53 null
crw------- 1 root root 10, 144 Feb 16 16:53 nvram
crw-r----- 1 root kmem 1, 4 Feb 16 16:53 port
crw------- 1 root root 108, 0 Feb 16 16:53 ppp
crw------- 1 root root 10, 1 Feb 16 16:53 psaux
crw-rw-rw- 1 root tty 5, 2 Feb 16 2023 ptmx
drwxr-xr-x 2 root root 0 Feb 16 16:53 pts
crw-rw-rw- 1 root root 1, 8 Feb 16 16:53 random
crw-rw-r-- 1 root netdev 10, 242 Feb 16 16:53 rfkill
lrwxrwxrwx 1 root root 4 Feb 16 16:53 rtc -> rtc0
crw------- 1 root root 252, 0 Feb 16 16:53 rtc0
brw-rw---- 1 root disk 8, 0 Feb 16 16:53 sda
brw-rw---- 1 root disk 8, 1 Feb 16 16:53 sda1
brw-rw---- 1 root disk 8, 2 Feb 16 16:53 sda2
brw-rw---- 1 root disk 8, 3 Feb 16 16:53 sda3
brw-rw---- 1 root disk 8, 16 Feb 16 16:53 sdb
brw-rw---- 1 root disk 8, 17 Feb 16 16:53 sdb1
brw-rw---- 1 root disk 8, 18 Feb 16 16:53 sdb2
brw-rw---- 1 root disk 8, 19 Feb 16 16:53 sdb3
crw-rw---- 1 root disk 21, 0 Feb 16 16:53 sg0
crw-rw---- 1 root disk 21, 1 Feb 16 16:53 sg1
drwxrwxrwt 2 root root 40 Feb 16 16:53 shm
crw------- 1 root root 10, 231 Feb 16 16:53 snapshot
drwxr-xr-x 3 root root 320 Feb 16 16:53 snd
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdout -> /proc/self/fd/1
crw------- 1 root root 10, 224 Feb 16 16:53 tpm0
crw-rw-rw- 1 root tty 5, 0 Feb 16 21:13 tty
crw--w---- 1 root tty 4, 0 Feb 16 16:53 tty0
crw--w---- 1 root tty 4, 1 Feb 16 16:53 tty1
crw--w---- 1 root tty 4, 10 Feb 16 16:53 tty10
crw--w---- 1 root tty 4, 11 Feb 16 16:53 tty11
crw--w---- 1 root tty 4, 12 Feb 16 16:53 tty12
crw--w---- 1 root tty 4, 13 Feb 16 16:53 tty13
crw--w---- 1 root tty 4, 14 Feb 16 16:53 tty14
crw--w---- 1 root tty 4, 15 Feb 16 16:53 tty15
crw--w---- 1 root tty 4, 16 Feb 16 16:53 tty16
crw--w---- 1 root tty 4, 17 Feb 16 16:53 tty17
crw--w---- 1 root tty 4, 18 Feb 16 16:53 tty18
crw--w---- 1 root tty 4, 19 Feb 16 16:53 tty19
crw--w---- 1 root tty 4, 2 Feb 16 16:53 tty2
crw--w---- 1 root tty 4, 20 Feb 16 16:53 tty20
crw--w---- 1 root tty 4, 21 Feb 16 16:53 tty21
crw--w---- 1 root tty 4, 22 Feb 16 16:53 tty22
crw--w---- 1 root tty 4, 23 Feb 16 16:53 tty23
crw--w---- 1 root tty 4, 24 Feb 16 16:53 tty24
crw--w---- 1 root tty 4, 25 Feb 16 16:53 tty25
crw--w---- 1 root tty 4, 26 Feb 16 16:53 tty26
crw--w---- 1 root tty 4, 27 Feb 16 16:53 tty27
crw--w---- 1 root tty 4, 28 Feb 16 16:53 tty28
crw--w---- 1 root tty 4, 29 Feb 16 16:53 tty29
crw--w---- 1 root tty 4, 3 Feb 16 16:53 tty3
crw--w---- 1 root tty 4, 30 Feb 16 16:53 tty30
crw--w---- 1 root tty 4, 31 Feb 16 16:53 tty31
crw--w---- 1 root tty 4, 32 Feb 16 16:53 tty32
crw--w---- 1 root tty 4, 33 Feb 16 16:53 tty33
crw--w---- 1 root tty 4, 34 Feb 16 16:53 tty34
crw--w---- 1 root tty 4, 35 Feb 16 16:53 tty35
crw--w---- 1 root tty 4, 36 Feb 16 16:53 tty36
crw--w---- 1 root tty 4, 37 Feb 16 16:53 tty37
crw--w---- 1 root tty 4, 38 Feb 16 16:53 tty38
crw--w---- 1 root tty 4, 39 Feb 16 16:53 tty39
crw--w---- 1 root tty 4, 4 Feb 16 16:53 tty4
crw--w---- 1 root tty 4, 40 Feb 16 16:53 tty40
crw--w---- 1 root tty 4, 41 Feb 16 16:53 tty41
crw--w---- 1 root tty 4, 42 Feb 16 16:53 tty42
crw--w---- 1 root tty 4, 43 Feb 16 16:53 tty43
crw--w---- 1 root tty 4, 44 Feb 16 16:53 tty44
crw--w---- 1 root tty 4, 45 Feb 16 16:53 tty45
crw--w---- 1 root tty 4, 46 Feb 16 16:53 tty46
crw--w---- 1 root tty 4, 47 Feb 16 16:53 tty47
crw--w---- 1 root tty 4, 48 Feb 16 16:53 tty48
crw--w---- 1 root tty 4, 49 Feb 16 16:53 tty49
crw--w---- 1 root tty 4, 5 Feb 16 16:53 tty5
crw--w---- 1 root tty 4, 50 Feb 16 16:53 tty50
crw--w---- 1 root tty 4, 51 Feb 16 16:53 tty51
crw--w---- 1 root tty 4, 52 Feb 16 16:53 tty52
crw--w---- 1 root tty 4, 53 Feb 16 16:53 tty53
crw--w---- 1 root tty 4, 54 Feb 16 16:53 tty54
crw--w---- 1 root tty 4, 55 Feb 16 16:53 tty55
crw--w---- 1 root tty 4, 56 Feb 16 16:53 tty56
crw--w---- 1 root tty 4, 57 Feb 16 16:53 tty57
crw--w---- 1 root tty 4, 58 Feb 16 16:53 tty58
crw--w---- 1 root tty 4, 59 Feb 16 16:53 tty59
crw--w---- 1 root tty 4, 6 Feb 16 16:53 tty6
crw--w---- 1 root tty 4, 60 Feb 16 16:53 tty60
crw--w---- 1 root tty 4, 61 Feb 16 16:53 tty61
crw--w---- 1 root tty 4, 62 Feb 16 16:53 tty62
crw--w---- 1 root tty 4, 63 Feb 16 16:53 tty63
crw--w---- 1 root tty 4, 7 Feb 16 16:53 tty7
crw--w---- 1 root tty 4, 8 Feb 16 16:53 tty8
crw--w---- 1 root tty 4, 9 Feb 16 16:53 tty9
crw-rw---- 1 root dialout 4, 64 Feb 16 16:53 ttyS0
crw-rw---- 1 root dialout 4, 65 Feb 16 16:53 ttyS1
crw-rw---- 1 root dialout 4, 66 Feb 16 16:53 ttyS2
crw-rw---- 1 root dialout 4, 67 Feb 16 16:53 ttyS3
crw------- 1 root root 10, 239 Feb 16 16:53 uhid
crw------- 1 root root 10, 223 Feb 16 16:53 uinput
crw-rw-rw- 1 root root 1, 9 Feb 16 16:53 urandom
crw-rw---- 1 root tty 7, 0 Feb 16 16:53 vcs
crw-rw---- 1 root tty 7, 1 Feb 16 16:53 vcs1
crw-rw---- 1 root tty 7, 10 Feb 16 16:53 vcs10
crw-rw---- 1 root tty 7, 2 Feb 16 16:53 vcs2
crw-rw---- 1 root tty 7, 3 Feb 16 16:53 vcs3
crw-rw---- 1 root tty 7, 4 Feb 16 16:53 vcs4
crw-rw---- 1 root tty 7, 5 Feb 16 16:53 vcs5
crw-rw---- 1 root tty 7, 6 Feb 16 16:53 vcs6
crw-rw---- 1 root tty 7, 128 Feb 16 16:53 vcsa
crw-rw---- 1 root tty 7, 129 Feb 16 16:53 vcsa1
crw-rw---- 1 root tty 7, 138 Feb 16 16:53 vcsa10
crw-rw---- 1 root tty 7, 130 Feb 16 16:53 vcsa2
crw-rw---- 1 root tty 7, 131 Feb 16 16:53 vcsa3
crw-rw---- 1 root tty 7, 132 Feb 16 16:53 vcsa4
crw-rw---- 1 root tty 7, 133 Feb 16 16:53 vcsa5
crw-rw---- 1 root tty 7, 134 Feb 16 16:53 vcsa6
crw-rw---- 1 root tty 7, 64 Feb 16 16:53 vcsu
crw-rw---- 1 root tty 7, 65 Feb 16 16:53 vcsu1
crw-rw---- 1 root tty 7, 74 Feb 16 16:53 vcsu10
crw-rw---- 1 root tty 7, 66 Feb 16 16:53 vcsu2
crw-rw---- 1 root tty 7, 67 Feb 16 16:53 vcsu3
crw-rw---- 1 root tty 7, 68 Feb 16 16:53 vcsu4
crw-rw---- 1 root tty 7, 69 Feb 16 16:53 vcsu5
crw-rw---- 1 root tty 7, 70 Feb 16 16:53 vcsu6
drwxr-xr-x 2 root root 60 Feb 16 16:53 vfio
crw------- 1 root root 10, 63 Feb 16 16:53 vga_arbiter
crw------- 1 root root 10, 137 Feb 16 16:53 vhci
crw------- 1 root root 10, 238 Feb 16 16:53 vhost-net
crw------- 1 root root 10, 241 Feb 16 16:53 vhost-vsock
crw------- 1 root root 10, 130 Feb 16 16:53 watchdog
crw------- 1 root root 247, 0 Feb 16 16:53 watchdog0
prw-r----- 1 root adm 0 Feb 16 16:53 xconsole
crw-rw-rw- 1 root root 1, 5 Feb 16 16:53 zero
+ cd disk
+ echo 'cd to /dev/disk, then ls -la'
cd to /dev/disk, then ls -la
+ ls -la
total 0
drwxr-xr-x 7 root root 140 Feb 16 16:53 .
drwxr-xr-x 17 root root 3300 Feb 16 16:53 ..
drwxr-xr-x 2 root root 280 Feb 16 16:53 by-id
drwxr-xr-x 2 root root 100 Feb 16 16:53 by-partlabel
drwxr-xr-x 2 root root 100 Feb 16 16:53 by-partuuid
drwxr-xr-x 2 root root 280 Feb 16 16:53 by-path
drwxr-xr-x 2 root root 140 Feb 16 16:53 by-uuid
+ echo ' '
+ echo 'just because someone might ask, try to ls /dev/disk directly from /'
just because someone might ask, try to ls /dev/disk directly from /
+ cd /
+ ls -la /dev/disk
total 0
drwxr-xr-x 7 root root 140 Feb 16 16:53 .
drwxr-xr-x 17 root root 3300 Feb 16 16:53 ..
drwxr-xr-x 2 root root 280 Feb 16 16:53 by-id
drwxr-xr-x 2 root root 100 Feb 16 16:53 by-partlabel
drwxr-xr-x 2 root root 100 Feb 16 16:53 by-partuuid
drwxr-xr-x 2 root root 280 Feb 16 16:53 by-path
drwxr-xr-x 2 root root 140 Feb 16 16:53 by-uuid
crontab 条目:(尝试不带 env 变量,然后逐渐添加它们)
SHELL=/bin/bash
BASH_ENV="/root/.bashrc"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
USER=root
* * * * * /usr/local/bin/problem > /var/log/backup/problem.log 2>&1
crontab 的输出:(注意与大多数命令行输出的相似性,除了 /dev 内容)
++ date
+ echo 'timestamp: Fri 17 Feb 2023 08:48:01 AM CST'
timestamp: Fri 17 Feb 2023 08:48:01 AM CST
+ echo 'env values:'
env values:
+ printenv
SHELL=/bin/bash
PWD=/root
LOGNAME=root
TEMPDIR=/tmp/user/0
HOME=/root
LANG=en_US.UTF-8
TMPDIR=/tmp/user/0
USER=root
TEMP=/tmp/user/0
SHLVL=2
BASH_ENV=/root/.bashrc
TMP=/tmp/user/0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/printenv
+ whoami
root
+ cd /
+ echo 'ls -la'
ls -la
+ ls -la
total 60
drwxr-xr-x 18 root root 4096 Feb 17 00:17 .
drwxr-xr-x 18 root root 4096 Feb 17 00:17 ..
lrwxrwxrwx 1 root root 7 Feb 7 19:48 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Feb 12 20:57 boot
drwxr-xr-x 7 root root 400 Feb 16 16:53 dev
drwxr-xr-x 99 root root 4096 Feb 16 17:09 etc
d--------- 2 root root 40 Feb 16 16:53 home
lrwxrwxrwx 1 root root 31 Feb 7 19:51 initrd.img -> boot/initrd.img-5.10.0-21-amd64
lrwxrwxrwx 1 root root 31 Feb 7 19:49 initrd.img.old -> boot/initrd.img-5.10.0-20-amd64
lrwxrwxrwx 1 root root 7 Feb 7 19:48 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Feb 7 19:48 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Feb 7 19:48 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Feb 7 19:48 libx32 -> usr/libx32
drwx------ 2 root root 16384 Feb 7 19:48 lost+found
drwxr-xr-x 3 root root 4096 Feb 7 19:49 media
drwxr-xr-x 7 root root 4096 Feb 16 20:42 mnt
drwxr-xr-x 2 root root 4096 Feb 7 19:48 opt
dr-xr-xr-x 192 root root 0 Feb 16 16:53 proc
d--------- 2 root root 40 Feb 16 16:53 root
drwxr-xr-x 25 root root 800 Feb 17 00:18 run
lrwxrwxrwx 1 root root 8 Feb 7 19:48 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Feb 7 19:48 srv
dr-xr-xr-x 13 root root 0 Feb 16 16:53 sys
drwxrwxrwt 11 root root 4096 Feb 17 08:47 tmp
drwxr-xr-x 14 root root 4096 Feb 7 19:48 usr
drwxr-xr-x 12 root root 4096 Feb 7 20:14 var
lrwxrwxrwx 1 root root 28 Feb 7 19:51 vmlinuz -> boot/vmlinuz-5.10.0-21-amd64
lrwxrwxrwx 1 root root 28 Feb 7 19:49 vmlinuz.old -> boot/vmlinuz-5.10.0-20-amd64
+ cd /dev
+ echo 'cd to /dev, then ls -la'
cd to /dev, then ls -la
+ ls -la
total 4
drwxr-xr-x 7 root root 400 Feb 16 16:53 .
drwxr-xr-x 18 root root 4096 Feb 17 00:17 ..
drwxr-xr-x 2 root root 180 Feb 16 16:53 char
lrwxrwxrwx 1 root root 11 Feb 16 16:53 core -> /proc/kcore
lrwxrwxrwx 1 root root 13 Feb 16 16:53 fd -> /proc/self/fd
crw-rw-rw- 1 root root 1, 7 Feb 16 16:53 full
drwxr-xr-x 2 root root 0 Feb 16 16:53 hugepages
lrwxrwxrwx 1 root root 28 Feb 16 16:53 log -> /run/systemd/journal/dev-log
drwxrwxrwt 2 root root 40 Feb 16 16:53 mqueue
crw-rw-rw- 1 root root 1, 3 Feb 16 16:53 null
crw-rw-rw- 1 root root 5, 2 Feb 16 16:53 ptmx
drwxr-xr-x 2 root root 0 Feb 16 16:53 pts
crw-rw-rw- 1 root root 1, 8 Feb 16 16:53 random
drwxrwxrwt 2 root root 40 Feb 17 00:17 shm
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdout -> /proc/self/fd/1
crw-rw-rw- 1 root root 5, 0 Feb 16 16:53 tty
crw-rw-rw- 1 root root 1, 9 Feb 16 16:53 urandom
crw-rw-rw- 1 root root 1, 5 Feb 16 16:53 zero
+ cd disk
/usr/local/bin/problem: line 17: cd: disk: No such file or directory
+ echo 'cd to /dev/disk, then ls -la'
cd to /dev/disk, then ls -la
+ ls -la
total 4
drwxr-xr-x 7 root root 400 Feb 16 16:53 .
drwxr-xr-x 18 root root 4096 Feb 17 00:17 ..
drwxr-xr-x 2 root root 180 Feb 16 16:53 char
lrwxrwxrwx 1 root root 11 Feb 16 16:53 core -> /proc/kcore
lrwxrwxrwx 1 root root 13 Feb 16 16:53 fd -> /proc/self/fd
crw-rw-rw- 1 root root 1, 7 Feb 16 16:53 full
drwxr-xr-x 2 root root 0 Feb 16 16:53 hugepages
lrwxrwxrwx 1 root root 28 Feb 16 16:53 log -> /run/systemd/journal/dev-log
drwxrwxrwt 2 root root 40 Feb 16 16:53 mqueue
crw-rw-rw- 1 root root 1, 3 Feb 16 16:53 null
crw-rw-rw- 1 root root 5, 2 Feb 16 16:53 ptmx
drwxr-xr-x 2 root root 0 Feb 16 16:53 pts
crw-rw-rw- 1 root root 1, 8 Feb 16 16:53 random
drwxrwxrwt 2 root root 40 Feb 17 00:17 shm
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 Feb 16 16:53 stdout -> /proc/self/fd/1
crw-rw-rw- 1 root root 5, 0 Feb 16 16:53 tty
crw-rw-rw- 1 root root 1, 9 Feb 16 16:53 urandom
crw-rw-rw- 1 root root 1, 5 Feb 16 16:53 zero
+ echo ' '
+ echo 'just because someone might ask, try to ls /dev/disk directly from /'
just because someone might ask, try to ls /dev/disk directly from /
+ cd /
+ ls -la /dev/disk
ls: cannot access '/dev/disk': No such file or directory