Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Detailed Linux su command to switch users Mistakes     - Fedora 22 install Adobe Flash Player (Linux)

- Java reflection technology explain (Programming)

- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)

- Kali Linux virtualbox rc = Error 1908 workaround (Linux)

- JavaScript closures and the scope chain (Programming)

- iOS GCD multithreading simple to use (Programming)

- Linux RPM (Linux)

- Installation JDK 1.8 under CentOS7 (Linux)

- MySQL management partition table (Database)

- Zabbix monitoring Oracle Database use Orabbix plug (Enhanced Edition) (Database)

- Introduction and bash history command to quickly call (Linux)

- CentOS network configuration 7, and set the host name and IP-bound problems (Linux)

- To install Xen in Ubuntu 12.04 (Linux)

- Installation Mesos + Marathon + Zookeeper under CentOS 7 (Server)

- Systemd on RHEL7 (Linux)

- Linux environment to build next Cocos2dx-3.3.1 (Linux)

- Sublime Text Add instructions to insert the current time zone (Linux)

- MySQL stored procedures execute dynamic sql statement (Database)

- Tmux Getting Start (Linux)

- Linux IPTables anti-DDOS attack Shell Scripting (Linux)

  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


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.
- VirtualBox 4.3 Can not open a new task for a virtual computer solution (Linux)
- Ubuntu 14.04 virtual machine switching desktop environments (Linux)
- Linux, modify / etc / profile file (Linux)
- Debian SSD ext4 4K aligned (Linux)
- Use chattr and lsattr command to manage linux files and directory attributes (Linux)
- CentOS7 install MySQL5.6.22 (Linux)
- After Pydev installation, Eclipse does not display solutions (Linux)
- Vim Getting Started Tutorial (Linux)
- Android Studio interface-related settings (Linux)
- MariaDB database storage path modify configuration issues (Database)
- Ubuntu upgrade to Linux Kernel 4.2.3 Kernel (Linux)
- Linux security configuration (Linux)
- Apache Linux firewall reverse proxy configuration (Linux)
- Oracle 12c detailing the new features (Database)
- Java Virtual Machine class loading mechanism and bytecode execution engine (Programming)
- PostgreSQL 9.3.2 Json type of use (Database)
- Erase do with HTML5 Canvas and diffusion effect (Programming)
- Local port forwarding using iptables under linux (Server)
- lolcat: an output terminal rainbow effects in the Linux command-line tool (Linux)
- Ubuntu simple method to track multiple time zones (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.