{"id":1075,"date":"2024-06-28T14:38:11","date_gmt":"2024-06-28T14:38:11","guid":{"rendered":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?p=1075"},"modified":"2024-06-28T14:38:12","modified_gmt":"2024-06-28T14:38:12","slug":"how-to-create-a-user-in-linux-add-it-to-the-sudoer-file","status":"publish","type":"post","link":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html","title":{"rendered":"How to Create a User in Linux &amp; Add it to the sudoer File?"},"content":{"rendered":"\n<p>In Linux, user management is a fundamental aspect of system administration, ensuring multiple users can securely and efficiently access the system. Among the various tasks involved in user management, creating new users and granting them appropriate permissions is crucial.&nbsp;<\/p>\n\n\n\n<p>One of the most common requirements is to create a new user and provide them with the ability to execute commands with superuser privileges, also known as sudo access.<\/p>\n\n\n\n<p>The sudo command in Linux allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. This is a powerful feature that enables users to perform administrative tasks without logging in as the root user, thereby enhancing security by limiting root access.<\/p>\n\n\n\n<p>This guide is designed to help system administrators, and users granted administrative rights understand how to create a new user and configure sudo access for them. Whether setting up a new server, adding a new team member to your development environment, or simply enhancing your understanding of Linux user management, this step-by-step guide will walk you through the entire process!<\/p>\n\n\n\n<hr>\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/343\/Install-and-Configure-a-CSF-Firewall-in-a-CenTOS-Server.html\"><strong>Install &amp; Configure a CSF Firewall in a CenTOS Server<\/strong><\/a><\/p>\n<hr>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Steps to Create a New Sudo User<\/strong><\/h2>\n\n\n\n<p>\u2794 Here, we will create an account for <strong>\u2018Tech Support\u2019 <\/strong>as an example.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>useradd tech_support<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 Set the password for the new user.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>passwd tech_support<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 The system will show a prompt where you can set and confirm a password for your new user account. If everything goes well, the system will say <strong>&#8220;all authentication tokens updated successfully.&#8221;<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Steps to Add New User Directly to the sudoers File<\/strong><\/h2>\n\n\n\n<p>\u2794 Open the \u2018<strong>sudoers\u2019<\/strong> file with <strong>\u2018visudo\u2019<\/strong>, which ensures the file is edited safely.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>sudo visudo<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 Add the following line at the end of the file, replacing the \u2018<strong>tech_support\u2019<\/strong> with the actual username.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>tech_support ALL=(ALL) ALL<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 Save the file and exit the editor. In <strong>nano<\/strong>, for example, you would press <strong>Ctrl+X<\/strong>, then <strong>\u2018Y\u2019<\/strong>, and \u2018<strong>Enter\u2019<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Test Sudo Privileges for the User Account<\/strong><\/h2>\n\n\n\n<p>To ensure that the new user has the correct sudo privileges, perform the following test:<\/p>\n\n\n\n<p>\u2794 Switch to the new user by entering this command.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>su &#8211; tech_support<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 Run a command that requires superuser privileges. For example, try to list the root directory.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"kb_firewall\"><strong>sudo ls \/root<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If the user has sudo privileges, you will be prompted to enter the user\u2019s password. After entering the password, the command should execute and display the contents of the root directory. If there are any errors, check the user&#8217;s group membership and the sudoers file configuration.<\/p>\n\n\n\n<hr>\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/314\/Configure-Windows-Firewall-to-Allow-Only-Specific-IPs-For-Port-Connection.html\"><strong>Configure Windows Firewall to Allow Only Specific IPs For Port Connection<\/strong><\/a><\/p>\n<hr>\n\n\n\n<p>That\u2019s it! You have now created a new user and granted them sudo privileges. This user can now perform administrative tasks with superuser rights by prefixing commands with sudo. Always use caution when granting sudo privileges, as it allows users to execute potentially harmful commands with elevated rights.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, user management is a fundamental aspect of system administration, ensuring multiple users can securely and efficiently access the system. Among the various tasks involved in user management, creating new users and granting them appropriate permissions is crucial.&nbsp; One of the most common requirements is to create a new user and provide them with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-1075","post","type-post","status-publish","format-standard","hentry","category-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create a User in Linux &amp; Add it to the sudoer File?<\/title>\n<meta name=\"description\" content=\"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a User in Linux &amp; Add it to the sudoer File?\" \/>\n<meta property=\"og:description\" content=\"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html\" \/>\n<meta property=\"og:site_name\" content=\"Host IT Smart Knowledge base\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-28T14:38:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-28T14:38:12+00:00\" \/>\n<meta name=\"author\" content=\"Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html\",\"name\":\"How to Create a User in Linux &amp; Add it to the sudoer File?\",\"isPartOf\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\"},\"datePublished\":\"2024-06-28T14:38:11+00:00\",\"dateModified\":\"2024-06-28T14:38:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\"},\"description\":\"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\",\"name\":\"Host IT Smart Knowledge base\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\",\"name\":\"Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"caption\":\"Admin\"},\"sameAs\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\"],\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a User in Linux &amp; Add it to the sudoer File?","description":"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html","og_locale":"en_US","og_type":"article","og_title":"How to Create a User in Linux &amp; Add it to the sudoer File?","og_description":"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.","og_url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html","og_site_name":"Host IT Smart Knowledge base","article_published_time":"2024-06-28T14:38:11+00:00","article_modified_time":"2024-06-28T14:38:12+00:00","author":"Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html","name":"How to Create a User in Linux &amp; Add it to the sudoer File?","isPartOf":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website"},"datePublished":"2024-06-28T14:38:11+00:00","dateModified":"2024-06-28T14:38:12+00:00","author":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108"},"description":"This step-by-step guide teaches you how to create a new user in Linux and add them to the sudoers file in simple steps by adding commands.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/401\/how-to-create-sudo-user-in-linux.html"]}]},{"@type":"WebSite","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/","name":"Host IT Smart Knowledge base","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108","name":"Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","caption":"Admin"},"sameAs":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/"],"url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/1075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1075"}],"version-history":[{"count":2,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/1075\/revisions"}],"predecessor-version":[{"id":1077,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/1075\/revisions\/1077"}],"wp:attachment":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}