A brief discussion of the problems when switching from Linux password free to root users

  • 2020-05-15 03:23:18
  • OfStack

su is used for user switching under Linux (Centos system as an example).

1 as follows:


su username
su - username

The first way is to switch users and still use the environment variables of the previous logged-in users, sometimes running some programs will cause problems.

The second method is quite thorough. After switching, the user's environment variable will also change, which is the current user's environment variable.

There are two things to note.

When we switch to the root user, we use either su or su -, but the problem is that we need to enter the password. It's a little bit of a hassle. We can allow a user to log in to root user without a password, which requires the following Settings:

vim /etc/pam.d/su

Uncomment the following line:


auth      sufficient   pam_wheel.so trust use_uid

Then execute:


gpasswd -a usename wheel 

Can!!


Related articles: