我正在测试将程序 std_out 重定向到 docker alpine 中的 /dev/stdout 。我不知道为什么我可以从用户回显到标准输出,但不能从su
命令回显。
docker exec -it 779ddea6ec33 bash
# 根用户
bash-4.4# su - http -c "echo 1 >> /dev/stdout"
-sh: can't create /dev/stdout: Permission denied
# why comman above failed
bash-4.4# whoami
root
bash-4.4# su - root -c "echo 1 >> /dev/stdout"
1
docker exec -u http -it 779ddea6ec33 bash
#http 用户
bash-4.4$ whoami
http
bash-4.4$ echo 1 >> /dev/stdout
1
# but this command works
一些LS:
bash-4.4# ls -lad /dev/stdout
lrwxrwxrwx 1 root root 15 Jul 7 16:47 /dev/stdout -> /proc/self/fd/1
bash-4.4# ls -lad /proc/self/fd/1
lrwx------ 1 root root 64 Jul 7 18:09 /proc/self/fd/1 -> /dev/pts/0
bash-4.4# ls -lad /dev/pts/0
crw--w---- 1 root tty 136, 0 Jul 7 18:09 /dev/pts/0
统计:
bash-4.4# stat /dev/stdout
File: '/dev/stdout' -> '/proc/self/fd/1'
Size: 15 Blocks: 0 IO Block: 4096 symbolic link
Device: 4dh/77d Inode: 8013573 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-07-07 18:09:33.000000000
Modify: 2019-07-07 16:47:08.000000000
Change: 2019-07-07 16:47:08.000000000
bash-4.4# stat /dev/pts/0
File: /dev/pts/0
Size: 0 Blocks: 0 IO Block: 1024 character special file
Device: 4eh/78d Inode: 3 Links: 1 Device type: 88,0
Access: (0620/crw--w----) Uid: ( 0/ root) Gid: ( 5/ tty)
Access: 2019-07-07 18:15:28.000000000
Modify: 2019-07-07 18:15:28.000000000
Change: 2019-07-07 17:48:22.000000000