The su command under Linux is mainly used to switch users. It can switch between ordinary users and super users. What are the uses of the su command? After using the su command, are other users still there? Let's take a look at the examples of the su command under Linux with the Xiaobian.
original Q: linux, I log in as root, and other users to log in and use the su command to switch to root user, what is there not the same, if the same thing, I execute su command after the other Users are still not in the system? I am trying to delete other users after executing su, linux prompts, other users logged in? Why
Answer: Let me explain it to you! In the Unix system, when the user logs in, a shell process is created for each user, providing interactive functions. If you are using bash, then the shell process is bash, ksh is used, the process is ksh, and other shells are the same.
For the process, in its process PCB (process control block), there are two values of the actual user ID and the effective user ID. The so-called actual user ID refers to the identity of the process. For example, I am currently the root user. The actual user ID of the process I created is the root ID, which is usually 0. The effective user ID refers to the ID of the user who currently has the right to use the process. For example, if I have a car, I will group it out. The owner of this car is me, but the permission is not mine.
In general, the actual user ID and the valid user ID are the same. The su command has such a function that a process can run with the permission of the command owner, that is, the actual user ID of the process can be made. The valid user IDs are not the same. You can use ls -l to view the su command. It must be written as s (small s) on its owner's x permission bit. The passwd command is the same, they have the same function. This s bit means that the user who executes the command can execute with the owner's permission of the command. If you cancel the s bit, only the owner of su can su.
Now let's explain it further, I hope you can understand it.
When we execute su as root, the su command will create a new shell process with the current shell process as the parent process. This shell process is provided to the user we want to su, and root. The shell process still exists, and vice versa, this is the reason you asked the question, because the previous user's shell process has not been closed, you can use exit to exit, you can see, not logout, Instead, go back to the previous user. Because they are the relationship between the parent and child processes, the end of the child process will of course not affect the execution of the parent process. But if we forcefully kill the parent process, we will quit directly.
In fact, many people do not understand the difference between whoami and who am i, their role is different.
who am i Displays the actual user ID of the current shell process.
whomai displays a valid user ID for the current shell process.
Many times, the two outputs are the same, so that we think the two commands have the same effect.
Example: root@yunhw-Aspire-4750G:~# who am i
root pts/0 2011-12-10 13:13 (:0.0)
root @yunhw-Aspire-4750G:~# whoami
root
root@yunhw-Aspire-4750G:~#ps -ef
root 2939 2935 0 13:18 pts /0 00:00:00 bash
root@yunhw-Aspire-4750G:~# su - yunhw
yunhw@yunhw-Aspire-4750G:~$ who am i
root pts/0 2011-12-10 13:13 (:0.0)
yunhw@yunhw-Aspire-4750G:~$worami
yunhw
root@ yunhw-Aspire-4750G:~#ps -ef
root 2939 2935 0 13:18 pts/0 00:00:00 bash
yunhw 2958 2939 0 13:19 pts/0 00 :00:00 su - yunhw
yunhw 2966 2958 7 13:19 pts/0 00:00:00 -su
root@yunhw-Aspire-4750G:~#sudo kill -9 2939
Once this command is executed, it will be completely quit.
The above is the usage of the su command under Linux. The su command is used to explain the specific usage of the problem. It also gives a reference to the users who have encountered the problem. Have you learned? ?
Ubuntu installed graphics driver is sometimes not so smooth, will prompt an error and cause Nvidia d
Linux system operation, sometimes need to install the kernel header file when installing the device
openSUSE Linux is a kernel-based Linux operating system, has been upgraded to version 13.2, how many
CentOS many software installation needs to be completed by yum, but CentOS6.2 when upgrading yum err
How to use the tail command guide under Linux
What should I do if ORA-12528 reports an error when building DataGuard in Linux?
Linux terminal prompt path length modification method
How to deal with the problem of starting weblogic server error in Linux
What should I do if there are garbled characters in Linux Chinese characters?
Linux uses commands to clean large files. Steps
How to use Linux to periodically delete expired files using the command
Linux uses PXE to install virtual machines
RHEL6 changes the name of the asm disk by udev.
The method of modifying the /etc/profile file in Linux system
What are the relationships between processes in the Linux system?
Notes on operating online replacement files on Linux systems
Enter the Windows XP system blue screen prompt "stop: 0X0000007B" to solve the
Win7 32-bit flagship system in response to firewall vulnerabilities
Win2000/XP and Win98 exchange visits
Windows 10 "most common" application is said to be actually not commonly used
Win8 system boot card in the logo can not enter the desktop how to do?
Resolving winxp with vbs You are a victim of pirated software tips
Windows 7 Simplifies Device Manager Improves Support for SSDs