{"id":381,"date":"2017-01-05T04:06:48","date_gmt":"2017-01-04T21:06:48","guid":{"rendered":"http:\/\/www.rickyadams.com\/wp\/?p=381"},"modified":"2017-01-05T04:08:36","modified_gmt":"2017-01-04T21:08:36","slug":"adding-users-to-sudo-access","status":"publish","type":"post","link":"https:\/\/www.rickyadams.com\/wp\/adding-users-to-sudo-access\/","title":{"rendered":"Adding Users to sudo Access"},"content":{"rendered":"<div class=\"procedure\">\n<p class=\"title\"><strong>Procedure\u00a02.2.\u00a0Configuring <code class=\"command\">sudo<\/code> Access<\/strong><\/p>\n<ol class=\"1\">\n<li class=\"step\">\n<div class=\"para\">Log in to the system as the <code class=\"systemitem\">root<\/code> user.<\/div>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Create a normal user account using the <code class=\"command\">useradd<\/code> command. Replace <em class=\"replaceable\">USERNAME<\/em> with the user name that you wish to create.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <code class=\"command\">useradd<\/code> <em class=\"replaceable\">USERNAME<\/em><\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Set a password for the new user using the <code class=\"command\">passwd<\/code> command.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <code class=\"command\">passwd<\/code> <em class=\"replaceable\">USERNAME<\/em>\r\nChanging password for user <em class=\"replaceable\">USERNAME<\/em>.\r\nNew password: \r\nRetype new password: \r\npasswd: all authentication tokens updated successfully.<\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Run the <code class=\"command\">visudo<\/code> to edit the <code class=\"filename\">\/etc\/sudoers<\/code> file. This file defines the policies applied by the <code class=\"command\">sudo<\/code> command.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <code class=\"command\">visudo<\/code><\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Find the lines in the file that grant <code class=\"command\">sudo<\/code> access to users in the group <code class=\"systemitem\">wheel<\/code> when enabled.<\/div>\n<pre class=\"screen\">## Allows people in group wheel to run all commands\r\n# %wheel        ALL=(ALL)       ALL<\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Remove the comment character (<span class=\"keycap\"><strong>#<\/strong><\/span>) at the start of the second line. This enables the configuration option.<\/div>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Save your changes and exit the editor.<\/div>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Add the user you created to the <code class=\"systemitem\">wheel<\/code> group using the <code class=\"command\">usermod<\/code> command.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <code class=\"command\">usermod<\/code> <em class=\"parameter\"><code>-aG<\/code><\/em> <em class=\"parameter\"><code>wheel<\/code><\/em> <em class=\"replaceable\">USERNAME<\/em><\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Test that the updated configuration allows the user you created to run commands using <code class=\"command\">sudo<\/code>.<\/div>\n<ol class=\"substeps a\">\n<li class=\"step\">\n<div class=\"para\">Use the <code class=\"command\">su<\/code> to switch to the new user account that you created.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <code class=\"command\">su<\/code> <em class=\"replaceable\">USERNAME<\/em> <em class=\"parameter\"><code>-<\/code><\/em><\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Use the <code class=\"command\">groups<\/code> to verify that the user is in the <code class=\"systemitem\">wheel<\/code> group.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">$<\/code> <code class=\"command\">groups<\/code>\r\n<em class=\"replaceable\">USERNAME<\/em> wheel<\/pre>\n<\/li>\n<li class=\"step\">\n<div class=\"para\">Use the <code class=\"command\">sudo<\/code> command to run the <code class=\"command\">whoami<\/code> command. As this is the first time you have run a command using <code class=\"command\">sudo<\/code> from this user account the banner message will be displayed. You will be also be prompted to enter the password for the user account.<\/div>\n<pre class=\"screen\"><code class=\"prompt\">$<\/code> <code class=\"command\">sudo<\/code> <code class=\"command\">whoami<\/code>\r\nWe trust you have received the usual lecture from the local System\r\nAdministrator. It usually boils down to these three things:\r\n\r\n    #1) Respect the privacy of others.\r\n    #2) Think before you type.\r\n    #3) With great power comes great responsibility.\r\n\r\n[sudo] password for <em class=\"replaceable\">USERNAME<\/em>:\r\nroot<\/pre>\n<div class=\"para\">The last line of the output is the user name returned by the <code class=\"command\">whoami<\/code> command. If <code class=\"command\">sudo<\/code> is configured correctly this value will be <code class=\"systemitem\">root<\/code>.<\/div>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/div>\n<div class=\"para\">You have successfully configured a user with <code class=\"command\">sudo<\/code> access. You can now log in to this user account and use <code class=\"command\">sudo<\/code> to run commands as if you were logged in to the account of the <code class=\"systemitem\">root<\/code> user.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Procedure\u00a02.2.\u00a0Configuring sudo Access Log in to the system as the root user. Create a normal user account using the useradd command. Replace USERNAME with the user name that you wish to create. # useradd USERNAME Set a password for the new user using the passwd command. # passwd USERNAME Changing password for user USERNAME. New password: Retype new password: passwd: all authentication tokens updated successfully. Run the visudo to edit the \/etc\/sudoers file. This file defines the policies applied by&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.rickyadams.com\/wp\/adding-users-to-sudo-access\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":1,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/posts\/381\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rickyadams.com\/wp\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}