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 are the usage and differences of Linux commands su, sudo, sudo su, sudo-I

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "how to use Linux commands su, sudo, sudo su, sudo-I and what are the differences?". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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 directly runs the sudo command with the-I parameter, which requires that the user who executes 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 content of "Linux commands su, sudo, sudo su, sudo-I usage and differences". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report