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

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.
Comprehensive Guide to Windows Subsystem for Linux (WSL): Benefits, Setup, and Usage
Introduction Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables natively on Windows 10, Windows 11, and Windows Server. It allows users to run a GNU/Linux environment directly on Windows, including most command-line tools, utilities, and applications.
Ultimate Guide to COBIT: Framework, Benefits, Implementation, and Impact
Introduction COBIT (Control Objectives for Information and Related Technologies) is a globally recognized framework for managing and governing enterprise IT. It provides comprehensive guidelines for organizations to achieve their objectives through the effective use of IT.
Understanding ISO/IEC 20000: A Comprehensive Guide to IT Service Management
Introduction ISO/IEC 20000 is an international standard for IT Service Management (ITSM). It provides a framework for managing and delivering IT services that meet business needs and customer requirements. The standard ensures consistent and high-quality IT service delivery through a set of processes and best practices.
Top SEO Tools for Digital Marketing: A Comprehensive Guide
Introduction In today's digital landscape, search engine optimization (SEO) is a critical component for any business looking to enhance its online presence and drive organic traffic. With the myriad of SEO tools available, navigating the digital marketing space can seem daunting. To streamline your efforts and achieve optimal results, it's essential to leverage the right tools that cater to your specific needs.
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.