{"id":449476,"date":"2022-05-18T16:00:56","date_gmt":"2022-05-18T13:00:56","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-list-users-in-linux\/"},"modified":"2022-05-18T16:00:56","modified_gmt":"2022-05-18T13:00:56","slug":"how-to-list-users-in-linux","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/","title":{"rendered":"#How to List Users in Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a26b6a6db64d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a26b6a6db64d\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#%E2%80%9CHow_to_List_Users_in_Linux%E2%80%9D\" >&#8220;How to List Users in Linux&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#User_Accounts\" >User Accounts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#List_Users_With_the_cat_Command\" >List Users With the cat Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#The_awk_Command\" >The awk Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#The_cut_Command\" >The cut Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#The_compgen_Command\" >The compgen Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#UID_MIN_and_UID_MAX\" >UID MIN and UID MAX<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#The_getent_Command\" >The getent Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-list-users-in-linux\/#Power_and_Simplicity\" >Power and Simplicity<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_List_Users_in_Linux%E2%80%9D\"><\/span>&#8220;How to List Users in Linux&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<figure style=\"width: 1200px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-791996\" data-pagespeed-lazy-srcset=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Linux laptop showing a bash prompt\" width=\"1200\" height=\"675\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">fatmawati achmad zaenuri\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>Linux is a multiuser operating system, so creating numerous user accounts is easy. Over time, it\u2019s easy to lose track of which accounts are required. Listing user accounts helps you manage them.<\/p>\n<h2 id=\"user-accounts\"><span class=\"ez-toc-section\" id=\"User_Accounts\"><\/span>User Accounts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Advances in <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/technology\/\" data-internallinksmanager029f6b8e52c=\"4\" title=\"Technology\" target=\"_blank\" rel=\"noopener\">technology<\/a> often bring their own new problems. As soon as computers were able to support multiple users, the need to ring-fence and encapsulate each person\u2019s work from everyone else became <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>arent. This led to the concept of user accounts. Each user has a named ID and a password. These are the credentials that let them log into their account. Their files are kept in an area that is private to each user.<\/p>\n<p>On a busy system, it is easy to lose sight of which accounts you have created, and which are no longer needed. From a security point of view, it is bad practice to keep user accounts that you no longer need to be configured and accessible on your computer. You should remove those users.<\/p>\n<p>Even if you don\u2019t have other people using your computer you might have created some accounts just to learn how to do it, or to learn and practice administration processes.<\/p>\n<p>The first step is to list the user accounts that are configured on your computer. That lets you review them and make a judgment call on which can be deleted. There are several methods to list users. No matter which distribution you\u2019re using, these techniques should work for you without needing to install any applications or utilities.<\/p>\n<h2 id=\"the-cat-command\"><span class=\"ez-toc-section\" id=\"List_Users_With_the_cat_Command\"><\/span>List Users With the cat Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A list of the configured users is maintained, along with information about each user, in the \u201c\/etc\/passwd\u201d file. This is a text file that regular users can list to the terminal window. You don\u2019t need to use <code>sudo<\/code> to look into the \u201c\/etc\/passwd\u201d file.<\/p>\n<p>We can use the <code>cat<\/code> command to send the contents of the \u201c\/etc\/passwd\u201d file to the terminal window. This will list the entire contents of the file. This means you\u2019ll also see the entries for user accounts that are owned by processes and the system, not by people.<\/p>\n<pre>cat \/etc\/passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-803909 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Sending the contents of the \/etc\/passwd file to the terminal window with cat\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>There\u2019s a line of dense information reported for each user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-803911 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/2-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The contents of the \/etc\/passwd file\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The information for the user account called \u201cdave\u201d contains these pieces of information, with colons \u201c<code>:<\/code>\u201d between them.<\/p>\n<ul>\n<li><strong>dave<\/strong>: The name of the user account. Usually the name of the person who owns the account.<\/li>\n<li><strong>x<\/strong>: At one time, this held the password for the account. Nowadays, passwords are stored in the \u201c\/etc\/shadow\u201d file. The \u201cx\u201d means the password is in that file.<\/li>\n<li><strong>1000<\/strong>: The user ID for this account. All user accounts have a unique numeric ID. Regular user accounts usually start at 1000, with each new account taking the next free ID, such as 1001, 1002, and so on.<\/li>\n<li><strong>1000<\/strong>: The group ID of the default group the user belongs to. In normal circumstances, the default group has the same value as the user ID.<\/li>\n<li><strong>dave,,,<\/strong>: A collection of optional extra information about the user. This field contains data with commas \u201c<code>,<\/code>\u201d between them. They can hold things like the full name of the user, their office number, and their telephone number. The entry for user account \u201cmary\u201d shows her full name is Mary Quinn.<\/li>\n<li><strong>\/home\/dave<\/strong>: The path to the user\u2019s home folder.<\/li>\n<li><strong>\/bin\/bash<\/strong>: The default shell for this user.<\/li>\n<\/ul>\n<p>If we pipe the output from this command through the <code>wc<\/code> utility and use the <code>-l<\/code> (lines) option we can count the lines in the file. That\u2019ll give us the number of accounts configured on this computer.<\/p>\n<pre>cat \/etc\/passwd | wc -l<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-803912 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Counting the number of accounts in the \/etc\/passwd file\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>That figure includes the system accounts and users created by applications. There are about 400 regular users configured on this computer. Your result is likely to be a lot less.<\/p>\n<p>With that many accounts, it\u2019s more convenient to use <code>less<\/code> to view the \u201c\/etc\/passwd\u201d file.<\/p>\n<pre>less \/etc\/passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803913\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Opening the \/etc\/passwd file in less\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Using <code>less<\/code> also allows you to search within the output, should you want to look for a particular user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803914\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/5.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Searching for the mary account in the \/etc\/passwd file, in less\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 id=\"the-awk-command\"><span class=\"ez-toc-section\" id=\"The_awk_Command\"><\/span>The awk Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Using the <code>awk<\/code> command we can display just the username. This can be useful when you\u2019re writing a script that needs to do something to a lot of user accounts. Listing the user account names and redirecting them into a text file can be a great time saver. All you need to do then is copy and paste the rest of the command onto each line.<\/p>\n<p>We\u2019ll tell awk to use the colon \u201c:\u201d as the field separator, and to print the first field. We\u2019ll use the -F (field separator) option.<\/p>\n<pre>awk -F: '{print $1}' \/etc\/passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803916\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/6.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"An awk command to select only the user names from the \/etc\/passwd\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The user account names are written to the terminal window without any of the other account information.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803917\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/7.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The user account names displayed in the terminal window\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 id=\"the-cut-command\"><span class=\"ez-toc-section\" id=\"The_cut_Command\"><\/span>The cut Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We can achieve the same sort of thing using the <code>cut<\/code> command. We need to use the <code>-d<\/code> (delimiter) option and ask it to select the first field only, using the <code>-f<\/code> (fields) option.<\/p>\n<pre>cutr -d: -f1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803918\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/8.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the cut command to display only the usernames from the \/etc\/passwd file\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This lists all of the user accounts, including the system and other non-human accounts.<\/p>\n<h2 id=\"the-compgen-command\"><span class=\"ez-toc-section\" id=\"The_compgen_Command\"><\/span>The compgen Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>compgen<\/code> command can be used with the <code>-u<\/code> (user) option to list the user accounts. We\u2019ll pipe the output through the <code>column<\/code> command to list the user accounts in columns, instead of one long list with a single user name per line.<\/p>\n<pre>compgen -u | column<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803920\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/9.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the compgen and column commands to list the user account names from the \/etc\/passwd file in columns\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Again, the first user accounts listed belong to processes, not humans.<\/p>\n<h2 id=\"uid-min-and-uid-max\"><span class=\"ez-toc-section\" id=\"UID_MIN_and_UID_MAX\"><\/span>UID MIN and UID MAX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>User accounts are given a numeric ID, which we saw earlier. Usually, the regular human user accounts start at 1000, and the system, non-human, user accounts start at 0. The ID of the root account is 0.<\/p>\n<p>If we can verify the lowest and highest possible user IDs, we can use that information to select the user accounts that are between those two values. That will let us select only the user accounts belonging to real people.<\/p>\n<p>Linux keeps track of these two values using configuration parameters called <code>UID_MIN<\/code> and <code>UID_MAX<\/code> . These are held in the \u201c\/etc\/login.defs\u201d file. We can easily see these values using <code>grep<\/code>.<\/p>\n<p>We\u2019re going to use the <code>-E<\/code> (extended regex) option. Our search string looks for lines that begin with \u201cUID_MIN\u201d or \u201cUID_MAX\u201d in the \u201c\/etc\/login.defs\u201d file. The caret \u201c<code>^<\/code>\u201d represents the beginning of a line.<\/p>\n<pre>grep -E '^UID_MIN|^UID_MAX' \/etc\/login.defs<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803921\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/10.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"110\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The range for user IDs on this computer is from 1000 to 60,000.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Use Regular Expressions (regexes) on Linux<\/em><\/strong><\/p>\n<h2 id=\"the-getent-command\"><span class=\"ez-toc-section\" id=\"The_getent_Command\"><\/span>The getent Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>getent<\/code> command reads information from system databases. We can tell it to list the entries in the \u201c\/etc\/passwd\u201d file by using \u201cpasswd\u201d as a parameter.<\/p>\n<pre>getent passwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803923\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/11.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using getent to dump the \/etc\/passwd file to the terminal window\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This gives us the same readout we can get using <code>cat<\/code>. But where <code>getent<\/code> shines is by accepting values known as \u201ckeys.\u201d A key dictates which information <code>getent<\/code> reports on. If we want to see the entry for a single user, we can pass in their user account name on the command line.<\/p>\n<pre>getent passwd Sarah<\/pre>\n<p>Note that the user account name is case-sensitive.<\/p>\n<pre>getent passwd sarah<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803924\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/12.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Looking for a single user account with getent\" width=\"645\" height=\"130\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can also pass in the upper and lower limits of the user account IDs we want to see. To see absolutely all the regular user accounts, we can use the values from <code>UID_MIN<\/code> and <code>UID_MAX<\/code>.<\/p>\n<pre>getent passwd {1000..60000}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803925\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/13.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using upper and lower account IDs with getent\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This takes some time to run. Eventually, you\u2019ll be returned to the command prompt.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803926\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/14.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The contents of the \/etc\/passwd file sent to the terminal window by getent\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The reason for the long execution time is that\u00a0<code>getent<\/code> tries to find matches for all of the user account values right up to 60000.<\/p>\n<p>Let\u2019s see what the highest user account ID is. We\u2019ll use the <code>cut<\/code> command, but this time we\u2019ll ask for field three, the user ID field. We\u2019ll pipe the output through <code>sort<\/code> and use the <code>-g<\/code> (<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a> numeric sort) option.<\/p>\n<pre>cut -d: -f3 \/etc\/passwd | sort -g<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803927\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/15.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The command to pipe the output from cut into the sort command\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The highest ID value of a human-owned user account is 1401.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803928\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/16.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"A sorted list of user account IDs\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>User id 65534 is assigned to the system concept of \u201cnobody.\u201d<\/p>\n<pre>getent passwd {65534..65534}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803930\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/new-17.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The system user nobody, with ID 65534\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>So we know that instead of using the <code>UID_MAX<\/code> value of 60000, on this computer we can use a more realistic value like 1500. That\u2019ll speed things up nicely. We\u2019ll also pipe the output through <code>cut<\/code> to extract just the names of the user accounts.<\/p>\n<p>getent passwd {1000..1500} | cut -d: -f1<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803931\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/18.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The output of getent piped through cut to list user account names \" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The users are listed and we\u2019re returned im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely to the command prompt.<\/p>\n<p>Instead of piping the output through <code>cut<\/code>, let\u2019s pipe the output through <code>wc<\/code> and count the lines once more. That\u2019ll give us the number of \u201creal\u201d user accounts.<\/p>\n<pre>getent passwd {1000..1500} | wc -l<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803932\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/19.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Counting the regular user accounts with getent and wc\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can now see that on this computer, definitively, there are 400 configured, human-owned, user accounts.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Power_and_Simplicity\"><\/span>Power and Simplicity<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One of these techniques is sure to suit your needs when you need to review the user accounts on a Linux computer. These commands should be present on all distributions, and none of them require <code>sudo<\/code>\u00a0access, so they are all available to every user.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Control sudo Access on Linux<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/803907\/linux-list-users\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to List Users in Linux&#8221; fatmawati achmad zaenuri\/Shutterstock.com Linux is a multiuser operating system, so creating numerous user accounts is easy. Over time, it\u2019s easy to lose track of which accounts are required. Listing user accounts helps you manage them. User Accounts Advances in technology often bring their own new problems. As soon as&#8230;<\/p>\n","protected":false},"author":1,"featured_media":449477,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-449476","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/449476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=449476"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/449476\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/449477"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=449476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=449476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=449476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}