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
Post a Comment
Thank you for your comment! We appreciate your feedback, feel free to check out more of our articles.
Best regards, Bizantum Blog Team.