{"id":8224,"date":"2021-07-10T12:41:00","date_gmt":"2021-07-10T12:41:00","guid":{"rendered":"https:\/\/linuxways.net\/?p=8224"},"modified":"2021-07-10T12:41:00","modified_gmt":"2021-07-10T12:41:00","slug":"how-to-add-a-user-to-sudoers-on-debian-10","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-add-a-user-to-sudoers-on-debian-10\/","title":{"rendered":"How to Add a User to Sudoers on Debian 10"},"content":{"rendered":"<p>Users need root or administrative privileges to install new software on a system through the command line. When a new user creates an on a Linux system, you grant some Sudo privileges to run administrative commands. The \u2018sudo\u2019 command access allows trusted users to execute the administrative commands as another user. So, you can grant some specific privileges and add these trusted users in a sudoers group or a file.<\/p>\n<p>In this article, we will explain a method of how to add a user to sudoers using the terminal on the Debian 10 system.<\/p>\n<h2><strong>Method 1: Add User to a Sudoers Group on Debian 10<\/strong><\/h2>\n<p>The most frequently used method to assign sudo privileges to a user is to add a user into the sudoers group. The members of the sudoer group can run all administrative commands as root. When a command runs with sudo privileges, a password confirmation prompt shows on the terminal. The sudo user authenticates this process using the password.<\/p>\n<p>You can add an existing user into the sudoers group or if you want then create a new user and add this user into the sudoers group. Here, we assume that a user is already created. So, add this already existing user into the sudoers group by using the below-mentioned syntax:<\/p>\n<pre>$ usermod -aG sudo user_name<\/pre>\n<p>In the above command, sudo is the group name and user_name is the name of the user. For example, we are adding a user named \u2018karim\u2019 into the sudoers group. Therefore, the above command will change into the following form:<\/p>\n<pre>$ usermod -aG sudo karim<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1084\" height=\"60\" class=\"wp-image-8225\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-341.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-341.png 1084w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-341-300x17.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-341-1024x57.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-341-768x43.png 768w\" sizes=\"auto, (max-width: 1084px) 100vw, 1084px\" \/><\/p>\n<p>The above-explained method is enough for granting sudo privileges to a user. To verify that the user is now added into the sudoers group, type the following terminal command:<\/p>\n<pre>$ sudo whoami<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"88\" class=\"wp-image-8226\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-342.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-342.png 1080w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-342-300x24.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-342-1024x83.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-342-768x63.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>Enter the password. If the user is added into the sudoers group then, the \u2018root\u2019 will display in the result. Otherwise, it will display an error on the terminal screen.<\/p>\n<h2><strong>Method 2: Add user into the sudoers file<\/strong><\/h2>\n<p>All sudo\u2019 and group\u2019 rules are defined into the sudoers\u00a0 file that you can locate at<\/p>\n<p>\u2018\/etc\/sudoers\u2019 location in your system. In this file, we define certain rules and set of the privileges which we assigned to a particular user.<\/p>\n<p>Using two different approaches you can grant access to a sudo user. Either, you can configure the \u2018\/etc\/sudoers\u2019 file on your system and edit it or you can create a new file in the \u2018\/etc\/sudoers.d\u2019 directory. To modify the sudoers file, type the below-mentioned command:<\/p>\n<pre>$ sudo visudo<\/pre>\n<p>Now, at the end of the configuration file add the following rules as follows:<\/p>\n<pre>user_name\u00a0 ALL=(ALL) NOPASSWD:ALL<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1091\" height=\"647\" class=\"wp-image-8227\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-343.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-343.png 1091w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-343-300x178.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-343-1024x607.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-343-768x455.png 768w\" sizes=\"auto, (max-width: 1091px) 100vw, 1091px\" \/><\/p>\n<p>Change the user name with your user which is shown in the following screenshot:<\/p>\n<h2><strong>Allow Limiting command access to sudo user<\/strong><\/h2>\n<p>You can also give some limiting sudo privileges to a user. For example, we want to grant specific privileges of \u2018useradd\u2019 and \u2018adduser\u2019 commands to the user \u2018karim\u2019.<\/p>\n<pre>karim ALL=(ALL) NOPASSWD: \/usr\/sbin\/useradd,\/usr\/sbin\/adduser<\/pre>\n<p>Save the above-explained rules at the end of the sudoers file. After that, the user can only run the \u2018adduser\u2019 and \u2018useradd\u2019 commands.<\/p>\n<p>You can also create a new file in the \u2018\/etc\/sudoers.d\u2019 directory and define some set of rules.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have explained how to add users into the sudoers group in this article.\u00a0 Moreover, we have also explained how to edit rules in the sudoers configuration file through the command. You can customize the sudoers file based on the user requirements.<\/p>","protected":false},"excerpt":{"rendered":"<p>Users need root or administrative privileges to install new software on a system through the command line. When a new user creates an on a Linux system, you&hellip;<\/p>","protected":false},"author":1,"featured_media":8263,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17,227,155],"class_list":["post-8224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-10","tag-sudoers","tag-user"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=8224"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8224\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8263"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}