In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the su command in the linux system. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
1. Command function
The role of su is to change to the identity of another user, except for a superuser, whose password needs to be typed.
two。 Mode of use
Su [- fmp] [- c command] [- s shell] [--help] [--version] [-] [USER [ARG]]
3. Parameter description
-f,-fast: no need to read startup files (such as csh.cshrc, etc.), only for csh or tcsh Shell.
-l,-login: after adding this parameter, it is like logging back in. Most of the environment variables (such as HOME, SHELL, USER, etc.) are based on the USER, and
And the working directory will change. If USER is not specified, the default is root.
-m,-p,-preserve-environment: the environment variable is not changed when su is executed.
-c command: the user whose account number is changed to USER, and then change back to the original user after executing the command.
-help display instruction file
-version displays version information
USER: the user account to be changed
ARG: pass in a new Shell parameter.
4. Examples
Su-c ls root changes the account to root and exits to change back to the original user after executing the ls instruction.
Su [user name]
A > under root users, enter su ordinary users. Then switch to ordinary user, and no password is required to switch from root to flexible user.
B > under ordinary users, enter su [user name]
Prompt password:
Enter the PASSWORD of the user, then switch to that user
Extended Reading 1: what is the difference between the su command and the su-command under Linux?
Su switches to other users, but does not switch environment variables (for example, if you check the export commands, you can see the difference between the two commands)
Su-is a complete switch to a user environment
Therefore, it is recommended that when switching users, try to use su-linuxso, otherwise you may find that some commands cannot be executed.
Extended Reading 2: the difference between su and sudo
Because su has no restrictions on permissions after switching to the super privilege user root, su cannot serve as a system managed by multiple administrators. If you use su to switch to the superuser to manage the system, it is not clear what work is done by which administrator. Especially when there are many people involved in the management of the server, it is best to focus on the technical expertise and management scope of each administrator, and delegate authority pertinently, and agree on which tools they use to complete their related work, then we need to use sudo.
Through sudo, we can delegate some super permissions pertinently, and do not need ordinary users to know the root password, so sudo is relatively secure compared to su with unrestricted permissions, so sudo can also be called restricted su. In addition, sudo requires authorization, so it is also called su of authorization.
The flow of sudo command execution is that the current user switches to root (or other designated user), and then executes the command as root (or other designated user). After execution, the command is returned directly to the current user. The premise of these is that authorization is carried out through the sudo configuration file / etc/sudoers.
On how to use the su command in the linux system to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.