{"id":23595,"date":"2019-09-07T17:53:47","date_gmt":"2019-09-07T14:53:47","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=23595"},"modified":"2026-03-20T01:02:12","modified_gmt":"2026-03-19T22:02:12","slug":"how-to-list-users-in-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-list-users-in-linux\/","title":{"rendered":"How To List Users in Linux"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Do you wan to List \/ Find users in a Linux system?. Once you have a running server with a given number of users logging into it. Sometimes it becomes necessary to get to know all the users that were created in the server for auditing purposes or just for the sake of scheduled house-keeping. In Linux, there are very interesting ways and utilities that you can ride on to get your users. The following  are some of the most used ones.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Looking at the \/etc\/passwd file<\/h2>\n\n\n\n<p>After the creation of every user, their details are usually stored in the \/etc\/passwd file. This includes all users including system-related users like root and the like.<\/p>\n\n\n\n<p>To view the file, just cat into it and you will get all of them. If the file is too long, pipe it into a less pager and peruse it like a boss! The first column will give you the names of your precious users.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo cat \/etc\/passwd\n<\/strong>\nroot:x:0:0:root:\/root:\/bin\/bash\ndaemon:x:1:1:daemon:\/usr\/sbin:\/usr\/sbin\/nologin\nbin:x:2:2:bin:\/bin:\/usr\/sbin\/nologin\nsys:x:3:3:sys:\/dev:\/usr\/sbin\/nologin\nsync:x:4:65534:sync:\/bin:\/bin\/sync\ngames:x:5:60:games:\/usr\/games:\/usr\/sbin\/nologin\nman:x:6:12:man:\/var\/cache\/man:\/usr\/sbin\/nologin\nlp:x:7:7:lp:\/var\/spool\/lpd:\/usr\/sbin\/nologin\nmail:x:8:8:mail:\/var\/mail:\/usr\/sbin\/nologin\nnews:x:9:9:news:\/var\/spool\/news:\/usr\/sbin\/nologin\nuucp:x:10:10:uucp:\/var\/spool\/uucp:\/usr\/sbin\/nologin\nproxy:x:13:13:proxy:\/bin:\/usr\/sbin\/nologin\nwww-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin\nbackup:x:34:34:backup:\/var\/backups:\/usr\/sbin\/nologin\nlist:x:38:38:Mailing List Manager:\/var\/list:\/usr\/sbin\/nologin\nirc:x:39:39:ircd:\/var\/run\/ircd:\/usr\/sbin\/nologin<\/pre>\n\n\n\n<p>As you can guess, you can add filters to get the desired output. To list all users beginning with letter G, just pipe the cat command to grep and you will have your results.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo cat \/etc\/passwd | grep G\n<\/strong>\ngnats:x:41:41:Gnats Bug-Reporting System (admin):\/var\/lib\/gnats:\/usr\/sbin\/nologin\nGorrety:x:1001:1001::\/home\/Gorrety:\/bin\/sh<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using getent command<\/h2>\n\n\n\n<p>The getent command displays entries from databases supported by the Name Service Switch libraries, which are configured in <strong>\/etc\/nsswitch.conf<\/strong>. If you check your <strong>\/etc\/nsswitch.conf<\/strong>, you will notice passwd is configured therein. Test it by running the below command. It should return all <strong>\/etc\/passwd<\/strong> entries.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo getent passwd<\/strong>\n\nroot:x:0:0:root:\/root:\/bin\/bash\ndaemon:x:1:1:daemon:\/usr\/sbin:\/usr\/sbin\/nologin\nbin:x:2:2:bin:\/bin:\/usr\/sbin\/nologin\nsys:x:3:3:sys:\/dev:\/usr\/sbin\/nologin\nsync:x:4:65534:sync:\/bin:\/bin\/sync\ngames:x:5:60:games:\/usr\/games:\/usr\/sbin\/nologin\nman:x:6:12:man:\/var\/cache\/man:\/usr\/sbin\/nologin\nlp:x:7:7:lp:\/var\/spool\/lpd:\/usr\/sbin\/nologin\nmail:x:8:8:mail:\/var\/mail:\/usr\/sbin\/nologin\nnews:x:9:9:news:\/var\/spool\/news:\/usr\/sbin\/nologin\nuucp:x:10:10:uucp:\/var\/spool\/uucp:\/usr\/sbin\/nologin\nproxy:x:13:13:proxy:\/bin:\/usr\/sbin\/nologin\nwww-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin\nbackup:x:34:34:backup:\/var\/backups:\/usr\/sbin\/nologin\nlist:x:38:38:Mailing List Manager:\/var\/list:\/usr\/sbin\/nologin\nirc:x:39:39:ircd:\/var\/run\/ircd:\/usr\/sbin\/nologin\ngnats:x:41:41:Gnats Bug-Reporting System (admin):\/var\/lib\/gnats:\/usr\/sbin\/nologin<\/pre>\n\n\n\n<p>It can also be piped to grep for filteration. To return all entries containing letter t, do:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo getent passwd | grep t<\/strong>\n\nroot:x:0:0:root:\/root:\/bin\/bash\nwww-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin\nlist:x:38:38:Mailing List Manager:\/var\/list:\/usr\/sbin\/nologin\ngnats:x:41:41:Gnats Bug-Reporting System (admin):\/var\/lib\/gnats:\/usr\/sbin\/nologin\nnobody:x:65534:65534:nobody:\/nonexistent:\/usr\/sbin\/nologin\nsystemd-network:x:100:102:systemd Network Management,,,:\/run\/systemd\/netif:\/usr\/sbin\/nologin\nsystemd-resolve:x:101:103:systemd Resolver,,,:\/run\/systemd\/resolve:\/usr\/sbin\/nologin\nmessagebus:x:103:107::\/nonexistent:\/usr\/sbin\/nologin\n_apt:x:104:65534::\/nonexistent:\/usr\/sbin\/nologin\npollinate:x:110:1::\/var\/cache\/pollinate:\/bin\/false\ntech:x:1000:1000:,,,:\/home\/tech:\/usr\/bin\/zsh\nGorrety:x:1001:1001::\/home\/Gorrety:\/bin\/sh<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">To return entries for a specific user, do<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo getent passwd Gorrety<\/strong>\n\nGorrety:x:1001:1001::\/home\/Gorrety:\/bin\/sh<\/pre>\n\n\n\n<p>Getent can list all users with their UID in a given range. For example, to list all users with UID from 900 to 2000, do:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$<strong> sudo getent passwd {900..2000}<\/strong>\n\ntech:x:1000:1000:,,,:\/home\/tech:\/usr\/bin\/zsh\nGorrety:x:1001:1001::\/home\/Gorrety:\/bin\/sh<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using the users utility<\/h2>\n\n\n\n<p><em>users<\/em> prints the user names of users currently logged in to the current host<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <strong>sudo users<\/strong>\ntech jkiiru jmwang root<\/pre>\n\n\n\n<p>Conclusion<\/p>\n\n\n\n<p>Listing users will never be a problem anymore. Note that you can add other filters to the getent command to either list the first column of the file or whatever you would wish to achieve. The guide was a basic way to check the users in the system and we hope it was fun. Check out other interesting guides below:<\/p>\n\n\n\n<p><a href=\"https:\/\/computingforgeeks.com\/how-to-use-linux-chown-command-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How To use Linux chown command with examples<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/computingforgeeks.com\/how-to-use-scp-command-to-securely-transfer-files-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How to use scp command to securely transfer files with examples<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/computingforgeeks.com\/top-10-free-backup-software-for-linux\/\" target=\"_blank\">Top 10 Free Backup software for Linux<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/computingforgeeks.com\/netstat-vs-ss-usage-guide-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">netstat vs ss usage guide on Linux<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\"How to use rsync command on Linux\/Unix with examples (opens in a new tab)\" href=\"https:\/\/computingforgeeks.com\/rsync-command-linux-examples\/\" target=\"_blank\">How to use rsync command on Linux\/Unix with examples<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/computingforgeeks.com\/change-ssh-port-centos-rhel-fedora-with-selinux\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How To Change SSH Port on CentOS \/ RHEL &amp; Fedora With SELinux<\/a><\/p>\n\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Do you wan to List \/ Find users in a Linux system?. Once you have a running server with a given number of users logging into it. Sometimes it becomes necessary to get to know all the users that were created in the server for auditing purposes or just for the sake of scheduled &#8230; <a title=\"How To List Users in Linux\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-list-users-in-linux\/\" aria-label=\"Read more about How To List Users in Linux\">Read more<\/a><\/p>\n","protected":false},"author":7,"featured_media":26859,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50],"tags":[13157,4110],"class_list":["post-23595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","tag-passwd","tag-users"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/23595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=23595"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/23595\/revisions"}],"predecessor-version":[{"id":162916,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/23595\/revisions\/162916"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/26859"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=23595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=23595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=23595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}