In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge of what the misunderstanding of Linux using su command is, the content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
When many friends use the su instruction, they often use the following form:
Example: switch from general account moonlit to root account
$su
So is there anything wrong with this?
Let's take a look at the data comparison before and after account switching.
[moonlit@host ~] $
Execute the following statement before switching to view the variables in the environment that contain moonlit:
$env | grep 'moonlit'
The screen displays as follows:
USER=moonlitMAIL=/var/spool/mail/moonlitPATH=/usr/java/jdk1.7.0_60/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/moonlit/binPWD=/home/moonlitHOME=/home/moonlitLOGNAME=moonlit
Perform the switchover:
$su
Password:
After entering the password, the screen is converted to:
[root@host ~] #
Enter # pwd to view the current path
/ home/moonlit
Hey, why is it still under the home directory of your moonlit account?
Then enter # env | grep 'moonlit'
Screen output:
USER=moonlitPATH=/usr/java/jdk1.7.0_60/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/moonlit/binMAIL=/var/spool/mail/moonlitPWD=/home/moonlitLOGNAME=moonlit
Did you see that? The environment hasn't changed.
Because there is no change to the root environment, it may cause a lot of root instruction errors or invalid oh.
To fully convert users to root, you can use the following instructions:
[moonlit@host ~] $su-
Change to [root@host ~] # after typing the root password
# pwd:
/ root
Then # env | grep 'moonlit':
There is no such thing.
Env: at this time the screen will display all the variables, more, not enumerated one by one, you can see the current home directory, PATH, MAIL and so on have all been replaced with root variables.
Finally, you can issue # exit to exit the current root user and return to moonlit.
These are all the contents of the article "what is the misunderstanding of Linux using the su command". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.
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.