9

When I execute users command, it output two users with same name. Why are there two users? I'm pretty sure that I created just one user.

i.e

username@Computer:~$ users

gives following output

username username
2
  • Did you copy and paste those results?
    – colboynik
    Feb 4, 2013 at 5:24
  • @JohnRambo he just cut out the actual username and computer name...
    – Alvar
    Feb 4, 2013 at 6:37

2 Answers 2

14

The users command prints the user names of users currently logged in to the current host, not the list of users you created on your computer.

In your case, it returns the same user name twice because you are probably logged in twice.

You can check by using the who command (show who is logged on):

felix@computer:~$ who
felix    pts/0        2013-02-04 06:40 (:0.0)
felix    pts/5        2013-02-04 06:42 (:0.0)
felix@computer:~$ users
felix felix

See the manual pages for more information (man 1 users).

3
  • I didn't logged in twice, it is by default. Why there are two users logged in anyway? Feb 4, 2013 at 8:05
  • 3
    Maybe because you have two open terminals?
    – felix
    Feb 4, 2013 at 8:20
  • 3
    Run users in aterminal. Now open another terminal run it again (users). You can see incerase in number.
    – totti
    Feb 4, 2013 at 10:16
0

The users command prints the user names of users currently logged in to the current host, not the list of users you created on your computer.

This not limited to users signed in form graphical sign in screen, but also those logins via sudo.

You can check that by running users, then logging in to another shell session with sudo running sudo -su <user_name> or even just sudo if you want root user. Run users from here or any other session, you could see another user entry.

One thing to note, is that the list contains users that have run sudo, not the users sudo switched to. For example,

  1. if you run users as non-root and got "someuser someuser"
  2. Then run sudo sh to get shell as root.
  3. If you test here by running users, you will get "<user_you_ran_sudo from> someuser someuser"
  4. Then run either another sudo sh or sudo -s -u <user_name>
  5. You will get additional entry for "root".

This is the case in my Linux version 6.0.0-kali6-amd64.

1
  • This is a repeat of the existing answer.
    – David
    Mar 25, 2023 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .