Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2904,"date":"2019-12-27T07:08:29","date_gmt":"2019-12-27T07:08:29","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2904"},"modified":"2019-12-27T07:08:42","modified_gmt":"2019-12-27T07:08:42","slug":"setup-a-non-root-user-with-sudo-access-on-ubuntu","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/setup-a-non-root-user-with-sudo-access-on-ubuntu\/","title":{"rendered":"Setup a Non-root User with Sudo Access on Ubuntu"},"content":{"rendered":"

Having only one user, which is root, can be\u00a0dangerous<\/strong>. So let’s fix that. AKWLEB Host provides us with the freedom to do as we please with our users and our servers. Let’s make use of this by adding a user with\u00a0sudo<\/strong>\u00a0access instead of\u00a0direct root access<\/strong>.<\/p>\n

Add a new user<\/h3>\n

We need to first connect to the server with root so that we have adequate permissions. Once connected, add another user account.<\/p>\n

# useradd <username>\r\n<\/code><\/pre>\n

Replace\u00a0<username><\/code>\u00a0with the desired username.<\/p>\n

That command will add the user to the list of users on the system, and create a corresponding group (if the group doesn’t exist).<\/p>\n

Edit the hostname<\/h3>\n

With the default hostname set, sudo with throw the following error.<\/p>\n

 sudo: unable to resolve host aklwebhost.guest\r\n<\/code><\/pre>\n

We can prevent this error by changing the hostname. Your hostname is located after the “@” symbol in the shell. For example,\u00a0root@<hostname> ~#<\/code>.<\/p>\n

Edit both\u00a0\/etc\/hosts\/<\/code>\u00a0and\u00a0\/etc\/hostname<\/code>\u00a0to update your hostname. Save the files when you’re done editing them.<\/p>\n

nano \/etc\/hosts\r\nnano \/etc\/hostname\r\n<\/code><\/pre>\n

Restart the server<\/h3>\n

You must restart the server for the hostname change to take effect. Once the server finishes rebooting, log back in to continue.<\/p>\n

reboot\r\n<\/code><\/pre>\n

Add a sudo entry<\/h3>\n

Even if you’re root, you will need to run the “sudo” part of the following command.<\/p>\n

sudo visudo\r\n<\/code><\/pre>\n

This will bring up a file with a bit of default info. What you need to look for is the following section:<\/p>\n

# Cmnd alias specification\r\n\r\n# User privilege specification\r\nroot    ALL=(ALL:ALL) ALL\r\n<\/code><\/pre>\n

Find where “root” appears in the list shown above, and add the following. Substitute the appropriate variables.<\/p>\n

<username> ALL=(ALL:ALL) ALL\r\n<\/code><\/pre>\n

Finish setting up user account<\/h3>\n

We are almost finished. A few more minor steps.<\/p>\n

Create the home folder for the new user.<\/p>\n

mkdir \/home\/<username>\r\n<\/code><\/pre>\n

Give the new user permissions in that folder.<\/p>\n

chown <username>:<usergroup> \/home\/<username> -R\r\n<\/code><\/pre>\n

Set a password for the new user.<\/p>\n

sudo passwd <username>\r\n<\/code><\/pre>\n

Add the following to the\u00a0\/etc\/passwd<\/code>\u00a0file.<\/p>\n

<username>:x:1000:1000::\/home\/<username>:\/bin\/bash\r\n<\/code><\/pre>\n

Reboot the server again for these changes to take effect.<\/p>\n

 reboot \r\n<\/code><\/pre>\n

Using sudo<\/h3>\n

At this point, your new user account is ready-to-go with sudo access. You may log into the server with this new account and use\u00a0sudo<\/code>\u00a0when necessary.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[242,247],"manual_kb_tag":[451],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2904"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2904"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2904\/revisions"}],"predecessor-version":[{"id":2905,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2904\/revisions\/2905"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2904"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2904"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}