Difference between su and su-commands I used to use root directly and seldom use su. only a few days ago I found that su and su-commands are essentially different! Most of the default accounts of www.2cto.com Linux distributions are normal users. to change system files or execute certain commands, you need to use roo... difference between su and su-commands I used to use root directly and seldom use su. only a few days ago I found that su and su-commands are essentially different! The default account of most Linux distributions at www.2cto.com is a common user. to change the system file or execute some commands, you need to use the root identity. This requires switching from the current user to the root user. In Linux, the command for switching users is su or su -. I realized the essential difference between the two when I used the useradd command the day before yesterday.
First, I used the su command to switch to the root identity. However, when I run useradd, the following error occurs: bash: useradd: command not found. Google: The reason is that the root user switched over with the su command. The biggest essential difference between the su command and the su-command is that the former only switches the root identity, but the Shell environment is still the Shell of ordinary users; the latter switches the user to the root identity together with the Shell environment. The PATH environment variable error does not occur only when the Shell environment is switched. After su is switched to the root user, pwd finds that the working directory is still the working directory of normal users. after su-command is switched, the working directory is changed to the root working directory. Run the echo $ PATH command to check whether the environment variables after su and su are different. Similarly, to switch from the current user to another user, use the su-command.
In Linux, services cannot run if the configuration file is too many or a space is missing. You must pay attention to the details so that you can avoid detours! Through the above comparison, we found that using su-is equivalent to a complete login process, while su simply switches the user over, and does not bring any environment variables.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.