LoginSignup
2
2

More than 5 years have passed since last update.

-bash: /dev/null: Permission denied と出たときの対策

Last updated at Posted at 2018-02-12

誤操作でrm -f /dev/null などとしてしまうと、
ファイル自体は存在したままだが、ファイルのパーミッション(属性)が変更され、デバイスファイルでなくなるので、エラーが出る。

MAKEDEV で再作成してやることで、復旧する。


$ rm -rf /dev/null 

$ ls -l /dev/null 
# パーミッションの先頭がcではなく、-になっている
# cはスペシャルファイルを示し、デバイスファイルには基本的にcがつく
-rw-r--r-- 1 root root 0 Jan 24 03:57 /dev/null

# デバイスファイルの再作成を実施
$ /sbin/MAKEDEV /dev/null

$ ls -l /dev/null 
crw-rw-rw- 1 root root 1, 3 Jan 24 03:59 /dev/null

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2