Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between su, sudo, sudo su and sudo-I?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces su, sudo, sudo su, sudo-I what is the difference between the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe you read this su, sudo, sudo su, sudo-I what differences the article will have a harvest, let's take a look at it.

The biggest difference between the sudo and su commands is:

The sudo command requires the password of the current user, and the su command requires the password of the root user. Another difference is its default behavior. The sudo command only allows you to run a single command with elevated privileges, while the su command starts a new shell and allows you to run as many commands as possible with root privileges until you explicitly log out.

Su is used to switch to the identity of different users.

By default, you only switch identities, not environment variables, which are still for ordinary users. When switching user identity, the user's environment variable is also switched to the new user's environment variable, so "-" can not be omitted, otherwise some operations cannot be performed.

Su root changes the root user after entering the root password, but the pwd directory remains unchanged.

Su-root changes the root user after entering the root password, but pwd directory / root

Sudo usually adds commands.

Sudo-I root has the same effect as sudo-root, sudo-I, sudo -, sudo root. When the password is prompted, the password is the password of the current account. The user who executes the command must be in sudoers to su. The secret usage of the switched account is "su account name".

Sudo: temporarily switch to superuser mode to perform superuser privileges, which generally refers to the root user. When prompted for a password, the password is the password of the current user, not the password of the superaccount. However, there is a time limit, and Ubuntu defaults to 15 minutes at a time.

Su: switch to the user mode of so-and-so. When prompted for a password, the password is the password of the account after the switch, and the usage is "su account name". If no account is added, the system defaults to the root account, and the password is also the password of the super account. There is no time limit.

Sudo-I: this command can be used to frequently execute certain permissions that only superusers can execute without having to enter a password every time. When prompted for a password, the password is the password of the current account. There is no time limit. After executing the command, the prompt changes to "#" instead of "$". You can execute "exit" or "logout" when you want to return your regular account. The user who is required to execute the command must be in sudoers

Sudo-I runs the sudo command directly with the-I parameter requiring that the user executing the command must be in sudoers

Sudo su runs the sudo command to lift the weight of the su command, and runs the su command. The user who is required to execute the command must be in sudoers.

This is the end of the article on "what's the difference between su, sudo, sudo su and sudo-I". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what's the difference between su, sudo, sudo su and sudo-I". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report