Sudo and su

Source: Internet
Author: User
Sudo and su-general Linux technology-Linux technology and application information. The following is a detailed description. You may have seen one of these two commands. Ubuntu users are more familiar with sudo, while SUSE, Fedora and Debian users are more commonly used with su commands. What are the differences between the two commands?

Both commands allow you to get the root permission. The difference between the two lies in how to obtain this permission.

Su

Su (abbreviation of switch user) is used to open a shell or logon interface as another user. When this command is run without any parameters, the su command assumes that you want to be the root. When you run this command, you will be prompted to enter the password. The entered password is the password of the user you want to switch. For example, if I want to become a root user and run su on the terminal, I need to enter the password of the root user. If I run su bill, I need to enter the password of bill.

After a password is entered, a new shell will appear, just like you are logged on with the su user name. Any command you run from it will be considered as a user from the su.

Sudo

In a Ubuntu system, running su directly to become root will not produce any results. By default, the root user does not have an available password, so you cannot enter a password to obtain permissions. In this case, sudo is useful. The sudo command allows you to run a command (usually a root user) as another user ).

The main difference is that the password you need to enter is your own account password, rather than other users. This allows multiple administrators on a system to not share a password. When running sudo-s, a shell with the root permission will be opened, which is the same as running su.

Combining the Two

In most cases, su exists on any system even if it cannot be used directly. Sudo, unlike this, usually only exists in Debian or its derivative release. Because of this, we can do some tricks on a Ubuntu system:

Sudo su # the same effect as sudo-s

In the preceding example, use the sudo command to obtain the root permission. Therefore, the su command runs under the root user permission. In this way, the su command does not require a password, but the password of the current user required by the sudo command), which can also be used as an alternative to sudo-s.

Another example:

Sudo su bill # the same effect as sudo-s-u bill

This command will get a shell as user bill. Once again, you only need to enter your own password.

There are still a lot of tips for using sudo and su, And the rest should be discovered by yourself.

From http://cnyegle.spaces.live.com/Blog/cns! 7F95890C0E67568D! 567. entry

[ This post was last edited by Mysdwn]
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.