Linux make user admin

How can I create an administrator user from the command line?

@JizoSaves Generally speaking, it depends. adduser is more interactive, and useradd is designed for scripts.

4 Answers 4

Add the user to the sudo group with:

(If you’re running Ubuntu 11.10 or earlier, use the admin group.)

Default values are stored in /etc/adduser.conf , you can check them with

To create a user and add it directly to the sudo group use

(Again, use admin in place of sudo for 11.10 and earlier.)

Have a look at all the options you have with adduser here.

This is the first line of using -D : Option d is ambiguous (debug, disabled-login, disabled-password) . adduser interprets it as a mistake and tells you all the flags and options you can use . Definitely got nothing to do with defaults.

To create a new user with admin privileges in Ubuntu 12.04 and later:

In Ubuntu 11.10 and earlier, use this instead:

To modify a existing user (12.04 and later):

(Or for 11.10 and earlier: sudo usermod -aG admin )

-a stands for append whereas -G stands for groups. With the -a and -G flags as shown above, the sudo (or admin ) group will be added to the list of groups of which the user is a member.

When I do adduser foobar sudo before creating the user, in Xenial it says «adduser: the username `foobar’ does not exist», and it’s not shown in /etc/passwd , so I believe the user is not created.

On Trusty I get this: «` $ sudo adduser neue —group sudo adduser: Please specify a single name in this mode. $ sudo adduser neue sudo adduser: The user ‘neue’ does not exist. «`

The other answers are correct but you also asked about the home directory. You will also need a password for the new user.

sudo useradd *new-admin-username* -s /bin/bash -g sudo -m 
  • -s sets the user’s login shell
  • -m makes the user’s home directory if it doesn’t exist: /home/*new-admin-username*
  • -g adds the user to the sudo group so they will have admin privileges (>11.10)

Once created, add a password for the user:

sudo passwd *new-admin-username* 

Login to the user to see if everything worked:

su *new-admin-username* cd ~/ pwd 

Источник

How to Make a User an Administrator in Ubuntu

How to Make a User an Administrator in Ubuntu

If you have more than one user on your Linux system, you may not want all of them to perform administrative tasks or mess up private system settings. In this case, you can avoid giving these users administrative rights in Ubuntu. Unauthorized users won’t be able to install or uninstall software on your system, and they won’t be able to change important system settings and configurations. Even if you are not at your computer, unauthorized users cannot perform these tasks because they all need sudo privileges and must know the password for sudo.

Читайте также:  Библия linux 10 е издание негус

However, if you want to grant administrative privileges to a user, this article is for you.

In this article, I describe how to make a user an administrator through the graphical user interface and explain what commands you need to use on the command line to add a user to the sudo (authorized) user group.

We have run the commands and procedures mentioned in this article on an Ubuntu 20.04 and Ubuntu 22.04 system.

Make a User an Administrator in Ubuntu Through the GUI

In order to change user settings through the UI, you need to open the Users tab in the System Settings utility. You can access it through the following two ways:

Enter the ‘users’ keyword in the system Dash and click on the “Users” search result.

Users settings

Click on the downward arrow located in the top-right corner of your Ubuntu desktop, click on your username in the following view and then click Account Settings from the drop-down.

Account Settings

The Settings utility will open, displaying the Users tab. Please note that only an authorized user can change user settings in Ubuntu. First, you need to unlock the tab in order to make changes as an administrator by clicking the Unlock button located in the top-right corner of the Users view:

Users view

This will open the following Authentication dialog where you can provide the password for the authorized user:

Get sudo permissions

Enter the password and then click the Authenticate button. Now you can make changes to any user’s settings. Click on the username of the user you want to make an Administrator.

User details

In the Account Type of the user you will see two buttons; the Standard button and the Administrator button. Click on the Administrator button to make this user an Administrator. As soon as you do this, the user will be given administrative privileges and can now perform all operations that need root rights.

Make a User an Administrator in Ubuntu Through the Command Line

We will describe two ways to make a standard Ubuntu user an Administrator through the command line:

We will use the Ubuntu command line application, the Terminal, to perform this operation. You can open the Terminal either through the system Dash or the Ctrl+Alt+T shortcut.

Method 1: The usermod command

Open the Terminal and enter the following command as sudo as only an authorized user can edit user settings in Ubuntu:

$ sudo usermod -aG sudo “username”

In this example we will use the following command to make a user with the username “sampleuser” an administrator:

$ sudo usermod -aG sudo sampleuser

Use usermod command to give admin rights to a Ubuntu user

Enter the password for sudo and the user will be added to the “sudo” group which means that he/she can perform all administrative tasks on Ubuntu.

You can verify that the user is now in the “sudo” group by checking the groups a user belongs to, through the following command:

The following output of the ‘groups’ command for our “sampleuser” indicates that he/she is now part of the sudo group.

Check sudo permissions

Method 2: The gpasswd command

Open the Terminal and enter the following gpasswd command as sudo as only an authorized user can edit user settings in Ubuntu:

$ sudo gpasswd -a “username” sudo

In this example, we are adding the “sampleuser” to the sudo group through the following command:

$ sudo gpasswd -a sampleuser sudo

Use gpasswd command to make user and admin

You can also remove a user from the sudo group through the -r switch in the same gpasswd command:

$ sudo gpasswd -d “username” sudo

In this example, we are removing the “sampleuser” from the sudo group through the following command:

$ sudo gpasswd -a sampleuser sudo

Remove user from sudo group

Through the methods described in this article, you can make an ordinary Ubuntu user an Administrator so that they can perform all tasks that require root privileges on the system.

Читайте также:  Linux qr code reader

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

How to Make a User an Administrator in Debian 11

Debian Administrator User

If you have multiple user accounts in your system, it is not a good idea to give administrative privileges to all of them. It is always safe to limit the privileges of certain accounts to prevent unauthorized and potentially harmful changes to the system.

However, if you want to assign administrative privileges to certain users, you can do it using various methods. In this article, we will discuss the methods you can use to make a user an administrator in your Debian operating system. This includes both the GUI and the command line. When you make a user an administrator, they are given all administrative privileges, such as installing and uninstalling software, making changes to system settings and configurations, etc.

We used Debian 11 and Debian 10 to successfully test the commands and procedures mentioned in this article.

Make a User an Administrator in Debian Through the GUI

In the following method, we will make a user an administrator though the Settings utility. To open the settings utility in your Debian system, hit the super key on your keyboard and type users. You will see the Settings icon in the results as shown in the following screenshot. Click on it to open the Settings utility directly in the Users tab.

Users

Alternatively, go to the top right corner of your desktop and click on the downward arrow. From the menu that appears, click on the Account Settings to open the Settings utility in the Users tab.

Account settings

When the settings utility will open, you will see the following view. To make the changes, make sure you have administrator privileges, otherwise, you will not be able to make any kind of changes.

Now you will need to unlock the tab to make required changes. To do so, click the unlock button at the top right corner of the following window.

Debian user account settings

You will be prompted to enter the password for the authorized user. Enter the password and click Authenticate.

Authenticate as admin to be able to change the account

Now you are allowed to make changes to any user’s settings. Select the user you want to make an administrator. There you will see two labels: Standard and Administrator next to the account type of the user. Click on the Administrator to assign the selected user an administrator privilege.

Make user an administrator

Make a User an Administrator in Debian Through the Command Line

In the following method, we will make the user an administrator through the following command line methods:

To open the command line terminal application in the Debian OS, go to the Activities tab in the top left corner of your desktop. Then in the search bar, type terminal. When the Terminal icon appears, click on to launch it.

Through the usermod command

To make a user an administrator, enter the command in the Terminal using the following syntax:

$ sudo usermod -aG sudo “username”

In the following example, we are going to make our user with the name “testuser” an administrator:

$ sudo usermod -aG sudo testuser

You will be prompted to enter the password. Enter the sudo password and the user will be added to the sudo group. The next time the user logs in, it will be granted sudo privileges.

Читайте также:  Linux send message to terminal

usermod command

To verify if the new user has been added to the sudo group, you can run the following command:

For instance, to verify if the “testuser” is in the sudo group, the command would be:

The output shows our user “testuser” is now in the sudo group and have all administrator privileges.

groups command

Through the gpasswd command

Another way of making a user an administrator is through the gpasswd command. To do so, open the Terminal and enter the command in the following syntax.

$ sudo gpasswd -a “user_name” sudo

For instance, to add “testuser” in the sudo group, the command would be:

$ sudo gpasswd -a testuser sudo

By running this command, our user will be added to the sudo group and will be granted administrator privileges.

gpassword command

In case, you want to remove the user from the sudo group added via gpasswd command, you can do so using the following command:

$ sudo gpasswd -a sampleuser sudo

For instance, to remove our user “testuser” from the sudo group, we will enter the following command:

$ sudo gpasswd -a testuser sudo

Add sudo privileges to user using gpassword

So these were some methods using which you can make an ordinary user an administrator so that they can perform any kind of administrative tasks on the system.

Search

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

How to Grant Admin Privileges to a User in Linux

Want to control and manage users on your Linux system? Here’s what you need to know about granting admin rights in Linux.

get-admin-rights-in-linux

Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

Need to get admin privileges in Linux, but not sure how? Today we’ll discuss how to quickly grant administrative rights to a specific user on Ubuntu and Arch Linux.

Why Do I Need Admin Privileges?

While using a Linux system, when you try to attempt any kind of administrative task, like installing or removing software, you might get an error saying you don’t have the right permissions. This can be frustrating at times, but getting admin rights on Linux isn’t as hard as it sounds.

In fact, there are multiple tools at your disposal, depending on the distribution you use. However, remember that non-root users can’t grant admin rights to anyone, so you’ll need to sign in as another user that does have the admin status.

These users, technically defined, belong to the sudo or sudoers group. This means that they can issue sudo commands by entering their user passwords. Passwords are required to authorize users so that they can execute administrative tasks on the system.

To gain admin rights, you need to belong to the right group, and we’ll explain how to do that below.

How to Grant Admin Permissions in Ubuntu

Desktop environments make it easy to control user permissions, regardless of your comfort level with the inner workings of Linux. You can use a GUI app to manage users on the desktop, or you can complete the same task with more efficiency through the command line.

Granting Admin Rights via the Desktop

In Debian-based distributions such as Ubuntu and Linux Mint, you’ll find a user management tool in your system settings. Search for user in the app launcher and the user management utility will usually be on top of the results.

Источник

Оцените статью
Adblock
detector