解决 Debian 非特权用户无法使用 ifconfig

如何配置让 Debian 非特权用户也可以使用 ifconfig 。

ifconfig 在 /sbin 目录下,新建一个用户时, Debian 默认从 /etc/skel/ 复制配置文件,

/sbin 并不在 $PATH 中,所以导致默认非特权用户无法使用 ifconfig (terminal 会提示说找不到该命令)。

解决方法:

在 ~/.profile 修改 $PATH 环境变量,在末尾加上一行

export PATH=$PATH:/sbin

或者,修改 /etc/skel/.profile,这个会影响所有新创建的用户。

(完)

Read More:

20 Comments

  1. 1 Mucid Commented @ 2011-10-02 10:50Reply to this comment

    直接绝对路径么。。

  2. 2 fcicq Commented @ 2011-10-02 10:54Reply to this comment

    接上: alias ifconfig="/sbin/ifconfig", 哈哈哈

  3. 3 Mucid Commented @ 2011-10-02 10:57Reply to this comment

    我记得centos是大部分都无法直接用。

  4. 4 jmw778s Commented @ 2011-10-02 11:09Reply to this comment

    “这个会影响所以新创建的用户。”不懂什么意思

  5. 5 Shao Hao Commented @ 2011-10-02 11:14Reply to this comment

    现在用ip addr 了吧?

  6. 6 thorne Commented @ 2011-10-02 11:17Reply to this comment

  7. 7 Iven Commented @ 2011-10-02 11:43Reply to this comment

  8. 8 lee Commented @ 2011-10-02 12:24Reply to this comment

    @jmw778s:

    因为/etc/skel/.profile会在创建用户的时候被复制到用户的主目录。修改那个会影响新用户而不会影响老用户——老用户已经复制过这个文件了。

    不管是改path或者是alias 修改的都是bash的profile,已经拷贝过去的当然没有办法……你准备让所有用户的profile内容丢失吗

  9. 9 自由建客 Commented @ 2011-10-02 15:05Reply to this comment

    @@ -1,11 +1,11 @@ # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

    -if [ "id -u" -eq 0 ]; then +#if [ "id -u" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -else - PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" -fi +#else +# PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" +#fi export PATH

    if [ "$PS1" ]; then

  10. 10 自由建客 Commented @ 2011-10-02 15:05Reply to this comment

    汗!不能发多行数据? /etc/profile 前面几行,昭然若揭。

  11. 11 Heiher Commented @ 2011-10-02 16:51Reply to this comment

    嘿嘿,对于这个命令我也是每次都绝对路径的。

  12. 12 Liang Guo Commented @ 2011-10-02 16:55Reply to this comment

    我的习惯是在需要使用超级用户命令的用户的目录下建立一个bin目录,在bin目录中建立连接指向/sbin目录下的对应命令。 如果给所有用户的PATH中添加/sbin,自动完成是会出现许多不应有的东西

  13. 13 Cravix Commented @ 2011-10-02 21:50Reply to this comment

    连这种常识也能上linuxtoy了吗...wtf.

  14. 14 Kevin W Commented @ 2011-10-02 23:16Reply to this comment

    有点无语,给新人个机会?TOY

  15. 15 wolfman.wu Commented @ 2011-10-03 0:35Reply to this comment

    作者及给出自己使用经验的跟帖都充满智慧,非常感谢!

  16. 16 Joey64 Commented @ 2011-10-03 10:48Reply to this comment

    /sbin/ifconfig 就可以了,何必修改

  17. 17 henrylj2g Commented @ 2011-10-03 12:45Reply to this comment

    确实是常识。。。我以为debian大过节的出了什么事呢。

  18. 18 PWD Commented @ 2011-10-03 13:15Reply to this comment

    这需要“解决”吗

  19. 19 freedrive Commented @ 2011-10-03 19:18Reply to this comment

    对我们这样的debian新手绝对有用,嘿嘿

  20. 20 atom Commented @ 2011-10-08 18:35Reply to this comment

    这篇没什么营养 :(