终端启动时给出错误 bash: /usr/bin/lesspipe

终端启动时给出错误 bash: /usr/bin/lesspipe

我搜索并阅读了这里所有可能的页面,但找不到确切的问题。

当我打开终端时,我得到了:

bash: /usr/bin/lesspipe: /bin/sh: bad interpreter: No such file or directory

然后当我使用时apt-get update出现以下错误。

Fetched 39,9 MB in 53s (747 kB/s)                                              
Reading package lists. . .  Done
W: GPG error: http://archive. canonical.com/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: The repository 'http://archive.canonical.com/ubuntu xenial InRelease' is not signed. 
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. 
N: See apt-secure(8) manpage for repository creation and user configuration details. 
W: GPG error: http://ppa.launchpad.net/nijel/phpmyadmin/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
.......
W: The repository 'http://us.archive.ubuntu.com/ubuntu xenial-security InRelease' is not signed. 
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. 
N: See apt-secure(8) manpage for repository creation and user configuration details. 
E: Problem executing scripts APT::Update::Post-Invoke-Success 'touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true'
E: Sub-process returned an error code




$ namei -lx /bin/sh
f: /bin/sh
Drwxr-xr-x root root /
drwxr-xr-x root root bin
                     sh - No such file or directory

有人知道为什么会发生此错误以及如何解决它?

答案1

由于某种原因,您没有/bin/sh。这可能意味着系统中的很多东西也可能出错,但仅针对这个特定问题,您可以重新创建符号链接:

sudo ln -s /bin/dash /bin/sh

如果/bin/sh存在,但是有问题,请执行以下操作:

sudo ln -sf /bin/dash /bin/sh

答案2

我在 Windows 10 Pro Bash for Windows 上解决了我的问题。我选择了 Ubuntu 18.04 LTS。

症状:打开 Ubuntu shell 时收到错误消息“bash: /usr/bin/lesspipe: /bin/sh: bad interpretationr: No such file or directory”。安装时没有立即出现此错误,但在我重新启动 Windows(版本 10.0.18363)后出现。

我追踪到问题出在 /bin/dash 上,但它并不存在。我使用以下方法修复了这个问题:

# use bash as a temporary dash
cd /bin
sudo cp bash dash
# reinstall dash
sudo apt-get install --reinstall dash

相关内容