I have 3 users in my server:
- root
- user1
- user2
When I try to change my current user from user1 to user2 by using the command sudo su user1
, my operating system sometimes changes instead from user1 to root (this is verified by using the whoami
command).
The opposite happens when I try to change my current user from user1 to root by using the command sudo su root
, the OS sometimes changes from user1 to user2.
Some extra errors (or symptoms) detected are:
- When already logged as user2 I can't change to root user by any method (I end up restarting the server connection until it works).
- Sometimes when I am logged as either root or user2 and time passes I find that my current user has changed automatically from root to user2 or vice versa.
- The user name does not display correctly in command line when logged as root or username2 (it sometimes displays
[user1@IP ~] #
while thewhoami
command displaysroot
, for example).
sudo su user
is being used to not prompt for password (I am aware of the security implications of doing this). Anyways, if I usesu user
and introduce the password manually the exact same problem still rises. I have read the manuals you mentioned and used both options, unfortunately with no results.The sequence of commands used is only:
– Enrique GO Nov 07 '19 at 17:00sudo su user
orsu user
. Any other suggestions? Thanks.su -l user
andsu -l root
still reproduce the issue. I have feeling that it has to do with some kind of "user aliases" or "environment variables" as you mentioned, unfortunately I haven't found related info to test it. – Enrique GO Nov 07 '19 at 17:05sudo su
: if a user can usesudo
without a password, thensudo -iu username
is the command to use. There really is no purpose invokingsudo su
. – Christopher Nov 07 '19 at 17:56id user1
andid user2
? – bxm Nov 07 '19 at 20:50USER
,LOGNAME
andMAIL
environment variables are being overwritten from one another occasionally. Already tried to search for the process that generates them, with no luck. – Enrique GO Nov 08 '19 at 14:01