疑难杂症——bash: /dev/null: Permission denied

描述

在使用 Devstack 的时候需要时常切换用户su stack,此时会触发错误:

root@mickeyfan-dev:~# su stack
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied
bash: /dev/null: Permission denied

一般而言,Permission denied 问题可以通过 reset 权限 chmod 666 /dev/null 来解决,但在 Ubuntu 中,系统会自动将设备的权限还原为 420 crw--w---- 1 root tty 1, 3 Aug 26 11:46 /dev/null。所以常用的方法并不能解决该问题。

解决方案

-bash: /dev/null: Permission denied

此时,你需要删除 /dev/null 文件,并重新创建它:

rm -f /dev/null; mknod -m 666 /dev/null c 1 3

你可能感兴趣的:(疑难杂症——bash: /dev/null: Permission denied)