linux ifconfig 无法使用 bash: ifconfig: command not found
来源:互联网 发布:制作婚礼照片软件 编辑:程序博客网 时间:2024/06/05 06:25
转自http://blog.csdn.net/xiaosong521/article/details/7519002
初学Linux,总是有许多问题,这次就遇到了这个问题:
问题描述:
之前ifconfig命令是可以使用的,但是我有事离开了一段时间,又回来之后,发现虚拟机的ip地址不对,想使用ifconfig命令查看一下,结果发现ifconfig命令无法使用,总是显示找不到ifconfig这个命令。然后我切换到管理员账户,发现ifconfig还是无法使用。
问题查找:
没办法,只好寻求百度的帮助,发现也有许多人遇到这个问题,当然,这个问题也是可以很好解决的。
1.可以使用/sbin/ifconfig,说明ifconfig是可以使用的,原因是因为系统的环境变量设置不对。
2.可以执行echo $PATH命令查看PATH里的路径,发现少了/sbin这个路径,所以系统默认是找不到ifconfig的。
3.也可以使用which ifconfig命令看能否查找到ifconfig的路径,如果无法查找到,说明系统默认的环境变量是没有ifconfig 的路径的,需要把ifconfig的路径加上去。
解决方法:
1.可以切换到root账户,切换的时候执行su - root命令,便可以直接使用ifconfig命令了,原因是因为单纯使用su root 是不会读取root用户设置的私有文件的。(这个方法比较有意思)
2.就是比较原始的方法了,使用/sbin/ifconfig来代替ifconfig。
3.可以在PATH下加上/sbin的路径。使用root账户,可以vi /etc/profile,在文件末尾加上以下语句:
PATH=$PATH:/sbin #在PATH变量后追加/sbin目录
export PATH=$PATH:/sbin#设置变量为全局的
然后保存并退出,就可以直接使用ifconfig了。
4.如果是其他用户的话,可以修改/home/用户/.bash_profile,在PATH后面添加/sbin:/usr/sbin:/usr/local/sbin:/usr/kerberos/sbin这几个路径。然后执行命令:. .bash_profile,也可以注销下或者重启才能使刚刚修改的内容生效。再来sudo ifconfig , 就可以了。(这个方法没有试过)
参考资料:
http://www.233.com/linux/fudao/20100921/141130183.html
http://blog.csdn.net/yiyaaixuexi/article/details/6113144
http://topic.csdn.net/u/20111216/22/75c30222-abae-4ec3-a6f5-0c853e235746.html
- linux ifconfig 无法使用 bash: ifconfig: command not found
- ifconfig命令无法找到,提示bash: ifconfig: command not found
- Linux 提示:“bash: ifconfig: command not found”
- Linux - bash : ifconfig command not found
- linux -bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- -bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- bash: ifconfig: command not found
- Linux ifconfig command not found
- Linux关于bash:ifconfig command not found 解决方法
- 解决bash: ifconfig: command not found
- 计算机基础进制转换
- 结构体指针怎么用
- 常用浏览器兼容问题
- 欢迎大家提意见
- $.mobile.changePage
- linux ifconfig 无法使用 bash: ifconfig: command not found
- Linux在应用层读写寄存器的方法
- 算法学习-天平与假币
- 2016.11.22回顾
- spring @ModelAttribute 注解
- mysql5.7安装过程中的问题
- 12.zabbix学习笔记:zabbix监控之邮件报警
- API导出EXCEL删除报表某一行或列
- 使用google authenticator打造运维平台的动态口令