M01:
Introduction to Operating Systems |
TU1: Installing, configuring
and exploiting a computer system |
ASIX1- DAW1 |
Practical Exercise 6: Managing users and groups accounts | 09-01-23 |
Practical
Exercise 6: Managing users and groups accounts
On Linux:
* A user is a real person or program which
can access to some resources of a computer such as folders,
files, programs, hardware and so on.
* A group is a collection of users. Groups
are used as a basis for determining file access permissions. It
depends on your groups membership that you will be able to
access or not to certain folders, files, hardware, databases and
so on.
In order to define properly a new user, you
must provide to the system some basic information. A system user
will need:
a)
A username
b) Usually,
an encrypted password
c)
Most times (but it is not mandatory), a personal home directory
where the user can store his/her/its personal data and personal
configuration files and enviroment variables.
d) A
numerical value called User IDentifier or UID associated
with the username. The user will be identified by the system
thanks to its UID rather than its username.
e) A
default group. A user must be member of one or more groups. If a
user is member of just one group, that group will be its default
group. The group name must exist. Instead of a group name, you
can write the unique number that identifies the group.
f)
A default shell, usually /bin/bash.
g)
Another additional characteristics like comments, expiry date,
additional groups memberships and so on.
h) User environment variables. This variables are a tool
to customize how the user interacts with the system.
The value of an environment variable can for example be the
location of all executable files in the file system, the default
editor or browser that should be used, default language, colors
used in the terminal, location of some personal
configuration files and folders,.....
i) An entry in files /etc/passwd
and /etc/shadow where the vast majority of this
information about the user is stored.
In order to define properly a new group, you
must provide to the system some basic information. A system
group will need:
a)
A group name.
b) A numerical value
called Group IDentifier or GID associated with the group
name. The group will be identified by the system thanks to
its GID rather than its group name.
c)
Users which are member of that group.
h)
An entry in files /etc/group and /etc/gshadow
where all this information about the group is
stored.
In order to configure and manage system users and groups, the Linux operating provides you with a set of command-line utilities: a) useradd adds a new user account to the system, b) userdel deletes a user's account, c) usermod modifies a user's account, d) groupadd adds a new group to the system, e) groupdel removes a group and f) groupmod modifies a group.
The purpose of this exercise is:
a) Firstly, to learn how to manage
(add, delete and modify) user and group account on Linux.
b) Secondly, we will study the main chararacterisitics of system user
and groups, and how to modify these characteristics.
c) Finally, we will study the contents
of /etc/passwd, /etc/group and
/etc/shadow.
2- mkpasswd
a) Descrition: The command-line utility mkpasswd encrypts a given
password. This command is part of a package called whois.
You have to install whois in order to install
mkpasswd on your system.
b) Synopis: mkpasswd
PASSWORD
c) As a result, a encrypted version of PASSWORD will
be displayed on screen
d) Example:
linux:~ # mkpasswd FjeClot@20
Ab1VoXikXZ6E2
4- userdel
a) Description: The
useradel command deletes an user account.
b) Synopsis 1: userdel
username ==> The user will be deleted but not
its home folder. Entries in /etc/passwd, /etc/shadow and
/etc/group will be deleted. Folder /home/username will not be
deleted.
c) Synopsis 2: userdel -r
username ==> The user will be deleted and its home folder as
well. Entries in
/etc/passwd, /etc/shadow and /etc/group will be deleted. Folder
/home/username will be deleted.
d) Example: If you want to
completely remove the user tux, you should run the
following command: userdel
-r tux
9- gpasswd: Removing a user from a group. Adding a user to a group
PRACTICAL EXERCISE
1- Install
a package called whois on your system. This package
contains mkpasswd, a command that provides encrypted
versions of any given password.
2- Create a group called clot2023 with GID = 2023. Look at changes at /etc/group. Check and show clearly that a new group called clot2023 has been added to your system.
3- Add to the skeleton the
following directories: Desktop, Documents,
Downloads, Public and Temporal.
4- Create a
new user called clot2023, with
the following characteristics:
a) User identifier will be 2023
b) By default is member of the clot2023 group
c) Home directory
will be /home/clot2023
d) The default shell will be the bash program
e) The password (the version with no encryption for the user)
will be FjeClot23#
f) Additionally, the new user will be member of vboxsf
and sudo groups
g) /etc/skel will be the skeleton directory
for the new user
5- Create a new user called fje, with the following characteristics:
a) User identifier will be 1023,
b) By default is member of the users group
c) The Home directory will be /home/fje
d) The default shell will be the bash
program,
e) The password (the
version with no encryption for the user) will be Clot2023$
f) Additionally, the new user will be member of
the vboxsf group.
g) /etc/skel will be the skeleton
directory for the new user.
6-
Do the following tasks:
a) Look at changes at /etc/passwd and /etc/shadow. Check and show clearly that a new user called clot2023
has been added to your system.
b) Check that a new directory called /home/clot2023 has
been created on your system. Check the contents of /home/clot2023.
7- Working on
terminal: Become clot2022.
Check your environment:
a) Run env and check your
$HOME environment variable. What is the meaning of data stored
in variable $HOME?
b) Run env
and check your $PATH environment variable. What is the meaning of data
stored in variable $PATH?. Why is so important?
c) Run
env and check your $SHELL environment variable. What is the meaning of data
stored in variable $SHELL?.
d) Run
env and check your $USER environment variable. What is the meaning of data
stored in variable $USER?.
8- Create a new group called
students23 with GID = 223. Look at changes
at /etc/group. Check and show clearly that a new
group called students23 has been added
to your system.
9- Modify clot2023's UID and change it to 3023. Look at changes at /etc/passwd. Check and show clearly that user clot2023 has been modified.
10- Add clot2023 and fje users to students23 group. Look at changes at /etc/group. Check and show clearly that
users clot2023 and fje have
been added to students23.
11- Swap clot2023 default group to adm group. Look at changes at /etc/passwd. Check and show clearly that user clot2023 has been modified.
12- Modify students23 GID and change it to 323. Look at changes at /etc/group. Check and show clearly that
group students23 has been modified.
13-
Show the
groups user clot2023 is in.
14- Show members of group students23.
15- Modify
clot2023's password. The new
password will be FJEclot23@.
16- Remove
clot2023 and fje from students23 group.
Look at changes
at /etc/group. Check and show clearly
that users clot2023 and
fje have been removed from students23.
17-
Remove
clot2023 and his/her home
directory. Check and show clearly that:
a) User clot2023
has been removed from /etc/passwd and /etc/shadow.
b) Directory /home/clot2023 has
been removed from your system.
18-
Remove
students23. Look at changes at /etc/group. Check and show clearly
that students23 has
been removed from your system.
19-
Disable and lock the fje user account. Try to gain access to the fje account. What
happens?.
20- Enable and unlock the fje user account again. Try to gain access to the fje account. What happens?.