解决方法

  • 原因是 /dev/null 设备可能被常规文件替换了,重新创建即可

方法一

  • 重启就好了,重启后该设备会自动重新创建

方法二

  • 手动重新创建该设备
1
rm -f /dev/null; mknod -m 666 /dev/null c 1 3
  • 重建之后看起来就正常了
1
2
3
4
5
Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease
Hit:2 http://mirrors.tencentyun.com/ubuntu focal-security InRelease
Hit:3 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease
Hit:4 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu focal InRelease
Reading package lists... Done

问题表现

这一大堆,我也懒得看…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
❯ apt update
Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease
Hit:2 http://mirrors.tencentyun.com/ubuntu focal-security InRelease
Hit:3 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease
0% [Connecting to ppa.launchpad.net (91.189.95.85)]gpgv: Signature made Fri Apr 24 01:34:17 2020 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) "
gpgv: Signature made Fri Apr 24 01:34:17 2020 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) "
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
0% [Connecting to ppa.launchpad.net (91.189.95.85)]gpgv: Signature made Tue Nov 2 05:30:01 2021 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) "
gpgv: Signature made Tue Nov 2 05:30:01 2021 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) "
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
0% [Waiting for headers]gpgv: Signature made Tue Nov 2 05:30:35 2021 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) "
gpgv: Signature made Tue Nov 2 05:30:35 2021 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) "
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
Hit:4 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu focal InRelease
0% [Working]gpgv: Signature made Sun Oct 24 03:17:20 2021 CST
gpgv: using RSA key 9EA4D6FCA5D37A5D1CA9C09AAD5F235DF639B041
gpgv: Good signature from "Launchpad PPA for Alessandro Strada"
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
Reading package lists... Done

Ref

  • https://unix.stackexchange.com/questions/146633/bash-dev-null-permission-denied