<\/p>\n
We will show you How to Create Users and Manage Their Sudo Privileges on Ubuntu.\u00a0The sudo<\/strong> command allows normal users to run programs which are only available to the root user.\u00a0\u00a0This tutorial will show you the simplest way to create a new user with sudo access on Ubuntu, without modifying\u00a0 your server’s\u00a0sudoers<\/code>\u00a0file.<\/p>\n
<\/h2>\n5 Steps to Create a New Sudo User:<\/h3>\n\nTable of Contents<\/p>\n
- 1. Login to your server<\/a><\/li>
- 2. Add a new system user<\/a><\/li>
- 3. Add sudo privileges to a system user in Linux<\/a><\/li>
- 4. Install Sudo program<\/a><\/li>
- 5. Remove sudo privileges for a system user in Linux<\/a><\/li><\/ul><\/nav><\/div>\n
<\/span>1. Login to your server<\/span><\/h2>\n
First of all, connect to your Linux server via SSH<\/a><\/p>\n
<\/span>2. Add a new system user<\/span><\/h2>\n# adduser newuser<\/pre>\nFeel free to replace newuser<\/code> with the name of the system user you want to add. You will need to enter a password for your new user as well as you will need to enter some random user information. You can
generate a strong password through the command line<\/a>.<\/p>\n
# adduser newuser\r\nAdding user `newuser' ...\r\nAdding new group `newuser' (1001) ...\r\nAdding new user `newuser' (1001) with group `newuser' ...\r\nCreating home directory `\/home\/newuser' ...\r\nCopying files from `\/etc\/skel' ...\r\nEnter new UNIX password:\r\nRetype new UNIX password:\r\npasswd: password updated successfully\r\nChanging the user information for newuser\r\nEnter the new value, or press ENTER for the default\r\n Full Name []: New User\r\n Room Number []: 101\r\n Work Phone []: 123456\r\n Home Phone []: 123456\r\n Other []:\r\nIs the information correct? [Y\/n] y<\/pre>\n<\/span>3. Add sudo privileges to a system user in Linux<\/span><\/h2>\nOnce the system user is created go ahead and add it to the sudo<\/code> group using the following command:<\/p>\n
# usermod -aG sudo newuser<\/pre>\nThen, use the su<\/code> command to switch to the new user:<\/p>\n
# su - newuser<\/pre>\n
Now you can try to run some command or program that is available only to the root user. For example, try to update the package index<\/a> and to install the newest versions of all packages that are currently installed on your server.<\/p>\n
sudo apt-get update\r\nsudo apt-get upgrade<\/pre>\nIn case the sudo command is not installed on your server you will get the following error:<\/p>\n
-su: sudo: command not found<\/pre>\n<\/span>4. Install Sudo program<\/span><\/h2>\nThis means you will need to install the sudo program in order to be able to run that command. Switch to your root account and run the following command:<\/p>\n
# apt-get install sudo<\/pre>\nYou can verify that it is successfully installed using this command:<\/p>\n
# dpkg -l | grep -i sudo<\/pre>\nThe output should be similar to the one below:<\/p>\n
# dpkg -l | grep -i sudo\r\nii sudo 1.8.16-0ubuntu1.3 amd64 Provide limited super user privileges to specific users<\/pre>\nOnce the sudo program is installed on your Ubuntu VPS<\/a>, switch to the new user and try to run the same commands again. You should not see the error message now and instead, you will be prompted to enter the password of the new system user.<\/p>\n
<\/span>5. Remove sudo privileges for a system user in Linux<\/span><\/h2>\nIn some cases, you may want to remove the sudo privileges for a specific system user. For that purpose you can use this command:<\/p>\n
# deluser newuser sudo<\/pre>\nFeel free to replace newuser<\/code> with the name of the system user you want to modify. If you get the following message that means the system user has been successfully removed from the sudo group.<\/p>\n
# deluser newuser sudo\r\nRemoving user `newuser' from group `sudo' ...\r\nDone.<\/pre>\n
Of course, you don\u2019t have to Create Users and Manage Their Sudo Privileges on Ubuntu, if you use one of our Ultra-Flast VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to Create Users and Manage Their Sudo Privileges on Ubuntu server. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n