How To Add User To Sudo In Linux
Introduction
The sudo
control is the preferred means to handle elevated permissions. In supported versions of Ubuntu, using the sudo
command will grant elevated permissions for fifteen minutes.
Standard user accounts are restricted from performing sensitive tasks, such equally viewing the contents of the /root directory. This prevents the accidental use of commands with massive consequences. Information technology also makes it more than difficult for intruders to compromise a system. However, sometimes you need to run an administrative command. Sudo – or Super User Do – grants y'all privileges to run sensitive tasks.
This simple tutorial volition show you how to add together a new user on Ubuntu and provide sudo access.
Prerequisites
- A system running a supported version of Ubuntu
- Admission to a root user account or another account with sudo privileges
- Access to a terminal window/command line (Ctrl–Alt–T)
Notation: Linux Sudo Control tutorials as well available for CentOS and Debian.
Steps to Add Sudo User on Ubuntu
Step 1: Create New User
ane. Log into the system with a root user or an account with sudo privileges.
ii. Open a terminal window and add a new user with the command:
adduser newuser
The adduser
control creates a new user, plus a group and abode directory for that user.
You may go an error bulletin that you have insufficient privileges. (This typically merely happens for non-root users.) Get effectually information technology past entering:
sudo adduser newuser
3. You can replace newuser
with whatsoever username you wish. The organization will add together the new user; and then prompt you lot to enter a password. Enter a corking secure password, then retype it to ostend.
4. The system will prompt you to enter additional information about the user. This includes a proper noun, phone numbers, etc. – these fields are optional, and tin can be skipped by pressing E nter.
Footstep 2: Add together User to Sudo Grouping
Most Linux systems, including Ubuntu, accept a user group for sudo users. To grant the new user elevated privileges, add them to the sudo grouping.
In a terminal, enter the command:
usermod -aG sudo newuser
Supercede newuser
with the username that you entered in Step ane.
Once again, if you go an error, run the command with sudo equally follows:
sudo usermod -aG sudo newuser
The -aG
pick tells the system to append the user to the specified group. (The -a
option is simply used with G
.)
Step 3: Verify User Belongs to Sudo Group
Enter the following to view the groups a user belongs to:
groups newuser
The organisation will answer past list the username and all groups it belongs to, for example: newuser : newuser sudo
Step 4: Verify Sudo Access
Switch users by inbound:
su - newuser
Replace newuser
with the username y'all entered in Pace 1. Enter your countersign when prompted. You can run commands as normal, merely past typing them.
For example:
ls /home
However, some commands or locations require elevated privileges. If yous try to listing the contents of the /root directory, you'll get an access denied error: ls /root
The command can be executed with:
sudo ls /root
The system will prompt for your password. Use the same countersign you lot set in Step i. You should at present encounter the contents of the /root directory.
Determination
Now you know how to add and create a user with sudo privileges on Ubuntu.
Before sudo, users would log in to their systems with full permissions over the entire system with the su command. This was risky as users could be exploited by tricking them into entering malicious commands. These vulnerabilities were solved by limiting account privileges. However, administrators even so had to log out of their business relationship and into an admin account to perform routine tasks.
The sudo
command in Ubuntu strikes a rest – protecting user accounts from malicious or inadvertent impairment while allowing a privileged user to run administrative tasks. To learn more about the difference between these commands, cheque out Sudo vs. Su.
Was this commodity helpful?
Yes No
How To Add User To Sudo In Linux,
Source: https://phoenixnap.com/kb/how-to-create-sudo-user-on-ubuntu
Posted by: johnstonyoulle.blogspot.com
0 Response to "How To Add User To Sudo In Linux"
Post a Comment