linux找不到root用户,Ubuntu中root用户没有办法使用命令

lin@lenovo:~$ su - root

口令:

Command 'mesg' is available in '/usr/bin/mesg'

The command could not be located because '/usr/bin' is not included in the PATH environment variable.

-su: mesg:找不到命令

root@lenovo:~# gedit /etc/profile

Command 'gedit' is available in '/usr/bin/gedit'

The command could not be located because '/usr/bin' is not included in the PATH environment variable.

-su: gedit:找不到命令

root@lenovo:~# useradd yul

Command 'useradd' is available in '/usr/sbin/useradd'

The command could not be located because '/usr/sbin' is not included in the PATH environment variable.

This is most likely caused by the lack of administrative priviledges associated with your user account.

-su: useradd:找不到命令

root@lenovo:~# vi

Command 'vi' is available in '/usr/bin/vi'

The command could not be located because '/usr/bin' is not included in the PATH environment variable.

-su: vi:找不到命令

问题分析及解决办法:

这主要是路径问题,先查看$PATH变量的设置。

echo $PATH

里面的格式是xxx:xxx:xxx:xxx

这应该没包含/usr/bin这个路径。

执行下面命令就可以将这个路径包含进去:

export PATH=/usr/bin/:$PATH

如果要想每次登陆系统的时候,都自动包含这个路径,

可以把刚才这个命令加入到/root/.bash_profile或者/root/.bashrc文件的后面。

具体如下:

退回到普通用户(我的普通用户是lin)

lin@lenovo:~$ sudo gedit /root/.bash_profile

添加export PATH=/usr/bin/:$PATH,保存关闭.bash_profile文件

lin@lenovo:~$ su - root

口令:

root@lenovo:~# echo $PATH

/usr/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@lenovo:~# env

SHELL=/bin/bash

TERM=xterm

XDG_SESSION_COOKIE=f591adb565a6ba1bc40f9e954a26895b-1255053756.679619-1536901825

USER=root

MAIL=/var/mail/root

PATH=/usr/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

PWD=/root

LANG=zh_CN.UTF-8

SHLVL=1

HOME=/root

LANGUAGE=zh_CN:zh

LOGNAME=root

_=/usr/bin/env

root@lenovo:~# vi

就可进行vi编辑了。0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值