我有一个通过 SSH 访问的 VPS。更新到 Debian 10 后,通过 ssh 以 root 身份登录时,我无法再运行 root 命令(我已经重新启动)。使用主机的 VNC 连接控制台进行访问时,一切正常。
作为示例,iptables
但这对所有命令都有效。
marius:/home/afh whoami
root
marius:/home/afh iptables
zsh: command not found: iptables
marius:/home/afh apt-get install iptables
Reading package lists... Done
Building dependency tree
Reading state information... Done
iptables is already the newest version (1.8.2-4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我已尝试按照建议重新安装关于这个答案:
marius:/home/afh apt-get --reinstall install iptables
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 399 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://cdn-fastly.deb.debian.org/debian buster/main amd64 iptables amd64 1.8.2-4 [399 kB]
Fetched 399 kB in 0s (1,162 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 1.)
debconf: falling back to frontend: Readline
(Reading database ... 327810 files and directories currently installed.)
Preparing to unpack .../iptables_1.8.2-4_amd64.deb ...
Unpacking iptables (1.8.2-4) over (1.8.2-4) ...
Setting up iptables (1.8.2-4) ...
Processing triggers for man-db (2.8.5-2) ...
localepurge: Disk space freed in /usr/share/locale: 0 KiB
localepurge: Disk space freed in /usr/share/man: 0 KiB
Total disk space freed by localepurge: 0 KiB
marius:/home/afh iptables -L
zsh: command not found: iptables
marius:/home/afh whoami
root
marius:/home/afh echo $PATH
/root/.bin:/home/afh/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
bash 也失败了:
root@marius:/home/afh# iptables -L
bash: iptables: command not found
答案1
你还没告诉我们你是怎样变成的root
。
如果你正在使用普通版本su
,那么升级到 Buster 会破坏它 — — 实际上它修复了它,因为它已经损坏了 ;-)
这个想法是,su
现在不再使用PATH
来自目标用户环境(root
在您的情况下)和PATH
普通用户的环境不包含/sbin
和/usr/sbin
目录,这就是为什么/usr/sbin/iptables
无法使用其未修饰的(短)名称进行访问。
快速解决方法是使用su -
强制该程序切换到“登录”模式。
看这了解更多信息。