0

Does anyone know how do I list existing alias for a certain Unix/Linux user on Debian? For example I have an Unix/Linux user 1001 and want to know which alias for login it has?

migrated from serverfault.com Aug 27 '13 at 20:25

This question came from our site for system and network administrators.

  • What do you mean by alias? Do you mean the user name? – Gilles Aug 27 '13 at 21:50
7

I assume you have a user with a numerical user id (uid) of 1001 and want its user name:

getent passwd 1001 

will show this information.

1

If it's a local user you can grep /etc/passwd for it. Like following:

grep 1001 /etc/passwd

If it's a non-local user, it depends on the DB backend that is used to store him in. For example if you use NIS you may check with ypcat:

cd /etc
ypcat passwd | grep 1001

For other DB backends you'll have to check the specific ways to search for a user by UID.

  • 2
    See my approach. This will work with LDAP, NIS etc. – Sven Aug 27 '13 at 10:11
  • This isn't good. What if there is a UID 1001 and a UID 11001? – jordanm Aug 27 '13 at 21:20

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.