{"id":31801,"date":"2018-10-31T17:31:57","date_gmt":"2018-10-31T12:01:57","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=31801"},"modified":"2018-10-31T17:41:01","modified_gmt":"2018-10-31T12:11:01","slug":"how-to-add-user-and-grant-root-privileges-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/how-to-add-user-and-grant-root-privileges-on-ubuntu\/","title":{"rendered":"How to Add a User and Grant Root Privileges on Ubuntu 16.04"},"content":{"rendered":"<p><span style=\"color: #000080;\"><strong>How to Add a User and Grant Root Privileges on Ubuntu 16.04<\/strong><\/span><\/p>\n<p><strong>Ubuntu 16.04 LTS<\/strong> provides you the <strong>ability to add a user<\/strong> for anyone who plans on accessing your <a href=\"https:\/\/www.wikitechy.com\/tutorials\/apache\/iis-web-server-vs-apache-tomcat-server\" target=\"_blank\" rel=\"noopener\">server<\/a>. \u00a0Creating a user is a basic setup but an important and critical one for your <a href=\"https:\/\/www.wikitechy.com\/tutorials\/apache\/how-to-secure-apache-web-server\" target=\"_blank\" rel=\"noopener\">server security<\/a>. In this tutorial, we will create a user and <strong>grant administrative access<\/strong>, known as <strong>root<\/strong>, to your trusted user.<\/p>\n<h3 id=\"pre-flight-check\"><span style=\"color: #993300;\"><strong>Pre-Flight Check<\/strong><\/span><\/h3>\n<ol>\n<li>Open a terminal and log in as <strong>root<\/strong>.<\/li>\n<li>Work on a <strong>Linux<\/strong> Ubuntu 16.04 server<\/li>\n<\/ol>\n<h2 id=\"creating-a-user-with-root-privileges\"><span style=\"color: #0000ff;\"><strong>Creating a User with Root Privileges<\/strong><\/span><\/h2>\n<h3 id=\"step-1-add-the-user\"><strong><span style=\"color: #008000;\">Step 1:<\/span> \u00a0Add The User<\/strong><\/h3>\n<p>Create a username for your new user, in my example my new user is Tom:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">adduser tom<\/code><\/pre> <\/div>\n<p>You\u2019ll then be prompted to enter a password for this user.\u00a0 We recommend using a strong password because malicious bots are programmed to guess simple passwords. If you need a secure password, this third party\u00a0<a href=\"https:\/\/www.lastpass.com\/password-generator\" target=\"_blank\" rel=\"noopener\">password generator<\/a>\u00a0can assist with creating one.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">~#adduser tom<br\/>Adding user &#039;tom&#039; ...<br\/>Adding new group `tom&#039; (1002) ...<br\/>Adding new user `tom&#039; (1002) with group `tom&#039; ...<br\/>Creating home directory `\/home\/tom&#039; ...<br\/>Copying files from `\/etc\/skel&#039; ...<br\/>Enter new UNIX password:<br\/>Retype new UNIX password:<br\/>passwd: password updated successfully<\/code><\/pre> <\/div>\n<p><span style=\"color: #800000;\"><strong>Note:<\/strong><\/span><\/p>\n<p>Usernames should be lowercase and avoid special characters. If you receive the error below, alter the username.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">~#adduser Tom<br\/>adduser: Please enter a username matching the regular expression configured<br\/> via the NAME_REGEX[_SYSTEM] configuration variable. <br\/>Use the &#039;--force-badname&#039; option to relax this check or reconfigure NAME_REGEX.<\/code><\/pre> <\/div>\n<p><a href=\"https:\/\/www.wikitechy.com\/technology\/10-useful-command-prompt-tricks-might-not-know\/\" target=\"_blank\" rel=\"noopener\">Prompts<\/a> will appear to enter in information on your new user. \u00a0Entering this information is not required and can be skipped by pressing enter in each field.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">Enter the new value, or press ENTER for the default<br\/>Full Name []:<br\/>Room Number []:<br\/>Work Phone []:<br\/>Home Phone []:<br\/>Other []:<\/code><\/pre> <\/div>\n<p>Lastly, the system will ask you to review the information for accuracy. \u00a0Enter\u00a0<strong>Y<\/strong>\u00a0to continue to our next step.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">Is the information correct? [Y\/n] Y<\/code><\/pre> <\/div>\n<h3 id=\"step-2-grant-root-privileges\"><strong><span style=\"color: #008000;\">Step 2:<\/span> Grant Root Privileges<\/strong><\/h3>\n<p>Assigning a user root access is to grant a user the highest power. \u00a0My user, Tom, can then make changes to the system as a whole, so it\u2019s critical to allow this access only to users who need it. Afterward, Tom will be able to use <strong>sudo<\/strong> before <a href=\"https:\/\/www.wikitechy.com\/technology\/zip-and-unzip-unix-command-line\/\" target=\"_blank\" rel=\"noopener\">commands<\/a> that are usually designed to be used by the <a href=\"https:\/\/www.wikitechy.com\/forum\/d\/110-how-can-use-mysql-root-access-from-all-hosts\" target=\"_blank\" rel=\"noopener\">root user<\/a>.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">usermod -aG sudo tom<\/code><\/pre> <\/div>\n<h3 id=\"step-3-verify-new-user\"><strong><span style=\"color: #008000;\">Step 3:<\/span> Verify New User<\/strong><\/h3>\n<p>As root, you can switch to your new user with the <strong>su \u2013 command<\/strong> and then test to see if your new user has root privileges.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">su - tom<\/code><\/pre> <\/div>\n<p>If the user has properly been granted root access the command below will show tom in the list<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">grep &#039;^sudo&#039; \/etc\/group<\/code><\/pre> <\/div>\n<h3 id=\"output\"><span style=\"color: #008000;\">Output:<\/span><\/h3>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-less code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-less code-embed-code\">sudo : x : 27 : tom<\/code><\/pre> <\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Add a User and Grant Root Privileges on Ubuntu 16.04 Ubuntu 16.04 LTS provides you the ability to add a user for anyone who plans on accessing your server. \u00a0Creating a user is a basic setup but an important and critical one for your server security. In this tutorial, we will create a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":14796,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1331],"tags":[85728,85729,85730,85731,84434,85732,85734,85733,85735,85737,85736,85746,85745,85744,85743,85742,85741,85740,85739,85738],"class_list":["post-31801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-unix","tag-add-user-to-group","tag-add-user-to-root-group","tag-add-user-to-sudo-group","tag-add-user-to-sudoers","tag-add-user-to-sudoers-centos","tag-change-user-permissions-linux","tag-give-permission-to-folder-in-linux-for-a-user","tag-give-user-sudo-access-ubuntu","tag-grant-root-access-to-file","tag-how-to-give-full-permission-to-user-in-linux","tag-how-to-give-full-permission-to-user-in-ubuntu","tag-how-to-give-root-privileges-to-a-user-in-linux","tag-how-to-give-root-privileges-to-a-user-in-ubuntu","tag-how-to-give-sudo-access-to-a-user-in-linux","tag-how-to-give-sudo-permission-to-user-in-linux","tag-root-privileges-linux","tag-ubuntu-add-user-to-group","tag-ubuntu-create-user-with-home-directory","tag-ubuntu-list-users","tag-ubuntu-user-permissions"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=31801"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media\/14796"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=31801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=31801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=31801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}