{"id":44,"date":"2023-09-28T14:13:25","date_gmt":"2023-09-28T13:13:25","guid":{"rendered":"https:\/\/thevadasan.com\/?p=44"},"modified":"2024-04-29T06:46:30","modified_gmt":"2024-04-29T05:46:30","slug":"how-to-add-a-new-user-and-add-them-as-sudoer","status":"publish","type":"post","link":"https:\/\/thevadasan.com\/?p=44","title":{"rendered":"How to add a new user and add them as Sudoer"},"content":{"rendered":"\n<p>To add a user, set a password for that user, and grant them sudo privileges on a Linux system, follow the steps below. For this tutorial, let&#8217;s assume you&#8217;re adding a user named &#8220;newuser&#8221;.<\/p>\n\n\n\n<ol>\n<li><strong>Add a User<\/strong>: First, you&#8217;ll need to open a terminal and gain superuser privileges. Typically, you would do this by entering <code>sudo su<\/code> or just prefixing the following commands with <code>sudo<\/code>. Add the user with the following command:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">adduser newuser<\/code><\/pre>\n\n\n\n<p>This command will prompt you to set a password and other optional details for the user.<\/p>\n\n\n\n<ol start=\"2\">\n<li><strong>Set\/Change Password<\/strong>: If you need to reset or change the password for the user at a later time, you can use the following command:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">passwd newuser<\/code><\/pre>\n\n\n\n<p>You&#8217;ll be prompted to enter the new password twice for confirmation.<\/p>\n\n\n\n<ol start=\"3\">\n<li><strong>Add User to sudoers<\/strong>: For a user to be able to execute commands as the superuser, they need to be added to the <code>sudo<\/code> group (on many modern Linux distributions) or be explicitly listed in the <code>\/etc\/sudoers<\/code> file. Here&#8217;s how to do both:<\/li>\n<\/ol>\n\n\n\n<p><strong>Add user to the <code>sudo<\/code> group<\/strong> (preferred method for systems where the <code>sudo<\/code> group exists):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><code>usermod -aG sudo newuser<\/code><\/code><\/pre>\n\n\n\n<p><strong>Directly edit the <code>\/etc\/sudoers<\/code> file<\/strong>: It&#8217;s advised to use the <code>visudo<\/code> command to edit the sudoers file as it checks for syntax errors: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">visudo<\/code><\/pre>\n\n\n\n<p>Once inside the editor, you can add the following line to grant the user full sudo privileges: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">newuser ALL=(ALL:ALL) ALL<\/code><\/pre>\n\n\n\n<p>After adding the line, save and exit the editor. If you&#8217;re unfamiliar with the <code>vi<\/code> editor that <code>visudo<\/code> defaults to, remember to press <code>i<\/code> to enter insert mode, make your changes, then press <code>Esc<\/code> followed by <code>:wq<\/code> and <code>Enter<\/code> to save and quit.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To add a user, set a password for that user, and grant them sudo privileges on a Linux system, follow the steps below. For this tutorial, let&#8217;s assume you&#8217;re adding a user named &#8220;newuser&#8221;. This command will prompt you to set a password and other optional details for the user. You&#8217;ll be prompted to enter [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":76,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/44"}],"collection":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":1,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":45,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/45"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/media\/76"}],"wp:attachment":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}