- [Instructor] Welcome to the next video
of the last section,
User Administration Script.
In the previous video,
we've seen how to write and read
the minus sequel database from bash.
This video aims at writing a user management tool
that can handle all the tasks.
GNU Lynux is a multi-user operating system
allowing many users to log in
and perform several activities at the same time.
There are several administration tasks
that are handled with user management
which include setting the default shell for the user,
disabling a user account,
disabling a shell account,
adding new users,
removing users,
setting a password,
setting an expiry date for user account, and so on.
Let's go through the user administration script.
A sample output is as follows.
The user_adm.sh script can be used
to perform many user management tasks.
You can follow the usage text
for the proper usage of the script
which is called when any of the parameters
given by the user is wrong or has the minus usage parameter.
A case statement is used to match the command arguments
and execute the corresponding commands
according to that.
The valid command options for the user adm sh script are
minus add user, minus deluser, minus shell,
minus disable, minus enable, minus expiry,
minus password, minus newgroup,
minus delgroup, minus add group,
minus details, and minus usage.
When this command case is matched,
it means that a wrong operation
then hence usage is invoked.
For each match case we have used this command as usage.
It is used for checking a number of arguments.
If a number of command arguments are not
equal to the required number,
the usage function is invoked
and the script will exit without executing further.
In order to run the user management commands,
this script needs to be run as root
and hence a check for the user ID zero,
root has user ID zero is performed.
Let's explain each case one by one.
The user add command can be used to create a new user.
It has the following syntax.
The minus M option is used to create the home directory.
It's also possible to provide the full name
of the user by using the minus C full name option.
The deluser command can be used to remove the user.
The syntax is as follows,
minus minus remove minus all minus files
is used to remove all files associated
with the user including the home directory.
Minus shell, this chsh command is used
to change the default shell for each user.
The syntax is--
Minus disable and minus enable.
The usermod command is used to manipulate
several attributes related to user accounts.
User mod minus capital L user locks the user account
and user mod minus capital U user unlocks the user account.
Minus expiry,
the chage command is used to manipulate
user account expiry information.
The syntax is.
There are additional options as follows,
minus M mindays, set the minimum number of days
between password changes to mindays.
Minus capital M maxdays, set the maximum number of days
during which a password is valid.
Minus capital W warndays, set the number of days
of warning for a password change is required.
The password command is used to change passwords
for the users.
The syntax is--
The command will prompt to enter a new password.
Minus newgroup and addgroup.
The addgroup command will add a new user group
to they system.
The syntax is.
In order to add an existing user to a group, use --
The delgroup command will remove a user group.
The syntax is--
Minus details, the finger user command
will display the user information for the user
which includes such details such as
user home directory path, last login time,
default shell, and so on.
The chage minus L command will display
the user account expiry information.
Awesome.
We've successfully learned about
user administration scripts.
In the next video, we'll learn about
bulk image resizing and format conversion.