Linux_su: commandnotfounderror

Source: Internet
Author: User
Linux_su: commandnotfounderror-Linux general technology-Linux programming and kernel information. For details, refer to the following section. In linux, I found a problem. When I use the su command to become a Super User, some commands of the management system, such as shutdown, will give me a "bash: shutdown: command not found ". according to the general idea of solving the problem:

First, this command must exist and cannot be found. It is estimated that the path is incorrect. First, I checked the shutdown command location:/sbin/shutdown, then there is the Super User's search path: (you can get it through the environment variable)

Env:

PATH =/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/X11R6/bin: /home/xishan/bin

After switching to the root user, I checked the environment variables of the root user:

PATH =/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

Obviously, the environment variables of super su users vary greatly. How can we get the root environment variables?

Does su have other usage? man su, read it.

Su [OPTION]... [-] [USER [ARG]...]

-,-L, -- login

Make the shell a login shell

It should be su-root/su-l/su -- login to log on as the root user.

The problem has been solved.

However, I have used the NETBSD system before. When using the su command, I can also use shutdown instead of other commands. These two system kernels are similar, should I be able to modify the environment variables for the purpose?

Vi ~ /. Bashrc

Added an export PATH = $ PATH:/sbin

After restarting, run the su command to access the Super User and check the environment variables,

PATH =/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/X11R6/bin: /home/xishan/bin:/sbin

Added successfully, and then tested: shutdown, OK. You can use su directly next time.
Related Article

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.