Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Detailed Linux su command to switch users Mistakes     - Kitematic how seamless and DockerFILE (Server)

- The principle Httpclient4.4 (HttpClient Interface) (Programming)

- CentOS6 MongoDB connection solution can not break 1000 (Database)

- Linux centralized log server rsyslog (Server)

- Oracle 11g RMAN cross-platform transfer table space (Database)

- Setting up Linux machine through a proxy firewall (Linux)

- Gitblit adopted Ticket collaborative development model (Linux)

- git checkout generated in the use of temporary br (Linux)

- VirtualBox install Windows 8.1 has encountered an error 0x000000C4 solutions (Linux)

- How to fix Not Enough Free Disk Space On / boot on Ubuntu (Linux)

- Linux System Getting Started Learning: The Linux ac command (Linux)

- LAMP environment to build Apache, MySQL, PHP under Ubuntu (Server)

- Oracle inline view updates problems encountered (Database)

- Analysis RabbitMQ cluster (Server)

- Android development, may cause a memory leak problem (Programming)

- Linux data redirection (Linux)

- Java multithreading easy to confuse the concept (Programming)

- Bash common several configuration files (Linux)

- Exploring the Android Listview display confusion (Programming)

- RedHat Linux 7 build yum source server (Server)

 
         
  Detailed Linux su command to switch users Mistakes
     
  Add Date : 2017-08-31      
         
       
         
  1. Background
For security reasons, the general recommendation is usually in the Linux operating environment for the use of general account

This is because the root account permissions too large, often because of careless misuse cause system errors, but also cause serious system failures, crashes.

Therefore it recommends related operations only when you need to switch to the root account under.

su command to switch users operating under Linux environment

2.su instruction
Many friends in the use of the instruction, often using the following form:

Example: Switching from the general account to the root account moonlit

$ Su

So you do what is wrong with it?

We'll be comparing the observed data under the account before and after switching.

[Moonlit @ host ~] $

Execute the following statement before switching to view the environment contains moonlit variables:

$ Env | grep 'moonlit'

The display shows:

USER = moonlit
MAIL = / var / spool / mail / moonlit
PATH = / 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 / bin
PWD = / home / moonlit
HOME = / home / moonlit
LOGNAME = moonlit

Performs switching:

$ Su

Password:

After entering the password screen converted to:

[Root @ host ~] #

Enter #pwd view the current path

/ Home / moonlit

Hey, how or in the moonlit account home directory?

Then enter # env | grep 'moonlit'

Screen output:

USER = moonlit
PATH = / 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 / bin
MAIL = / var / spool / mail / moonlit
PWD = / home / moonlit
LOGNAME = moonlit

See it? Wooden environment has changed ah.

Because there is no change to the root of the environment, it may cause a lot of root instruction errors or invalid oh.

Want complete conversion to root users can use the following command:

[Moonlit @ host ~] $ su -


After you type the root password into [root @ host ~] #

#pwd about:

/ Root


Then # env | grep 'moonlit' look:

Oh, God, no horse.

# Env about:

This time the screen will display all the variables out more, do not list them, you can see the current home directory, PATH, MAIL, etc. have all but replaced the root variables.

Finally, you can release #exit to exit the current root user returns moonlit.

3. Summary
In fact, no - when the system is in accordance with the non-login shell way switch users,

And plus - when the system is switched in accordance login shell.
     
         
       
         
  More:      
 
- 10 useful Linux command Interview Questions and Answers (Linux)
- Redmine Installation (Linux)
- Linux Operating System Security Management describes the top ten tricks (Linux)
- Spring Data MongoDB combat (Database)
- Linux reserves the rest of the file to delete several (Linux)
- To install the Contiki development toolchain on Ubuntu (Linux)
- CentOS 7 install Hadoop-cdh-2.6 (Server)
- Ubuntu disable graphics card (Linux)
- Linux use additional rights (Linux)
- Make command Detailed Tutorial (Programming)
- How to find on Linux and delete duplicate files: FSlint (Linux)
- Android will save the picture to see the album and timely (Programming)
- Understanding Linux firewall Iptables (Linux)
- How to install Go1.5 source development environment on Mac (Server)
- Sniffer install applications in Linux supplement (Linux)
- Install VMware Tools in Debian (Linux)
- Depth understanding of Python character set encoding (Programming)
- OS X CAOpenGLLayer how to enable OpenGL 3.2 core profile (Programming)
- CentOS system dual network card IP information configuration (Linux)
- Slow update statement Performance Analysis (Database)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.