0

I have 3 users in my server:

  1. root
  2. user1
  3. 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 the whoami command displays root, 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 use su 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: sudo su user or su user. Any other suggestions? Thanks. – Enrique GO Nov 7 at 17:00
  • su -l user and su -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 7 at 17:05
  • 1
    No, I can't think of anything more except on your use of sudo su: if a user can use sudo without a password, then sudo -iu username is the command to use. There really is no purpose invoking sudo su. – Christopher Nov 7 at 17:56
  • What’s the result of running id user1 and id user2? – bxm Nov 7 at 20:50
  • Both IDs are the same (0, which I believe belongs to root). What I have noticed is that USER, LOGNAME and MAIL 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 8 at 14:01
1

Make sure every user has a unique user ID, and all the environment variable definition scripts are not set to overwritte user ID.

  1. Compare the outputs of id user1 and id user2.

  2. Check the folders where environment variables are defined.

  3. Edit /etc/passwd and /etc/group files if permission/ID issues show up. Make sure to read the docs of both files. Docs at: /etc/passwd, /etc/group

New contributor
Enrique GO is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.