Bash: useradd: Command not found

Source: Internet
Author: User

I recently started to learn about linux Command operations and encountered problems when I used the 'useradd' command. I want to add a username command named user1, which should be 'useradd user1', but the prompt "bash: useradd: command not found" appears, finally, I found the reason for checking the information on the Internet.

First, I did not log on to the root user, but logged on to the common user. Then I switched to the root user using the 'su root' command, so this is the problem.

The 'su root' command only changes the root permission and does not change the environment variables. 'Su-root' can obtain the permissions and environment of the root user.

Make corrections now:

Bash-3.2 $ su-
Password:
[Root @ xudonglee ~] # Pwd
/Root
[Root @ xudonglee ~] #

The following is the root environment variable in this case:

/Usr/lib/qt-

3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin

:/Usr/sbin:/usr/bin:/root/bin

 

The following is the root environment variable when I simulate "su" again.

/Usr/kerberos/sbin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin

 

It should be clear now that although the two names are converted to the root user, their effects are different, so it is best to directly use the "Su-" command in the future. Although the "Su" command is easy to use, if you need to use environment variables, we need to change them again.

I recently started to learn about Linux Command operations and encountered problems when I used the 'useradd' command. I want to add a username command named user1, which should be 'useradd user1', but the prompt "Bash: useradd: Command not found" appears, finally, I found the reason for checking the information on the Internet.

First, I did not log on to the root user, but logged on to the common user. Then I switched to the root user using the 'su root' command, so this is the problem.

The 'su root' command only changes the root permission and does not change the environment variables. 'Su-root' can obtain the permissions and environment of the root user.

Make corrections now:

Bash-3.2 $ su-
Password:
[Root @ xudonglee ~] # Pwd
/Root
[Root @ xudonglee ~] #

The following is the root environment variable in this case:

/Usr/lib/Qt-

3.3/bin:/usr/Kerberos/sbin:/usr/Kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin

:/Usr/sbin:/usr/bin:/root/bin

 

The following is the root environment variable when I simulate "Su" again.

/Usr/Kerberos/sbin:/usr/lib/qt-3.3/bin:/usr/Kerberos/bin:/usr/local/bin:/usr/bin

 

It should be clear now that although the two names are converted to the root user, their effects are different, so it is best to directly use the "Su-" command in the future. Although the "Su" command is easy to use, if you need to use environment variables, we need to change them again.

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.