{"id":1547,"date":"2024-12-22T08:21:25","date_gmt":"2024-12-22T08:21:25","guid":{"rendered":"https:\/\/hostingn.in\/tutorials\/?p=1547"},"modified":"2024-12-24T08:35:43","modified_gmt":"2024-12-24T08:35:43","slug":"how-to-check-users-list-in-linux","status":"publish","type":"post","link":"https:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/","title":{"rendered":"A Comprehensive Guide: How to Check Users List in Linux Using Terminal?"},"content":{"rendered":"<p><strong>Introduction to Checking Users List in Linux<\/strong><\/p>\n<p>As a seasoned <a href=\"https:\/\/www.linux.org\/\" target=\"_blank\" rel=\"nofollow noopener sponsored\">Linux<\/a> user, I understand the importance of managing user accounts and permissions on your system. Knowing how to check the list of users on your Linux machine is a fundamental skill that can come in handy for various administrative tasks. In this comprehensive guide, I will walk you through the different methods you can use to check the list of users in Linux using the terminal.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" 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: #999;color:#999\" 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><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Understanding_the_Linux_Terminal_and_Basic_Commands\" >Understanding the Linux Terminal and Basic Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98cat_Command\" >Checking the List of Users Using the &#8216;cat&#8217; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98less_Command\" >Checking the List of Users Using the &#8216;less&#8217; 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:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98cut_Command\" >Checking the List of Users Using the &#8216;cut&#8217; 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:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98awk_Command\" >Checking the List of Users Using the &#8216;awk&#8217; 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:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98grep_Command\" >Checking the List of Users Using the &#8216;grep&#8217; 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:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98wc_Command\" >Checking the List of Users Using the &#8216;wc&#8217; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Checking_the_List_of_Users_Using_the_%E2%80%98sort_Command\" >Checking the List of Users Using the &#8216;sort&#8217; 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:\/\/hostingn.in\/tutorials\/how-to-check-users-list-in-linux\/#Summary_and_Conclusion\" >Summary and Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Understanding_the_Linux_Terminal_and_Basic_Commands\"><\/span>Understanding the Linux Terminal and Basic Commands<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Before we dive into the specific commands, it&#8217;s essential to have a basic understanding of the Linux terminal. The terminal is a powerful interface that allows you to interact with your operating system through text-based commands. Some of the most common and essential commands you&#8217;ll need to know are:<\/p>\n<ol class=\"!whitespace-normal list-decimal ml-5\">\n<li class=\"pb-1\"><code>ls<\/code>: Lists the contents of a directory<\/li>\n<li class=\"pb-1\"><code>cd<\/code>: Changes the current directory<\/li>\n<li class=\"pb-1\"><code>cat<\/code>: Displays the contents of a file<\/li>\n<li class=\"pb-1\"><code>less<\/code>: Displays the contents of a file in a paged format<\/li>\n<li class=\"pb-1\"><code>grep<\/code>: Searches for a specific pattern in a file or output<\/li>\n<\/ol>\n<p>These commands will come in handy as we explore the different methods for checking the list of users in Linux.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98cat_Command\"><\/span>Checking the List of Users Using the &#8216;cat&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One of the simplest ways to view the list of users on your <a href=\"https:\/\/hostingn.in\/tutorials\/how-to-change-passwords-and-gain-root-access-in-linux\/\">Linux system<\/a> is by using the\u00a0<code>cat<\/code>\u00a0command. The\u00a0<code>cat<\/code>\u00a0command is used to display the contents of a file, and in this case, we&#8217;ll be using it to display the contents of the\u00a0<code>\/etc\/passwd<\/code>\u00a0file, which contains the list of user accounts on your system.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">cat<\/span> \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command will output the entire contents of the\u00a0<code>\/etc\/passwd<\/code>\u00a0file, which includes information about each user account, such as the username, user ID, and default shell.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98less_Command\"><\/span>Checking the List of Users Using the &#8216;less&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Another way to view the list of users is by using the\u00a0<code>less<\/code>\u00a0command. The\u00a0<code>less<\/code>\u00a0command allows you to view the contents of a file in a paged format, making it easier to navigate through the output.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">less<\/span> \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command will display the contents of the\u00a0<code>\/etc\/passwd<\/code>\u00a0file in a paged format, allowing you to scroll through the list of users.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98cut_Command\"><\/span>Checking the List of Users Using the &#8216;cut&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you only want to see the usernames without the additional information, you can use the\u00a0<code>cut<\/code>\u00a0command. The\u00a0<code>cut<\/code>\u00a0command allows you to extract specific fields from a file or output.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">cut<\/span> -d: -f1 \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command will extract the first field (separated by the colon\u00a0<code>:<\/code>) from the\u00a0<code>\/etc\/passwd<\/code>\u00a0file, which contains the usernames.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98awk_Command\"><\/span>Checking the List of Users Using the &#8216;awk&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The\u00a0<code>awk<\/code>\u00a0command is a powerful text processing tool that allows you to perform more complex operations on data. You can use\u00a0<code>awk<\/code>\u00a0to extract the usernames from the\u00a0<code>\/etc\/passwd<\/code>\u00a0file.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">awk<\/span> -F: <span class=\"token\">'{print $1}'<\/span> \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command uses the\u00a0<code>-F<\/code>\u00a0option to specify the field separator (in this case, the colon\u00a0<code>:<\/code>) and then prints the first field (<code>$1<\/code>) for each line in the\u00a0<code>\/etc\/passwd<\/code>\u00a0file.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98grep_Command\"><\/span>Checking the List of Users Using the &#8216;grep&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The\u00a0<code>grep<\/code>\u00a0command is a powerful tool for searching and filtering text. You can use\u00a0<code>grep<\/code>\u00a0to search for specific usernames or patterns in the\u00a0<code>\/etc\/passwd<\/code>\u00a0file.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">grep<\/span> -E <span class=\"token\">'^[a-z]+$'<\/span> \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command uses the\u00a0<code>-E<\/code>\u00a0option to enable extended regular expressions and searches for usernames that consist of only lowercase letters.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98wc_Command\"><\/span>Checking the List of Users Using the &#8216;wc&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The\u00a0<code>wc<\/code>\u00a0(word count) command can be used to count the number of users on your system. You can combine it with other commands to get the total number of users.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">wc<\/span> -l \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command will output the number of lines in the\u00a0<code>\/etc\/passwd<\/code>\u00a0file, which corresponds to the total number of user accounts.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checking_the_List_of_Users_Using_the_%E2%80%98sort_Command\"><\/span>Checking the List of Users Using the &#8216;sort&#8217; Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you want to view the list of users in a sorted order, you can use the\u00a0<code>sort<\/code>\u00a0command. The\u00a0<code>sort<\/code>\u00a0command allows you to sort the output of other commands.<\/p>\n<div class=\"relative font-sans rounded-t-md overflow-hidden\">\n<div class=\"flex justify-between bg-gray-800 py-1.5 px-4 text-gray-200\">\n<div class=\"text-xs lowercase\">bash<\/div>\n<\/div>\n<div class=\"overflow-x-auto transition-colors duration-200\">\n<pre><code class=\"language-bash\"><span class=\"token\">sort<\/span> \/etc\/passwd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>This command will sort the contents of the\u00a0<code>\/etc\/passwd<\/code>\u00a0file in alphabetical order by username.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Summary_and_Conclusion\"><\/span>Summary and Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this comprehensive guide, we&#8217;ve explored several methods for checking the list of users on a Linux system using the terminal. From the simple\u00a0<code>cat<\/code>\u00a0and\u00a0<code>less<\/code>\u00a0commands to the more advanced\u00a0<code>cut<\/code>,\u00a0<code>awk<\/code>,\u00a0<code>grep<\/code>,\u00a0<code>wc<\/code>, and\u00a0<code>sort<\/code>\u00a0commands, you now have a variety of tools at your disposal to manage and understand the user accounts on your Linux machine.<\/p>\n<p>To take your Linux administration skills to the next level, be sure to check out our [advanced Linux tutorials](https:\/\/www.example.com\/linux-tutorials) for more in-depth guides and tips.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Checking Users List in Linux As a seasoned Linux user, I understand the importance of managing user accounts and permissions on your system&#8230;.<\/p>\n","protected":false},"author":3,"featured_media":1876,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[93,8],"tags":[145,218,217],"class_list":["post-1547","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps","category-technology","tag-linux","tag-terminal","tag-users"],"_links":{"self":[{"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/posts\/1547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/comments?post=1547"}],"version-history":[{"count":4,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/posts\/1547\/revisions"}],"predecessor-version":[{"id":1898,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/posts\/1547\/revisions\/1898"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/media\/1876"}],"wp:attachment":[{"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/media?parent=1547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/categories?post=1547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostingn.in\/tutorials\/wp-json\/wp\/v2\/tags?post=1547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}