Ubuntu 22.04 LTS: Manage Users

ubuntu22-04

Initial Settings

After installing Ubuntu System, there is only a user you configured during installation except System Accounts and he is an administrative user. If you'd like to add more common user accounts on System, Configure like follows.

Manage Users

Step [1] For example, Add a [jammy] user.


ubuntu@bizantum:~$ sudo adduser jammy
[sudo] password for ubuntu:  # input self password
Adding user `jammy' ...
Adding new group `jammy' (1001) ...
Adding new user `jammy' (1001) with group `jammy' ...
Creating home directory `/home/jammy' ...
Copying files from `/etc/skel' ...
New password:           # set user password
Retype new password:    # confirm
passwd: password updated successfully
Changing the user information for jammy
Enter the new value, or press ENTER for the default
        Full Name []:   # input user info (OK with empty all if you do not need)
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
ubuntu@bizantum:~$

Step [2] If you'd like to give privileges to a new user, Configure like follows.


ubuntu@bizantum:~$ sudo usermod -aG sudo jammy
ubuntu@bizantum:~$ su - jammy
Password:
# try to run a command which requires root privilege
jammy@bizantum:~$ sudo ls -l /root
[sudo] password for jammy:     # input self password
total 4
drwx------ 3 root root 4096 Apr 22 13:31 snap

Step [3] If you'd like to remove user accounts, Configure like follows.


# remove a user [jammy] (only removed user account)
ubuntu@bizantum:~$ sudo deluser jammy
# remove a user [jammy] (removed user account and his home directory)
ubuntu@bizantum:~$ sudo deluser jammy --remove-home

Enable root User

The root Account in Ubuntu is disabled by default because his password is not set. To use root priviledges, basically it's better to use the sudo command with administrative accounts. However, if you'd like to use root Account itself by some reason, it's possible to use like follows.

Step [4] The user account added during installation is set an administrative account with Sudo, so it's easy to get root account's shell like follows.


ubuntu@bizantum:~$ sudo -s
[sudo] password for ubuntu:   # input self password
root@bizantum:/home/ubuntu#   # just switched

Step [5] Or it's possible to switch to root account with standard su command to set root account's password.


ubuntu@bizantum:~$ sudo passwd root
[sudo] password for ubuntu:   # input self password
New password:                 # set root password
Retype new password:          # confirm
passwd: password updated successfully

ubuntu@bizantum:~$ su -
Password:                     # input root password
root@bizantum:~#              # just switched

The examples on this site shows by root user account. If you use Sudo, add [sudo] on the head of commands. For the security reason it's better to restrict users who can [su] to root if you enable root account like follows. For using by Sudo, it's possible to limit to prohibit shells in sudoers config, refer to details about Sudo Settings.

Step [6] For [su] command restriction, set like follows.


root@bizantum:~# vi /etc/pam.d/su
# line 15 : uncomment and add a group which is allow to run [su] command
auth       required   pam_wheel.so  group=adm

# add an user you allowed to run [su] to the group you set above
root@bizantum:~# usermod -aG adm ubuntu

Comments

Popular posts from this blog

Debian 12 Bookworm: Install Kubeadm
Introduction In this article, we will explore the what, who, where, when, why, and how of Kubeadm functionality on the Debian 12 Bookworm platform, so let's get started.
Fedora 40 : Mail Server
Introduction This guide covers the installation and configuration of a mail server on Fedora 40. It will help you understand the what, who, where, when, why, and how of setting up a mail server.
Cyber Security: NIST Overview
Overview The National Institute of Standards and Technology (NIST) is a pivotal entity in the United States that plays a crucial role in advancing measurement science, standards, and technology. Understanding NIST’s functions, importance, and impact is vital for various industries and sectors.
Cyber Security: ISO 27001 Overview
Introduction ISO 27001 is an international standard for information security management systems (ISMS). It provides a framework for managing sensitive company information to ensure it remains secure. Understanding ISO 27001 is crucial for organizations aiming to protect their information assets.
AlmaLinux 9: How to Install
Introduction AlmaLinux 9 Server is a free and open-source Linux distribution that provides a stable and secure platform for server environments. It's a popular choice for both enterprise and personal use due to its reliability and robust features. This guide will walk you through the steps to install AlmaLinux 9 Server on your system.
AlmaLinux 9: Overview
Introduction AlmaLinux 9 is a robust, open-source enterprise operating system that serves as a community-driven alternative to CentOS. Designed to deliver stability, performance, and long-term support, AlmaLinux is an excellent choice for servers in diverse environments, from small businesses to large enterprises.