centos 程序员 开源 mysql 编程 Firefox wordpress Android Ubuntu 云计算 Windows java nginx php linux Python google shell 微软 apache

疑難雜癥——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

延伸阅读

    评论