Adding Users section

I'm trying to understand something here.

I created a new user and I wanted to log in as the user as per the video and I noticed that I did not have a "login: user" command on my distro (Centos 7) , so instead I used su "name of user" and was able to log in--or did I log in?

I'm not sure if I logged in or not because when I type the "last" command, I do not see the name of the new user account I logged in with. Or does using su "user name" not really log me in? I also verified this by typing "who" command and noticed that the new user account was not logged in.

However, when I open a new putty session and log in as the new user, then the user shows up as logged in via "who" and "last" command.

Why is this? Thank you!
  • post-author-pic
    Michael M


    The normal behaviour of the su <username> command is to change the UID and GID to those of the user account indicated in the "Substitute User" command. 
    This means that although the user is actually logged in all of the shell environment is the same as if that user were logged in. 
    An example: you are logged in as root and you type who, only root shows as logged in. If you execute su <anotheruser> and then whoami it will show that you are <anotheruser> but that user is not actually logged in, you are simply invoking commands using variables that represent that user. Also if you cd ~ you will be taken to <anotheruser>'s home directory. 
    You are technically not logged in as that user but to the system, each time that you execute a command that requires the UID / GID to be checked you are substituting the other user's ID's to the system. 
    I hope my explanation was clear, if not I apologize. 

    More can be found here.

  • post-author-pic

    That made perfect sense. Thank you!

Looking For Team Training?

Learn More