i am trying to make a txt file with a list of existing user in Linux debian10, all i want in the list is username of each existing user, can anyone teach me how to do it?

  • What have you tried? – Steven Mar 31 '20 at 2:52

This will print the first field of /etc/passwd, which contains all the accounts on a system.

awk -F: '{print $1}' /etc/passwd

To save that output to a file, use the > file redirection operator, e.g.

awk -F: '{print $1}' /etc/passwd > users.txt
  • 1
    Thanks alot and is there a way i could extract only the username of those users? – zhen cheng Mar 31 '20 at 6:32

To list the normal users on debian:

getent passwd {1000..6000}

1000 is the minimum UID :

grep ^UID_MIN /etc/login.defs

6000 is the maximum UID :

grep ^UID_MAX /etc/login.defs

see man login.def

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.