Linux add admin user

How to add an user called «admin»

So, I guess, by default, adduser is trying to create an «admin» group that already exist at the same time as creating the «admin» user. Reading adduser man page I’ve seen -N option to avoid goup creation. I tried this:

I can’t find any reference to a -N option, however you should be able to use either —ingroup GROUP to set the new user’s primary group to an existing group GROUP , or —group GROUP to set the new user’s primary group to a non-preexisting group GROUP , overriding creation of the default user private group.

as far as i know, admin is a system account and is created by default. It’s not assigned to any particular user. You could make a different account, admin1 though. That’s what i personally did

—ingroup did the trick, thank you very much. For -N option reference: manpages.ubuntu.com/manpages/trusty/en/man8/useradd.8.html -N, —no-user-group Do not create a group with the same name as the user, but add theuser to the group specified by the -g option or by the GROUP variable in /etc/default/useradd.

2 Answers 2

As steeldriver suggest, this works:

# adduser admin --ingroup sudo 

You should never create a user called exactly «admin». On many distributions this user exists and is used for system purposes. Some applications may refer to it too. If you create this user he may have unrestricted root-like system access through security settings in some scripts. If you try to alter this user’s rights some applications will stop working.

Then at least mention that you did that when asking fiurther questions if something on the system does not work.

I say «If something on that system not works and you ask questions about it, you must state that you created admin user and what you did with it, because it may be the cause of malfunction».

Ok, I understand. This issue happens in a fresh installation of Ubuntu 14.04.5. Create this «admin» user is the first thing I’m doing with Ubuntu. So, I did nothing with the user and the OS yet.

Источник

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 disk usage command

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.

About This Site

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

Latest Tutorials

Источник

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 

Источник

Читайте также:  Linux software distribution system

How To Create a New Sudo-enabled User on Ubuntu 20.04 [Quickstart]

How To Create a New Sudo-enabled User on Ubuntu 20.04 [Quickstart]

When managing a server, you’ll sometimes want to allow users to execute commands as “root,” the administrator-level user. The sudo command provides system administrators with a way to grant administrator privileges — ordinarily only available to the root user — to normal users.

In this tutorial, you’ll learn how to create a new user with sudo access on Ubuntu 20.04 without having to modify your server’s /etc/sudoers file.

Note: If you want to configure sudo for an existing user, skip to step 3.

Step 1 — Logging Into Your Server

SSH in to your server as the root user:

Step 2 — Adding a New User to the System

Use the adduser command to add a new user to your system:

Be sure to replace sammy with the username that you want to create. You will be prompted to create and verify a password for the user:

Output
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully

Next, you’ll be asked to fill in some information about the new user. It is fine to accept the defaults and leave this information blank:

Output
Changing the user information for sammy Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n]

Step 3 — Adding the User to the sudo Group

Use the usermod command to add the user to the sudo group:

Again, be sure to replace sammy with the username you just added. By default on Ubuntu, all members of the sudo group have full sudo privileges.

Step 4 — Testing sudo Access

To test that the new sudo permissions are working, first use the su command to switch to the new user account:

As the new user, verify that you can use sudo by prepending sudo to the command that you want to run with superuser privileges:

For example, you can list the contents of the /root directory, which is normally only accessible to the root user:

The first time you use sudo in a session, you will be prompted for the password of that user’s account. Enter the password to proceed:

Output:
[sudo] password for sammy:

Note: This is not asking for the root password! Enter the password of the sudo-enabled user you just created.

If your user is in the proper group and you entered the password correctly, the command that you issued with sudo will run with root privileges.

Conclusion

In this quickstart tutorial, we created a new user account and added it to the sudo group to enable sudo access.

For your new user to be granted external access, please follow our section on Enabling External Access for Your Regular User.

If you need more detailed information on setting up an Ubuntu 20.04 server, please read our Initial Server Setup with Ubuntu 20.04 tutorial.

Get Ubuntu on a hosted virtual machine in seconds with DigitalOcean Droplets! Simple enough for any user, powerful enough for fast-growing applications or businesses.

Источник

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