(summary) The essential difference between Su and Su-commands under Linux

Source: Internet
Author: User

I have been accustomed to direct use of root, rarely use Su, only a few days ago found Su and Su-command is an essential difference!

The default accounts for most Linux distributions are normal users, and changing the system files or executing certain commands requires root, which requires switching from the current user to the root user. The commands for switching users in Linux are Su or Su-. The day before yesterday when I used the useradd command, I realized the essential difference between the two.

650) this.width=650; "width=" 356 "height=" "title=" su "class=" Alignnone size-full wp-image-4002 "style=" margin:5px 0px;padding:3px;border:1px solid RGB (206,212,202); "src=" http://www.ha97.com/wp-content/uploads/2011/04/su.jpg "/

I first switched to root with the SU command, but when I ran Useradd, there was an error: Bash:useradd:command not found. Google for a bit, because of this with the SU command to switch over the root user.

SU command and the Su-command is that the former simply switches the root identity, But the shell environment is still a normal user's shell, and the user and the shell environment are switched to root. The PATH environment variable error does not occur unless you switch the shell environment. After the SU switch to the root user, PWD, found that the working directory is still the normal user's working directory, and after the Su-command switch, the working directory becomes the working directory of root. Use the echo $PATH command to see how the Su and Su-future environment variables are different. And so on, to switch from the current user to another user, you should use the Su-command.

650) this.width=650; "Width=" 654 "height=" 304 "title=" Su-"class=" Alignnone size-full wp-image-4003 "style=" margin:5px 0px;padding:3px;border:1px solid RGB (206,212,202); "src=" http://www.ha97.com/wp-content/uploads/2011/04/su-.jpg "/ >

Linux is like this, sometimes the configuration file more or less a space, the service will not run. Details must pay attention to, so as to less detours!

(summary) The essential difference between Su and Su-commands under Linux

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.