Linux Project

Photo by Andrew Neel on Unsplash

Linux Project

Project Description: In this project, you will write a shell script that automates the process of creating a new user, creating a new folder, granting access, creating a new group, adding the user to the group and folder, granting the user sudo access, and setting appropriate file permissions.

Project Steps:

⮚ Create two folders named: Technical and Manager
>mkdir <foldername>

Create a ‘Technical’ group having access of the Technical folder and a ‘Manager’ group having access of the Manager folder.
>groupadd <groupname>

\>change the folder group by using chgrp command

>sudo chgrp <groupowner> <file>
check by using ls -ld groupname

⮚ Set appropriate permissions to the folders.
>chmod g+rwx <groupname>

⮚ Ask the user for the name of the new user to be created.

create a new user by using below command with read:-
echo "Please enter the username" read username
>useradd <username>

⮚ Ask the department name ‘Technical’ or ‘Manager’. If technical add it to the technical group else add the user to the manager group.
To add a user into a specific group use below command:-
if [ "$departmentName" == "Technical" ];
then
>gpasswd -a $username Technical
echo "User: $username is added into the Techincal group"
else
>gpasswd -a $username Manager
echo "User: $username is added into the Manager group"

⮚ Grant sudo access to the new user.
To give sudo access to the new user, use the below command
>sudo usermod -aG sudo <username>
To verify the user is added to the sudo group use the below command
>groups <username>

⮚ At the end of the script, print a message that summarizes what was created and what access was granted.