Analysis of the difference between Su,su-,sudo

Source: Internet
Author: User
Tags creative commons attribution root access

Parsing the difference between Su,su-,sudo warm Color

Someone must not know the difference between the following two commands,

1 [[email protected] ~]$ su
1 [[email protected] ~]$ su- ##(有个减号)

What is the difference between the two commands below?

1 [[email protected] ~]$ su
1 [[email protected] ~]$ sudosu

First, SU,SU-both commands have root access,

But the root of the password is not to be handed over to others, then you need sudo command,

Use the user's own password, temporarily give the general user root privileges,

The process of sudo is this:

    1. Check if the user is in the list of/etc/sudoers,
    2. If the command is executed with root privileges,
    3. Remove root of user

Then tell me the difference between the three commands:

The following is the SU process:

0102030405060708091011 [[email protected] ~]$ su密码: [[email protected] warmcolor]# pwd/home/warmcolor[[email protected] ~]# echo $PATH/usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/warmcolor/bin

The following is the Su-process:

0102030405060708091011 [[email protected] ~]$ su -密码:[[email protected] ~]# pwd/root[[email protected] ~]# echo $PATH/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

The following is the process of sudo:

123456789 [[email protected] ~]$ sudo pwd[sudo] password for warmcolor:/home/warmcolor[[email protected] ~]$ sudo echo $PATH/usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/warmcolor/bin

It can be seen that Su and sudo do not switch working directory and environment variables, but only give user permissions,

And Su-is really switch to root login, working directory switch to/root, environment variable also change.

And there is a statement on the web, sudo defaults to the original environment variable reset, only some of the security has no effect on the setting.

As for the second question above, the answer is actually very simple,

Also switch to root login,

SU uses the root password, and sudo su uses the user password.

See the Man Manual for a more specific description of the above command.

Original link: http://blog.warmcolor.net/?p=3542
Reproduced this site article please specify, reproduced from: warm tone [http://blog.warmcolor.net]
This work uses: Creative Commons Attribution-NonCommercial use-Share 4.0 International license agreements in the same way.

Analysis of the difference between Su,su-,sudo

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.