In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to use su in linux". In the operation of actual cases, many people will encounter such a dilemma, so 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!
In linux, su is an acronym for "switch user", meaning to switch a user. The su command is used to change the identity of another user with the syntax "su option [USER [user]]". When using this command, you need to type the user's password except root.
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What does su mean in linux
The Linux su (English spelling: switch user) command is used to change the identity of another user. In addition to root, you need to type the user's password.
Permissions: all users.
Grammar
Su [- fmp] [- c command] [- s shell] [--help] [--version] [-] [USER [ARG]]
Parameter description:
-f or-- fast do not need to read the startup file (such as csh.cshrc, etc.) and are only used for csh or tcsh
The environment variable is not changed when-m-p or-- preserve-environment executes su
-c command or-- command=command is changed to the user with the account number USER and executes the instruction (command) and then changes back to the original user.
-s shell or-- shell=shell specify the shell (bash csh tcsh, etc.) to be executed. The default value is the user (USER) shell in / etc/passwd.
-- help display description file
-- version displays version information
After the parameter-- l or-- login is added, it is like re-login to the user. Most of the environment variables (HOME SHELL USER, etc.) are based on the user (USER), and the working directory will also change. If USER is not specified, it will be root.
User account number to be changed by USER
ARG passes in a new shell parameter
Example
Change the account to root and exit and change back to the original user after executing the ls instruction
Su-c ls root
Change the account to root and pass the-f parameter to the newly executed shell
Su root-f
Change your account to clsung and change your working directory to clsung's home directory (home dir)
Su-clsung
Switch users
Hnlinux@runoob.com:~$ whoami / / Show current user hnlinuxhnlinux@runoob.com:~$ pwd/ / Show current directory / home/hnlinuxhnlinux@runoob.com:~$ su root / / switch to root user password: root@runoob.com:/home/hnlinux# whoami rootroot@runoob.com:/home/hnlinux# pwd/home/hnlinux
Switch users, change environment variables
Hnlinux@runoob.com:~$ whoami / / Show current user hnlinuxhnlinux@runoob.com:~$ pwd / / Show current directory / home/hnlinuxhnlinux@runoob.com:~$ su-root / / switch to root user password: root@runoob.com:/home/hnlinux# whoami rootroot@runoob.com:/home/hnlinux# pwd / / Show current directory / root "how to use su in linux" this is the end of the introduction, thank you for 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.
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.