A command to list all users? And how to add, delete, modify users?











up vote
742
down vote

favorite
311












I need a command to list all users in terminal. And how to add, delete, modify users from terminal.



That could help in administrating your accounts easily by terminal.










share|improve this question




















  • 1




    sed answer sed 's/:.*//' /etc/passwd
    – Avinash Raj
    Jul 21 '16 at 13:02






  • 1




    list users: awk -F: '{ print $1 }' /etc/passwd
    – saviour123
    Aug 23 '17 at 9:51















up vote
742
down vote

favorite
311












I need a command to list all users in terminal. And how to add, delete, modify users from terminal.



That could help in administrating your accounts easily by terminal.










share|improve this question




















  • 1




    sed answer sed 's/:.*//' /etc/passwd
    – Avinash Raj
    Jul 21 '16 at 13:02






  • 1




    list users: awk -F: '{ print $1 }' /etc/passwd
    – saviour123
    Aug 23 '17 at 9:51













up vote
742
down vote

favorite
311









up vote
742
down vote

favorite
311






311





I need a command to list all users in terminal. And how to add, delete, modify users from terminal.



That could help in administrating your accounts easily by terminal.










share|improve this question















I need a command to list all users in terminal. And how to add, delete, modify users from terminal.



That could help in administrating your accounts easily by terminal.







command-line user-management






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 2 '14 at 18:10


























community wiki





19 revs, 2 users 77%
nux









  • 1




    sed answer sed 's/:.*//' /etc/passwd
    – Avinash Raj
    Jul 21 '16 at 13:02






  • 1




    list users: awk -F: '{ print $1 }' /etc/passwd
    – saviour123
    Aug 23 '17 at 9:51














  • 1




    sed answer sed 's/:.*//' /etc/passwd
    – Avinash Raj
    Jul 21 '16 at 13:02






  • 1




    list users: awk -F: '{ print $1 }' /etc/passwd
    – saviour123
    Aug 23 '17 at 9:51








1




1




sed answer sed 's/:.*//' /etc/passwd
– Avinash Raj
Jul 21 '16 at 13:02




sed answer sed 's/:.*//' /etc/passwd
– Avinash Raj
Jul 21 '16 at 13:02




1




1




list users: awk -F: '{ print $1 }' /etc/passwd
– saviour123
Aug 23 '17 at 9:51




list users: awk -F: '{ print $1 }' /etc/passwd
– saviour123
Aug 23 '17 at 9:51










8 Answers
8






active

oldest

votes

















up vote
999
down vote



accepted










To list all local users you can use:



cut -d: -f1 /etc/passwd


To list all users capable of authenticating (in some way), including non-local, see this reply: https://askubuntu.com/a/414561/571941



Some more useful user-management commands (also limited to local users):



To add a new user you can use:



sudo adduser new_username


or:



sudo useradd new_username


See also: What is the difference between adduser and useradd?



To remove/delete a user, first you can use:



sudo userdel username


Then you may want to delete the home directory for the deleted user account :



sudo rm -r /home/username


(Please use with caution the above command!)



To modify the username of a user:



usermod -l new_username old_username


To change the password for a user:



sudo passwd username


To change the shell for a user:



sudo chsh username


To change the details for a user (for example real name):



sudo chfn username


And, of course, see also: man adduser, man useradd, man userdel... and so on.



To add a user to the sudo group:



usermod -aG sudo username





share|improve this answer



















  • 10




    Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
    – Mikaela
    Jan 29 '14 at 7:26






  • 2




    I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
    – Rmano
    May 21 '14 at 18:02










  • sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
    – 00fruX
    Aug 7 '14 at 19:44








  • 1




    @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
    – Oli
    Aug 8 '14 at 8:32






  • 1




    +1 for What is the difference between adduser and useradd?
    – sonlexqt
    Oct 22 '15 at 10:20


















up vote
78
down vote













Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:



cat /etc/passwd


OR



less /etc/passwd
more /etc/passwd


You can also use awk:awk



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





share|improve this answer





















  • how to add users by command ?
    – nux
    Jan 24 '14 at 19:31










  • You can use useradd command.
    – Mitch
    Jan 24 '14 at 19:32










  • @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
    – flindeberg
    Jul 24 '16 at 14:39


















up vote
58
down vote













The easiest way to get this kind of information is getent - see manpage for the getent command Manpage icon. While that command gives the same output as cat /etc/passwd it is useful to remember because it will give you lists of several elements in the OS.



To get a list of all users you type (as users are listed in /etc/passwd)



getent passwd


To add a user newuser to the system you would type



sudo adduser newuser


to create a user that has all default settings applied.



Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type



sudo adduser anyuser cdrom


You delete a user (for instance obsolete) with



sudo deluser obsolete


If you want to delete his home directory/mails as well you type



sudo deluser --remove-home obsolete


And



sudo deluser --remove-all-files obsolete


will remove the user and all files owned by this user on the whole system.






share|improve this answer



















  • 6




    It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
    – Marcin Kaminski
    Sep 25 '14 at 16:34










  • @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
    – ulkas
    Sep 28 at 8:25


















up vote
27
down vote













You can use compgen built-in too:



compgen -u


Will lists all users.






share|improve this answer






























    up vote
    24
    down vote













    This should get, under most normal situations, all normal (non-system, not weird, etc) users:



    awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd


    This works by:




    • reading in from /etc/passwd

    • using : as a delimiter

    • if the third field (the User ID number) is larger than 1000 and not 65534, the first field (the username of the user) is printed.


    This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:




    A user ID (UID) is a unique positive integer assigned by a Unix-like
    operating system to each user. Each user is identified to the system
    by its UID, and user names are generally used only as an interface for
    humans.



    UIDs are stored, along with their corresponding user names and other
    user-specific information, in the /etc/passwd file...



    The third field contains the UID, and the fourth field contains the
    group ID (GID), which by default is equal to the UID for all ordinary
    users.



    In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers
    that can represent values from zero to 4,294,967,296. However, it is
    advisable to use values only up to 65,534 in order to maintain
    compatibility with systems using older kernels or filesystems that can
    only accommodate 16-bit UIDs.



    The UID of 0 has a special role: it is always the root account (i.e.,
    the omnipotent administrative user). Although the user name can be
    changed on this account and additional accounts can be created with
    the same UID, neither action is wise from a security point of view.



    The UID 65534 is commonly reserved for nobody, a user with no system
    privileges, as opposed to an ordinary (i.e., non-privileged) user.
    This UID is often used for individuals accessing the system remotely
    via FTP (file transfer protocol) or HTTP (hypertext transfer
    protocol).



    UIDs 1 through 99 are traditionally reserved for special system users
    (sometimes called pseudo-users), such as wheel, daemon, lp, operator,
    news, mail, etc. These users are administrators who do not need total
    root powers, but who perform some administrative tasks and thus need
    more privileges than those given to ordinary users.



    Some Linux distributions (i.e., versions) begin UIDs for
    non-privileged users at 100. Others, such as Red Hat, begin them at
    500, and still others, such Debian, start them at 1000. Because of the
    differences among distributions, manual intervention can be necessary
    if multiple distributions are used in a network in an organization.



    Also, it can be convenient to reserve a block of UIDs for local users,
    such as 1000 through 9999, and another block for remote users (i.e.,
    users elsewhere on the network), such as 10000 to 65534. The important
    thing is to decide on a scheme and adhere to it.



    Among the advantages of this practice of reserving blocks of numbers
    for particular types of users is that it makes it more convenient to
    search through system logs for suspicious user activity.



    Contrary to popular belief, it is not necessary that each entry in the
    UID field be unique. However, non-unique UIDs can cause security
    problems, and thus UIDs should be kept unique across the entire
    organization. Likewise, recycling of UIDs from former users should be
    avoided for as long as possible.







    share|improve this answer






























      up vote
      16
      down vote













      list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)



      awk -F':' '$2 ~ "$" {print $1}' /etc/shadow


      add new user



      sudo adduser new_username


      or



      sudo useradd new_username


      delete/remove username



      sudo userdel username


      If you want to delete the home directory (default the directory /home/username)



      sudo deluser --remove-home username


      or



      sudo rm -r /path/to/user_home_dir


      If you want to delete all files from the system from this user (not only is the home diretory)



      sudo deluser --remove-all-files





      share|improve this answer



















      • 1




        Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
        – s3lph
        Sep 25 '14 at 20:13






      • 1




        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
        – jeff musk
        Jun 20 at 5:43




















      up vote
      7
      down vote













      Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.



      user (tab tab)


      gives me as possible options
      useradd userdel usermod users users-admin

      if you want to know more about a command google it or type man
      man useradd
      gives
      useradd - create a new user or update default new user information
      ...
      ...



      to list users you should go with what Mitch said.



      Hope that helps I love tab completion in bash saves me from remembering things.






      share|improve this answer




























        up vote
        6
        down vote













        To find out the users which have home-directories in the /home-folder on the machine, run the following commands



        cd /home
        ls


        You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.






        share|improve this answer



















        • 7




          This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
          – David Foerster
          Dec 19 '14 at 0:57










        protected by Radu Rădeanu Feb 22 '15 at 17:21



        Thank you for your interest in this question.
        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



        Would you like to answer one of these unanswered questions instead?














        8 Answers
        8






        active

        oldest

        votes








        8 Answers
        8






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        999
        down vote



        accepted










        To list all local users you can use:



        cut -d: -f1 /etc/passwd


        To list all users capable of authenticating (in some way), including non-local, see this reply: https://askubuntu.com/a/414561/571941



        Some more useful user-management commands (also limited to local users):



        To add a new user you can use:



        sudo adduser new_username


        or:



        sudo useradd new_username


        See also: What is the difference between adduser and useradd?



        To remove/delete a user, first you can use:



        sudo userdel username


        Then you may want to delete the home directory for the deleted user account :



        sudo rm -r /home/username


        (Please use with caution the above command!)



        To modify the username of a user:



        usermod -l new_username old_username


        To change the password for a user:



        sudo passwd username


        To change the shell for a user:



        sudo chsh username


        To change the details for a user (for example real name):



        sudo chfn username


        And, of course, see also: man adduser, man useradd, man userdel... and so on.



        To add a user to the sudo group:



        usermod -aG sudo username





        share|improve this answer



















        • 10




          Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
          – Mikaela
          Jan 29 '14 at 7:26






        • 2




          I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
          – Rmano
          May 21 '14 at 18:02










        • sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
          – 00fruX
          Aug 7 '14 at 19:44








        • 1




          @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
          – Oli
          Aug 8 '14 at 8:32






        • 1




          +1 for What is the difference between adduser and useradd?
          – sonlexqt
          Oct 22 '15 at 10:20















        up vote
        999
        down vote



        accepted










        To list all local users you can use:



        cut -d: -f1 /etc/passwd


        To list all users capable of authenticating (in some way), including non-local, see this reply: https://askubuntu.com/a/414561/571941



        Some more useful user-management commands (also limited to local users):



        To add a new user you can use:



        sudo adduser new_username


        or:



        sudo useradd new_username


        See also: What is the difference between adduser and useradd?



        To remove/delete a user, first you can use:



        sudo userdel username


        Then you may want to delete the home directory for the deleted user account :



        sudo rm -r /home/username


        (Please use with caution the above command!)



        To modify the username of a user:



        usermod -l new_username old_username


        To change the password for a user:



        sudo passwd username


        To change the shell for a user:



        sudo chsh username


        To change the details for a user (for example real name):



        sudo chfn username


        And, of course, see also: man adduser, man useradd, man userdel... and so on.



        To add a user to the sudo group:



        usermod -aG sudo username





        share|improve this answer



















        • 10




          Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
          – Mikaela
          Jan 29 '14 at 7:26






        • 2




          I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
          – Rmano
          May 21 '14 at 18:02










        • sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
          – 00fruX
          Aug 7 '14 at 19:44








        • 1




          @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
          – Oli
          Aug 8 '14 at 8:32






        • 1




          +1 for What is the difference between adduser and useradd?
          – sonlexqt
          Oct 22 '15 at 10:20













        up vote
        999
        down vote



        accepted







        up vote
        999
        down vote



        accepted






        To list all local users you can use:



        cut -d: -f1 /etc/passwd


        To list all users capable of authenticating (in some way), including non-local, see this reply: https://askubuntu.com/a/414561/571941



        Some more useful user-management commands (also limited to local users):



        To add a new user you can use:



        sudo adduser new_username


        or:



        sudo useradd new_username


        See also: What is the difference between adduser and useradd?



        To remove/delete a user, first you can use:



        sudo userdel username


        Then you may want to delete the home directory for the deleted user account :



        sudo rm -r /home/username


        (Please use with caution the above command!)



        To modify the username of a user:



        usermod -l new_username old_username


        To change the password for a user:



        sudo passwd username


        To change the shell for a user:



        sudo chsh username


        To change the details for a user (for example real name):



        sudo chfn username


        And, of course, see also: man adduser, man useradd, man userdel... and so on.



        To add a user to the sudo group:



        usermod -aG sudo username





        share|improve this answer














        To list all local users you can use:



        cut -d: -f1 /etc/passwd


        To list all users capable of authenticating (in some way), including non-local, see this reply: https://askubuntu.com/a/414561/571941



        Some more useful user-management commands (also limited to local users):



        To add a new user you can use:



        sudo adduser new_username


        or:



        sudo useradd new_username


        See also: What is the difference between adduser and useradd?



        To remove/delete a user, first you can use:



        sudo userdel username


        Then you may want to delete the home directory for the deleted user account :



        sudo rm -r /home/username


        (Please use with caution the above command!)



        To modify the username of a user:



        usermod -l new_username old_username


        To change the password for a user:



        sudo passwd username


        To change the shell for a user:



        sudo chsh username


        To change the details for a user (for example real name):



        sudo chfn username


        And, of course, see also: man adduser, man useradd, man userdel... and so on.



        To add a user to the sudo group:



        usermod -aG sudo username






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 27 at 16:13









        Joshua Pinter

        1556




        1556










        answered Jan 24 '14 at 20:23









        Radu Rădeanu

        115k34244321




        115k34244321








        • 10




          Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
          – Mikaela
          Jan 29 '14 at 7:26






        • 2




          I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
          – Rmano
          May 21 '14 at 18:02










        • sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
          – 00fruX
          Aug 7 '14 at 19:44








        • 1




          @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
          – Oli
          Aug 8 '14 at 8:32






        • 1




          +1 for What is the difference between adduser and useradd?
          – sonlexqt
          Oct 22 '15 at 10:20














        • 10




          Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
          – Mikaela
          Jan 29 '14 at 7:26






        • 2




          I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
          – Rmano
          May 21 '14 at 18:02










        • sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
          – 00fruX
          Aug 7 '14 at 19:44








        • 1




          @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
          – Oli
          Aug 8 '14 at 8:32






        • 1




          +1 for What is the difference between adduser and useradd?
          – sonlexqt
          Oct 22 '15 at 10:20








        10




        10




        Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
        – Mikaela
        Jan 29 '14 at 7:26




        Radu forgot to mention sudo chfn <username> which changes user details (for example real name). I tried to add this as a comment, but I got error telling me that I must have +50 reputation to do so.
        – Mikaela
        Jan 29 '14 at 7:26




        2




        2




        I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
        – Rmano
        May 21 '14 at 18:02




        I think that it should be underlined that the correct answer to the linked question is askubuntu.com/a/381646/16395 --- otherwise you have to take into account the GID/UID Ubuntu policies by hand. The accepted answer is not so clear.
        – Rmano
        May 21 '14 at 18:02












        sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
        – 00fruX
        Aug 7 '14 at 19:44






        sudo userdel DOMAIN\johndoe gives me the error: "userdel: cannot remove entry 'DOMAINjohndoe' from /etc/passwd -- I looked in /etc/passwd and they're not even in there, likely because it's a "domain" account?
        – 00fruX
        Aug 7 '14 at 19:44






        1




        1




        @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
        – Oli
        Aug 8 '14 at 8:32




        @00fruX Yeah... If you're using a centralised user database you're going to need to deal with it directly.
        – Oli
        Aug 8 '14 at 8:32




        1




        1




        +1 for What is the difference between adduser and useradd?
        – sonlexqt
        Oct 22 '15 at 10:20




        +1 for What is the difference between adduser and useradd?
        – sonlexqt
        Oct 22 '15 at 10:20












        up vote
        78
        down vote













        Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:



        cat /etc/passwd


        OR



        less /etc/passwd
        more /etc/passwd


        You can also use awk:awk



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





        share|improve this answer





















        • how to add users by command ?
          – nux
          Jan 24 '14 at 19:31










        • You can use useradd command.
          – Mitch
          Jan 24 '14 at 19:32










        • @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
          – flindeberg
          Jul 24 '16 at 14:39















        up vote
        78
        down vote













        Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:



        cat /etc/passwd


        OR



        less /etc/passwd
        more /etc/passwd


        You can also use awk:awk



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





        share|improve this answer





















        • how to add users by command ?
          – nux
          Jan 24 '14 at 19:31










        • You can use useradd command.
          – Mitch
          Jan 24 '14 at 19:32










        • @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
          – flindeberg
          Jul 24 '16 at 14:39













        up vote
        78
        down vote










        up vote
        78
        down vote









        Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:



        cat /etc/passwd


        OR



        less /etc/passwd
        more /etc/passwd


        You can also use awk:awk



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





        share|improve this answer












        Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:



        cat /etc/passwd


        OR



        less /etc/passwd
        more /etc/passwd


        You can also use awk:awk



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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 24 '14 at 19:28









        Mitch

        83k14172228




        83k14172228












        • how to add users by command ?
          – nux
          Jan 24 '14 at 19:31










        • You can use useradd command.
          – Mitch
          Jan 24 '14 at 19:32










        • @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
          – flindeberg
          Jul 24 '16 at 14:39


















        • how to add users by command ?
          – nux
          Jan 24 '14 at 19:31










        • You can use useradd command.
          – Mitch
          Jan 24 '14 at 19:32










        • @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
          – flindeberg
          Jul 24 '16 at 14:39
















        how to add users by command ?
        – nux
        Jan 24 '14 at 19:31




        how to add users by command ?
        – nux
        Jan 24 '14 at 19:31












        You can use useradd command.
        – Mitch
        Jan 24 '14 at 19:32




        You can use useradd command.
        – Mitch
        Jan 24 '14 at 19:32












        @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
        – flindeberg
        Jul 24 '16 at 14:39




        @nux A bit late to the party, but from command line use adduser instead, useradd should be limited to scripts where the author really really knows what he is doing.
        – flindeberg
        Jul 24 '16 at 14:39










        up vote
        58
        down vote













        The easiest way to get this kind of information is getent - see manpage for the getent command Manpage icon. While that command gives the same output as cat /etc/passwd it is useful to remember because it will give you lists of several elements in the OS.



        To get a list of all users you type (as users are listed in /etc/passwd)



        getent passwd


        To add a user newuser to the system you would type



        sudo adduser newuser


        to create a user that has all default settings applied.



        Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type



        sudo adduser anyuser cdrom


        You delete a user (for instance obsolete) with



        sudo deluser obsolete


        If you want to delete his home directory/mails as well you type



        sudo deluser --remove-home obsolete


        And



        sudo deluser --remove-all-files obsolete


        will remove the user and all files owned by this user on the whole system.






        share|improve this answer



















        • 6




          It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
          – Marcin Kaminski
          Sep 25 '14 at 16:34










        • @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
          – ulkas
          Sep 28 at 8:25















        up vote
        58
        down vote













        The easiest way to get this kind of information is getent - see manpage for the getent command Manpage icon. While that command gives the same output as cat /etc/passwd it is useful to remember because it will give you lists of several elements in the OS.



        To get a list of all users you type (as users are listed in /etc/passwd)



        getent passwd


        To add a user newuser to the system you would type



        sudo adduser newuser


        to create a user that has all default settings applied.



        Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type



        sudo adduser anyuser cdrom


        You delete a user (for instance obsolete) with



        sudo deluser obsolete


        If you want to delete his home directory/mails as well you type



        sudo deluser --remove-home obsolete


        And



        sudo deluser --remove-all-files obsolete


        will remove the user and all files owned by this user on the whole system.






        share|improve this answer



















        • 6




          It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
          – Marcin Kaminski
          Sep 25 '14 at 16:34










        • @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
          – ulkas
          Sep 28 at 8:25













        up vote
        58
        down vote










        up vote
        58
        down vote









        The easiest way to get this kind of information is getent - see manpage for the getent command Manpage icon. While that command gives the same output as cat /etc/passwd it is useful to remember because it will give you lists of several elements in the OS.



        To get a list of all users you type (as users are listed in /etc/passwd)



        getent passwd


        To add a user newuser to the system you would type



        sudo adduser newuser


        to create a user that has all default settings applied.



        Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type



        sudo adduser anyuser cdrom


        You delete a user (for instance obsolete) with



        sudo deluser obsolete


        If you want to delete his home directory/mails as well you type



        sudo deluser --remove-home obsolete


        And



        sudo deluser --remove-all-files obsolete


        will remove the user and all files owned by this user on the whole system.






        share|improve this answer














        The easiest way to get this kind of information is getent - see manpage for the getent command Manpage icon. While that command gives the same output as cat /etc/passwd it is useful to remember because it will give you lists of several elements in the OS.



        To get a list of all users you type (as users are listed in /etc/passwd)



        getent passwd


        To add a user newuser to the system you would type



        sudo adduser newuser


        to create a user that has all default settings applied.



        Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type



        sudo adduser anyuser cdrom


        You delete a user (for instance obsolete) with



        sudo deluser obsolete


        If you want to delete his home directory/mails as well you type



        sudo deluser --remove-home obsolete


        And



        sudo deluser --remove-all-files obsolete


        will remove the user and all files owned by this user on the whole system.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        answered Feb 2 '14 at 18:50


























        community wiki





        guntbert









        • 6




          It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
          – Marcin Kaminski
          Sep 25 '14 at 16:34










        • @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
          – ulkas
          Sep 28 at 8:25














        • 6




          It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
          – Marcin Kaminski
          Sep 25 '14 at 16:34










        • @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
          – ulkas
          Sep 28 at 8:25








        6




        6




        It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
        – Marcin Kaminski
        Sep 25 '14 at 16:34




        It's useful to remember that getent doesn't just print the output of users in /etc/passwd but all users in all configured userdb backends on a given system, whether it's /etc/passwd or LDAP, etc.
        – Marcin Kaminski
        Sep 25 '14 at 16:34












        @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
        – ulkas
        Sep 28 at 8:25




        @MarcinKaminski is right, it also prints users setup in SSO systems who have access to the server. this answer is the the best one, with getent passwd being the right command
        – ulkas
        Sep 28 at 8:25










        up vote
        27
        down vote













        You can use compgen built-in too:



        compgen -u


        Will lists all users.






        share|improve this answer



























          up vote
          27
          down vote













          You can use compgen built-in too:



          compgen -u


          Will lists all users.






          share|improve this answer

























            up vote
            27
            down vote










            up vote
            27
            down vote









            You can use compgen built-in too:



            compgen -u


            Will lists all users.






            share|improve this answer














            You can use compgen built-in too:



            compgen -u


            Will lists all users.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            answered Jun 14 '17 at 12:51


























            community wiki





            Ravexina























                up vote
                24
                down vote













                This should get, under most normal situations, all normal (non-system, not weird, etc) users:



                awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd


                This works by:




                • reading in from /etc/passwd

                • using : as a delimiter

                • if the third field (the User ID number) is larger than 1000 and not 65534, the first field (the username of the user) is printed.


                This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:




                A user ID (UID) is a unique positive integer assigned by a Unix-like
                operating system to each user. Each user is identified to the system
                by its UID, and user names are generally used only as an interface for
                humans.



                UIDs are stored, along with their corresponding user names and other
                user-specific information, in the /etc/passwd file...



                The third field contains the UID, and the fourth field contains the
                group ID (GID), which by default is equal to the UID for all ordinary
                users.



                In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers
                that can represent values from zero to 4,294,967,296. However, it is
                advisable to use values only up to 65,534 in order to maintain
                compatibility with systems using older kernels or filesystems that can
                only accommodate 16-bit UIDs.



                The UID of 0 has a special role: it is always the root account (i.e.,
                the omnipotent administrative user). Although the user name can be
                changed on this account and additional accounts can be created with
                the same UID, neither action is wise from a security point of view.



                The UID 65534 is commonly reserved for nobody, a user with no system
                privileges, as opposed to an ordinary (i.e., non-privileged) user.
                This UID is often used for individuals accessing the system remotely
                via FTP (file transfer protocol) or HTTP (hypertext transfer
                protocol).



                UIDs 1 through 99 are traditionally reserved for special system users
                (sometimes called pseudo-users), such as wheel, daemon, lp, operator,
                news, mail, etc. These users are administrators who do not need total
                root powers, but who perform some administrative tasks and thus need
                more privileges than those given to ordinary users.



                Some Linux distributions (i.e., versions) begin UIDs for
                non-privileged users at 100. Others, such as Red Hat, begin them at
                500, and still others, such Debian, start them at 1000. Because of the
                differences among distributions, manual intervention can be necessary
                if multiple distributions are used in a network in an organization.



                Also, it can be convenient to reserve a block of UIDs for local users,
                such as 1000 through 9999, and another block for remote users (i.e.,
                users elsewhere on the network), such as 10000 to 65534. The important
                thing is to decide on a scheme and adhere to it.



                Among the advantages of this practice of reserving blocks of numbers
                for particular types of users is that it makes it more convenient to
                search through system logs for suspicious user activity.



                Contrary to popular belief, it is not necessary that each entry in the
                UID field be unique. However, non-unique UIDs can cause security
                problems, and thus UIDs should be kept unique across the entire
                organization. Likewise, recycling of UIDs from former users should be
                avoided for as long as possible.







                share|improve this answer



























                  up vote
                  24
                  down vote













                  This should get, under most normal situations, all normal (non-system, not weird, etc) users:



                  awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd


                  This works by:




                  • reading in from /etc/passwd

                  • using : as a delimiter

                  • if the third field (the User ID number) is larger than 1000 and not 65534, the first field (the username of the user) is printed.


                  This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:




                  A user ID (UID) is a unique positive integer assigned by a Unix-like
                  operating system to each user. Each user is identified to the system
                  by its UID, and user names are generally used only as an interface for
                  humans.



                  UIDs are stored, along with their corresponding user names and other
                  user-specific information, in the /etc/passwd file...



                  The third field contains the UID, and the fourth field contains the
                  group ID (GID), which by default is equal to the UID for all ordinary
                  users.



                  In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers
                  that can represent values from zero to 4,294,967,296. However, it is
                  advisable to use values only up to 65,534 in order to maintain
                  compatibility with systems using older kernels or filesystems that can
                  only accommodate 16-bit UIDs.



                  The UID of 0 has a special role: it is always the root account (i.e.,
                  the omnipotent administrative user). Although the user name can be
                  changed on this account and additional accounts can be created with
                  the same UID, neither action is wise from a security point of view.



                  The UID 65534 is commonly reserved for nobody, a user with no system
                  privileges, as opposed to an ordinary (i.e., non-privileged) user.
                  This UID is often used for individuals accessing the system remotely
                  via FTP (file transfer protocol) or HTTP (hypertext transfer
                  protocol).



                  UIDs 1 through 99 are traditionally reserved for special system users
                  (sometimes called pseudo-users), such as wheel, daemon, lp, operator,
                  news, mail, etc. These users are administrators who do not need total
                  root powers, but who perform some administrative tasks and thus need
                  more privileges than those given to ordinary users.



                  Some Linux distributions (i.e., versions) begin UIDs for
                  non-privileged users at 100. Others, such as Red Hat, begin them at
                  500, and still others, such Debian, start them at 1000. Because of the
                  differences among distributions, manual intervention can be necessary
                  if multiple distributions are used in a network in an organization.



                  Also, it can be convenient to reserve a block of UIDs for local users,
                  such as 1000 through 9999, and another block for remote users (i.e.,
                  users elsewhere on the network), such as 10000 to 65534. The important
                  thing is to decide on a scheme and adhere to it.



                  Among the advantages of this practice of reserving blocks of numbers
                  for particular types of users is that it makes it more convenient to
                  search through system logs for suspicious user activity.



                  Contrary to popular belief, it is not necessary that each entry in the
                  UID field be unique. However, non-unique UIDs can cause security
                  problems, and thus UIDs should be kept unique across the entire
                  organization. Likewise, recycling of UIDs from former users should be
                  avoided for as long as possible.







                  share|improve this answer

























                    up vote
                    24
                    down vote










                    up vote
                    24
                    down vote









                    This should get, under most normal situations, all normal (non-system, not weird, etc) users:



                    awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd


                    This works by:




                    • reading in from /etc/passwd

                    • using : as a delimiter

                    • if the third field (the User ID number) is larger than 1000 and not 65534, the first field (the username of the user) is printed.


                    This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:




                    A user ID (UID) is a unique positive integer assigned by a Unix-like
                    operating system to each user. Each user is identified to the system
                    by its UID, and user names are generally used only as an interface for
                    humans.



                    UIDs are stored, along with their corresponding user names and other
                    user-specific information, in the /etc/passwd file...



                    The third field contains the UID, and the fourth field contains the
                    group ID (GID), which by default is equal to the UID for all ordinary
                    users.



                    In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers
                    that can represent values from zero to 4,294,967,296. However, it is
                    advisable to use values only up to 65,534 in order to maintain
                    compatibility with systems using older kernels or filesystems that can
                    only accommodate 16-bit UIDs.



                    The UID of 0 has a special role: it is always the root account (i.e.,
                    the omnipotent administrative user). Although the user name can be
                    changed on this account and additional accounts can be created with
                    the same UID, neither action is wise from a security point of view.



                    The UID 65534 is commonly reserved for nobody, a user with no system
                    privileges, as opposed to an ordinary (i.e., non-privileged) user.
                    This UID is often used for individuals accessing the system remotely
                    via FTP (file transfer protocol) or HTTP (hypertext transfer
                    protocol).



                    UIDs 1 through 99 are traditionally reserved for special system users
                    (sometimes called pseudo-users), such as wheel, daemon, lp, operator,
                    news, mail, etc. These users are administrators who do not need total
                    root powers, but who perform some administrative tasks and thus need
                    more privileges than those given to ordinary users.



                    Some Linux distributions (i.e., versions) begin UIDs for
                    non-privileged users at 100. Others, such as Red Hat, begin them at
                    500, and still others, such Debian, start them at 1000. Because of the
                    differences among distributions, manual intervention can be necessary
                    if multiple distributions are used in a network in an organization.



                    Also, it can be convenient to reserve a block of UIDs for local users,
                    such as 1000 through 9999, and another block for remote users (i.e.,
                    users elsewhere on the network), such as 10000 to 65534. The important
                    thing is to decide on a scheme and adhere to it.



                    Among the advantages of this practice of reserving blocks of numbers
                    for particular types of users is that it makes it more convenient to
                    search through system logs for suspicious user activity.



                    Contrary to popular belief, it is not necessary that each entry in the
                    UID field be unique. However, non-unique UIDs can cause security
                    problems, and thus UIDs should be kept unique across the entire
                    organization. Likewise, recycling of UIDs from former users should be
                    avoided for as long as possible.







                    share|improve this answer














                    This should get, under most normal situations, all normal (non-system, not weird, etc) users:



                    awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd


                    This works by:




                    • reading in from /etc/passwd

                    • using : as a delimiter

                    • if the third field (the User ID number) is larger than 1000 and not 65534, the first field (the username of the user) is printed.


                    This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:




                    A user ID (UID) is a unique positive integer assigned by a Unix-like
                    operating system to each user. Each user is identified to the system
                    by its UID, and user names are generally used only as an interface for
                    humans.



                    UIDs are stored, along with their corresponding user names and other
                    user-specific information, in the /etc/passwd file...



                    The third field contains the UID, and the fourth field contains the
                    group ID (GID), which by default is equal to the UID for all ordinary
                    users.



                    In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers
                    that can represent values from zero to 4,294,967,296. However, it is
                    advisable to use values only up to 65,534 in order to maintain
                    compatibility with systems using older kernels or filesystems that can
                    only accommodate 16-bit UIDs.



                    The UID of 0 has a special role: it is always the root account (i.e.,
                    the omnipotent administrative user). Although the user name can be
                    changed on this account and additional accounts can be created with
                    the same UID, neither action is wise from a security point of view.



                    The UID 65534 is commonly reserved for nobody, a user with no system
                    privileges, as opposed to an ordinary (i.e., non-privileged) user.
                    This UID is often used for individuals accessing the system remotely
                    via FTP (file transfer protocol) or HTTP (hypertext transfer
                    protocol).



                    UIDs 1 through 99 are traditionally reserved for special system users
                    (sometimes called pseudo-users), such as wheel, daemon, lp, operator,
                    news, mail, etc. These users are administrators who do not need total
                    root powers, but who perform some administrative tasks and thus need
                    more privileges than those given to ordinary users.



                    Some Linux distributions (i.e., versions) begin UIDs for
                    non-privileged users at 100. Others, such as Red Hat, begin them at
                    500, and still others, such Debian, start them at 1000. Because of the
                    differences among distributions, manual intervention can be necessary
                    if multiple distributions are used in a network in an organization.



                    Also, it can be convenient to reserve a block of UIDs for local users,
                    such as 1000 through 9999, and another block for remote users (i.e.,
                    users elsewhere on the network), such as 10000 to 65534. The important
                    thing is to decide on a scheme and adhere to it.



                    Among the advantages of this practice of reserving blocks of numbers
                    for particular types of users is that it makes it more convenient to
                    search through system logs for suspicious user activity.



                    Contrary to popular belief, it is not necessary that each entry in the
                    UID field be unique. However, non-unique UIDs can cause security
                    problems, and thus UIDs should be kept unique across the entire
                    organization. Likewise, recycling of UIDs from former users should be
                    avoided for as long as possible.








                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 8 '15 at 20:09


























                    community wiki





                    2 revs
                    Wilf























                        up vote
                        16
                        down vote













                        list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)



                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow


                        add new user



                        sudo adduser new_username


                        or



                        sudo useradd new_username


                        delete/remove username



                        sudo userdel username


                        If you want to delete the home directory (default the directory /home/username)



                        sudo deluser --remove-home username


                        or



                        sudo rm -r /path/to/user_home_dir


                        If you want to delete all files from the system from this user (not only is the home diretory)



                        sudo deluser --remove-all-files





                        share|improve this answer



















                        • 1




                          Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                          – s3lph
                          Sep 25 '14 at 20:13






                        • 1




                          awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                          – jeff musk
                          Jun 20 at 5:43

















                        up vote
                        16
                        down vote













                        list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)



                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow


                        add new user



                        sudo adduser new_username


                        or



                        sudo useradd new_username


                        delete/remove username



                        sudo userdel username


                        If you want to delete the home directory (default the directory /home/username)



                        sudo deluser --remove-home username


                        or



                        sudo rm -r /path/to/user_home_dir


                        If you want to delete all files from the system from this user (not only is the home diretory)



                        sudo deluser --remove-all-files





                        share|improve this answer



















                        • 1




                          Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                          – s3lph
                          Sep 25 '14 at 20:13






                        • 1




                          awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                          – jeff musk
                          Jun 20 at 5:43















                        up vote
                        16
                        down vote










                        up vote
                        16
                        down vote









                        list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)



                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow


                        add new user



                        sudo adduser new_username


                        or



                        sudo useradd new_username


                        delete/remove username



                        sudo userdel username


                        If you want to delete the home directory (default the directory /home/username)



                        sudo deluser --remove-home username


                        or



                        sudo rm -r /path/to/user_home_dir


                        If you want to delete all files from the system from this user (not only is the home diretory)



                        sudo deluser --remove-all-files





                        share|improve this answer














                        list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)



                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow


                        add new user



                        sudo adduser new_username


                        or



                        sudo useradd new_username


                        delete/remove username



                        sudo userdel username


                        If you want to delete the home directory (default the directory /home/username)



                        sudo deluser --remove-home username


                        or



                        sudo rm -r /path/to/user_home_dir


                        If you want to delete all files from the system from this user (not only is the home diretory)



                        sudo deluser --remove-all-files






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        answered Sep 25 '14 at 15:47


























                        community wiki





                        Donovan Vesters









                        • 1




                          Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                          – s3lph
                          Sep 25 '14 at 20:13






                        • 1




                          awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                          – jeff musk
                          Jun 20 at 5:43
















                        • 1




                          Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                          – s3lph
                          Sep 25 '14 at 20:13






                        • 1




                          awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                          – jeff musk
                          Jun 20 at 5:43










                        1




                        1




                        Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                        – s3lph
                        Sep 25 '14 at 20:13




                        Maybe you should explain the difference between adduser and useradd. An also add the sudo-prefix to the first command. The password shadow file can only be read as root.
                        – s3lph
                        Sep 25 '14 at 20:13




                        1




                        1




                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                        – jeff musk
                        Jun 20 at 5:43






                        awk -F':' '$2 ~ "$" {print $1}' /etc/shadow showed me all user including bin, daemon, etc. and threw this warning: escape sequence $' treated as plain $' I found this post stackoverflow.com/a/25867768/847954 and added one more backslash and it worked fine: awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow
                        – jeff musk
                        Jun 20 at 5:43












                        up vote
                        7
                        down vote













                        Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.



                        user (tab tab)


                        gives me as possible options
                        useradd userdel usermod users users-admin

                        if you want to know more about a command google it or type man
                        man useradd
                        gives
                        useradd - create a new user or update default new user information
                        ...
                        ...



                        to list users you should go with what Mitch said.



                        Hope that helps I love tab completion in bash saves me from remembering things.






                        share|improve this answer

























                          up vote
                          7
                          down vote













                          Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.



                          user (tab tab)


                          gives me as possible options
                          useradd userdel usermod users users-admin

                          if you want to know more about a command google it or type man
                          man useradd
                          gives
                          useradd - create a new user or update default new user information
                          ...
                          ...



                          to list users you should go with what Mitch said.



                          Hope that helps I love tab completion in bash saves me from remembering things.






                          share|improve this answer























                            up vote
                            7
                            down vote










                            up vote
                            7
                            down vote









                            Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.



                            user (tab tab)


                            gives me as possible options
                            useradd userdel usermod users users-admin

                            if you want to know more about a command google it or type man
                            man useradd
                            gives
                            useradd - create a new user or update default new user information
                            ...
                            ...



                            to list users you should go with what Mitch said.



                            Hope that helps I love tab completion in bash saves me from remembering things.






                            share|improve this answer












                            Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.



                            user (tab tab)


                            gives me as possible options
                            useradd userdel usermod users users-admin

                            if you want to know more about a command google it or type man
                            man useradd
                            gives
                            useradd - create a new user or update default new user information
                            ...
                            ...



                            to list users you should go with what Mitch said.



                            Hope that helps I love tab completion in bash saves me from remembering things.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 24 '14 at 19:38









                            user239243

                            1043




                            1043






















                                up vote
                                6
                                down vote













                                To find out the users which have home-directories in the /home-folder on the machine, run the following commands



                                cd /home
                                ls


                                You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.






                                share|improve this answer



















                                • 7




                                  This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                  – David Foerster
                                  Dec 19 '14 at 0:57















                                up vote
                                6
                                down vote













                                To find out the users which have home-directories in the /home-folder on the machine, run the following commands



                                cd /home
                                ls


                                You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.






                                share|improve this answer



















                                • 7




                                  This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                  – David Foerster
                                  Dec 19 '14 at 0:57













                                up vote
                                6
                                down vote










                                up vote
                                6
                                down vote









                                To find out the users which have home-directories in the /home-folder on the machine, run the following commands



                                cd /home
                                ls


                                You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.






                                share|improve this answer














                                To find out the users which have home-directories in the /home-folder on the machine, run the following commands



                                cd /home
                                ls


                                You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jul 24 '16 at 14:45


























                                community wiki





                                3 revs, 3 users 60%
                                anvesh









                                • 7




                                  This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                  – David Foerster
                                  Dec 19 '14 at 0:57














                                • 7




                                  This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                  – David Foerster
                                  Dec 19 '14 at 0:57








                                7




                                7




                                This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                – David Foerster
                                Dec 19 '14 at 0:57




                                This only shows the content of /home. While Ubuntu puts user directories there by default, it's in no way mandatory.
                                – David Foerster
                                Dec 19 '14 at 0:57





                                protected by Radu Rădeanu Feb 22 '15 at 17:21



                                Thank you for your interest in this question.
                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                Would you like to answer one of these unanswered questions instead?



                                Popular posts from this blog

                                flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                Mangá

                                Eduardo VII do Reino Unido