The root user in Ubuntu cannot use the command

Source: Internet
Author: User
Lin @ lenovo :~ $ Su-root Password: Command 'mesg' isavailablein '/usr/bin/mesg' Thecommandcouldnotbelocatedbecause'/usr/bin' failed.-su: mesg: Command root @ lenov not found

Lin @ lenovo :~ $ Su-root
Password:
Command 'mesg' is available in '/usr/bin/mesg'
The command cocould not be located because '/usr/bin' is not supported ded in the PATH environment variable.
-Su: mesg: Command not found
Root @ lenovo :~ # Gedit/etc/profile
Command 'gedit 'is available in'/usr/bin/gedit'
The command cocould not be located because '/usr/bin' is not supported ded in the PATH environment variable.
-Su: gedit: Command not found
Root @ lenovo :~ # Useradd yul
Command 'useradd' is available in'/usr/sbin/useradd'
The command cocould not be located because '/usr/sbin' is not supported in the PATH environment variable.
This is most likely caused by the lack of administrative priviledges associated with your user account.
-Su: useradd: The command cannot be found.
Root @ lenovo :~ # Vi
Command 'vi' is available in '/usr/bin/vi'
The command cocould not be located because '/usr/bin' is not supported ded in the PATH environment variable.
-Su: vi: Command not found

Problem Analysis and Solution:

This is mainly about the PATH. First, check the setting of the $ PATH variable.
Echo $ PATH
The format is xxx: xxx
This should not contain the path/usr/bin.
Run the following command to include the path:
Export PATH =/usr/bin/: $ PATH
If you want to automatically include this path every time you log on to the system,
You can add this command to the end of the/root/. bash_profile or/root/. bashrc file.

The details are as follows:
Return to normal user (my normal user is lin)
Lin @ lenovo :~ $ Sudo gedit/root/. bash_profile
Add export PATH =/usr/bin/: $ PATH and save the close. bash_profile file.
Lin @ lenovo :~ $ Su-root
Password:
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
You can edit the vi.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.