Bash - 添加了新用户,现在无法找到包

Dav*_*ton -1 bash

有人可以向我解释一下吗?为什么当通过 root 登录时,我可以发出ifconfig并执行。在创建新用户后,我发出ifconfig无法找到包的问题。

Bash 输出

user@hostname:~$ ifconfig
bash: ifconfig: command not found
user@hostname:~$ locate ifconfig
/sbin/ifconfig
user@hostname:~$ /sbin/ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.121  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::ba27:ebff:fe2e:b2d  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:2e:0b:2d  txqueuelen 1000  (Ethernet)
        RX packets 2476  bytes 228711 (223.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1942  bytes 275732 (269.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Run Code Online (Sandbox Code Playgroud)

我认为区别在于,是特权吗?即 sbin - 根要求

仅在我的某些系统上,我可以在不需要 Sudo 的情况下发出 ifconfig。

那么为什么只指定路径 sbin 就可以执行真正需要 root 权限的东西呢?

有点困惑,还是我的用户通过允许 sbin 执行而配置不正确?

第一个基于 Debian 的系统(我是一名 Arch 用户,以前从未遇到过这种情况)

Ste*_*itt 6

这是由默认值引起的PATHroot的默认PATH包含/sbin,标准用户的默认PATH不包含。比较/etc/profile/root/.profile...的内容