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

How to switch users by Linux

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

Share

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

This article mainly introduces the relevant knowledge of Linux how to switch users, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will gain something after reading this Linux how to switch users article, let's take a look at it.

The command to switch users is that su,su is the abbreviation for (switch user) switching users. With the su command, you can switch from an ordinary user to a root user, or from a root user to an ordinary user. A password is required to switch from an ordinary user to a root user (this password is the password of an ordinary user), and no password is required to switch from a root user to an ordinary user.

Step 1: open SecureCRT:

Xiaoyu: the user name of the current user represented

Bogon: is the name of the host (this can also be changed)

~: represents the current directory

$: is the meaning of the ordinary user (if the root user is displayed #) the second step: switch from the ordinary user to the root user (where the switching order does not matter), enter it at the terminal

Enter: su then enter, ask for a password (the password entered by the linux terminal does not seem to be displayed) enter the password and enter the root user.

To return to the normal user, I typed exit.

Or enter "su root" at the terminal and enter, and enter the root.

Enter su-root, and you can also switch root users. There are some differences:

Check it out:

What's the difference between su root and su-root?

If the user is not added after su, it is switched to root by default.

Su does not change the current variable

Su-is a variable that is changed to switch to the user

In other words, su can only get the execution permission of root, but not the environment variable, while su-switches to root and gets the environment variable and execution permission of root.

Syntax:

$su [user_name]

The su command can be used to interactively change your user ID and group ID. Su is an abbreviation for switch user or set user id. This command allows you to start a subprocess, become the new user ID and give you access to all files associated with that user ID. Therefore, for security reasons, you will be asked to enter the password of this user account when you actually change your identity.

If there are no parameters, the su command converts you to root (system administrator). The root account is sometimes called a superuser because this user can access any file in the system. For this reason, many people see the su command as an acronym for supper-user. Of course, you must provide the root password. To get back to your original user identity, instead of using the su command, you just need to use the exit command to exit the new conversation process that you generated using the su command.

$su-username

Some profiles are set up for your conversation clues. When you use the command su username, your conversation characteristics are the same as your original login identity. If you want your conversation process to have the same characteristics of the converted user ID, you should use a short slash: su-username.

Bash: groupadd: command not found

Today, when installing MYSQL, create a new database user.

# groupadd mysql

The result indicates that bash: groupadd: command not found

Is my variable wrong? How could the system not find the command groupadd.

And then I thought about it. Turns out it's su's fault.

Before, it was under the ordinary user. Switch directly from SU to ROOT user.

Quit and switch to SU-just switch to the ROOT user.

Su can only switch to administrator user rights without using administrator login scripts and search paths

Su-not only can you switch to administrator privileges but also use administrator login scripts and search paths

Use su-environment variables follow ~

This is the end of the article on "how to switch users on Linux". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to switch users in Linux". If you want to learn more knowledge, 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