Linux make user admin

How to create a user account on Ubuntu Linux

Steps to create a user account on Ubuntu Linux

  1. Open the terminal application
  2. Log in to remote box by running the ssh user@your-ubuntu-box-ip
  3. To add a new user in Ubuntu run sudo adduser userNameHere
  4. Enter password and other needed info to create a user account on Ubuntu server
  5. New username would be added to /etc/passwd file, and encrypted password stored in the /etc/shadow file

Let us see all commands in details and

Ubuntu create user account commands

Let us say you need to add a new user in Ubuntu called vivek, type the following command in your shell:
$ sudo adduser vivek
Type your own password and other info:

Verification

Use the grep command or cat command as follows:
$ cat /etc/passwd
$ grep ‘^vivek’ /etc/passwd
Sample outputs:

How do I log in using ssh?

From your Windows (WSL) or macOS or Linux desktop, run:
$ ssh vivek@your-aws-ubuntu-server-ip
OR
$ ssh -i

/.ssh/aws.pub.key vivek@your-aws-ubuntu-server-ip
Enter the password when prompted.

Creating a user account using useradd command on Ubuntu

Alternatively, you can use the useradd command is a low level utility for adding users on Ubuntu. The syntax is:
$ sudo useradd -s /path/to/shell -d /home/ -m -G
$ sudo passwd
Let us create a new user named vivek using the useradd command on Ubuntu:
$ sudo useradd -s /bin/bash -d /home/vivek/ -m -G sudo vivek
$ sudo passwd vivek
Where,

  • -s /bin/bash – Set /bin/bash as login shell of the new account
  • -d /home/vivek/ – Set /home/vivek/ as home directory of the new Ubuntu account
  • -m – Create the user’s home directory
  • -G sudo – Make sure vivek user can sudo i.e. give admin access to the new account

I strongly recommend installing ssh keys while creating the new user account. You must have RSA/ed25519 key pair on your local desktop/laptop . Use the cat command to view your current RSA/ed25519 public key on the desktop:
$ cat

View public ssh key on your macos/unix/linux desktop

How to delete a user account

Use the userdel command as follows:
sudo userdel
sudo userdel vivek
To remove home directory and mail spool too, enter:
sudo userdel -r
sudo userdel -r jerry

How to change Linux user password

Run the following passwd command:
sudo passwd
sudo passwd tom
To change your own password, enter:
passwd
First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. The new password must be entered twice to avoid password mismatch errors.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard
Читайте также:  Установка яндекс браузер альт линукс

Join Patreon

Conclusion

In this quick tutorial, you learned how to add users in Ubuntu Linux using the CLI. The same commands works for any Debian/Ubuntu based distribution too. See useradd man page using the man command or read it online here:
man 8 useradd
man 8 passwd
man 8 adduser

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to Make a User an Administrator in Ubuntu

If you have more than one user on your Linux system, you might not want all of them to perform administrative tasks or mess up with private system settings. In that case, you can avoid giving administrative privileges on Ubuntu to those users. Unauthorized users can not install or uninstall software on your system and neither can they change key system settings and configurations. Even if you are away from your computer, any unauthorized user cannot perform these tasks as all of them require sudo rights and need to know the password for sudo.

However, if by will you want to grant administrative rights to a user, this article is here for your help.

In this article, I will describe how to make a user an Administrator through the Graphical User Interface and also explain what commands to use in the command line in order 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 LTS 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.

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.

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:

Advertisement

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

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.

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:

  • Through the usermod command
  • Through the gpasswd command

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:

Читайте также:  Одновременная установка windows linux

$ sudo usermod -aG sudo “username”

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

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.

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:

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:

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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Источник

Add a new user account with admin access on Linux

Create a new user account with admin (sudo) access on Ubuntu or Debian Linux

Commands to add or create a sudo user (admin) on an Ubuntu or Debian Linux server:

  • Open the terminal application
  • For remote Ubuntu/Debian server use the ssh command and log in as the root user using either su or sudo.
  • Create a new user named marlena , run: adduser marlena
  • Make marlena user ‘sudo user’ (admin) run: usermod -aG sudo marlena
  • Verify it by running the id marlena command
  • Log in as marlena: su — marlena . Than run sudo command for verification. For example: sudo ls -l /etc/shadow

A note about granting sudo account for an existing Ubuntu/Debian Linux user

The syntax is (must run as the root user):
# adduser sudo
## add user named ‘sai’ to sudo group ##
# adduser sai sudo
Another syntax:
usermod -aG sudo UserNameHere
Log in as the root user and add an existing user accout named ‘sai’ to sudo group:
usermod -aG sudo sai
id sai
See “How to create a new sudo user on Ubuntu Linux server” for more info.

RHEL or CentOS create a new user account with admin (sudo) access

Procedure to add or create a sudo user (admin) on CentOS or RHEL:

  • Open the terminal application
  • For remote CentOS server use the ssh command and log in as the root user using either su or sudo.
  • Create a new CentOS user named vivek , run: useradd vivek
  • Set the password, execute: passwd vivek
  • Make vivek user ‘sudo user’ on CentOS/RHEL, run : usermod -aG wheel vivek
  • Verify it by running the id vivek command

How to grant sudo access for an existing RHEL/CentOS Linux user

The syntax is as follows for the usermod command and id command:
# usermod -aG wheel User-Name-Here
Add an existing user account named kirsh to wheel group. In other words, type the following two commands:
# usermod -aG wheel krish
# id krish
See Add / Create a Sudo User on CentOS Linux 8 for more info.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard
Читайте также:  Как правильно настроить windows 10 manager

Join Patreon

Conclusion

You learned how to create a sudo (admin level access) user account on both Ubuntu/Debian and RHEL/CentOS Linux servers. See sudo docs here.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to Give Standard Users Admin (Root) Rights on Ubuntu 16.04 | 18.04

This brief tutorial shows students and new users how to give standard user administrative rights or privileges to make changes to Ubuntu systems. If you want a standard user to make changes in Ubuntu, you’ll want to give them administrative privileges.

In Ubuntu, you can change which users have administrative privileges and which ones do not. Users who have admin rights or are member of the sudo system tool can make global changes to Ubuntu, including deleting critical files and other user accounts on the system.

A good way to keep your system secure from authorized changes is to limit some user accounts types to standard. which may keep them from making potentially damaging changes to your system.To get started with changing user account types in Ubuntu, follow the steps below:

Option 1: Changing Ubuntu Account Types on the Desktop

There are multiple ways one can change Ubuntu account types. Most desktop users will use the graphical user interface (GUI) to make account changes.

You need administrator privileges to change account types. The first user account on the system is usually the one that has administrator privileges. This is the user account that was created when you first installed the system.

To change account types via the desktop, follow the steps below:

  • Open the Activities overview and start typing Users.
  • Click Users to open the panel.
  • Press Unlock in the top right corner and type in your password when prompted.
  • Select the user whose privileges you want to change.
  • Click the label Standard next to Account Type and select Administrator.
  • The user’s privileges will be changed when they next log in.

You can also select System setting from the top right corner of the menu.

Then navigate to Details –> Users panel. Press Unlock in the top right corner and type in your password when prompted.

Now you can select the user account and change the type to Administrator as shown below:

Exit and the account privileges will change the next time the user logs on.

Option #2: Changing User Account Type via Command line

If you prefer the command line or on a server environment, you can use the command line below to make give an account administrative rights or privileges.

Linux, including Ubuntu has a tool called sudo. which allows users to run programs with administrative rights.

By default on Ubuntu systems, members of the sudo group are granted with sudo access. If you want a standard account to run commands or programs with admin rights, make them a member of the sudo group.

To make janedoe standard member of the sudo group, run the commands below:

sudo usermod -aG sudo janedoe

The next time Jane Doe logs in, that account will have sudo privileges granted.

To validate, run the commands below to switch to janedoe account.

Then run whoami command to see what the user account type is.

The output should be:

Congratulations! You have successfully learned how to change account types in Ubuntu via the GUI and command line.

Источник

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