In: Computer Science
Using your Virtual machine, do the following tasks. Put the commands you executed in this document.
PART1:
You will be required to add 3 users to your system. For the sake of simplicity, use the following information for your user accounts:
USER1
Full Name / Comment: George Jetson
Username: jetsong
Password: jetsong
USER2
Full Name / Comment: Fred Flintstone
Username: flintstonef
Password: flintstonef
USER3
Full Name / Comment: Johnny Bravo
Username: bravoj
Password: bravoj
Requirements: You must add the users as displayed above, when creating an account; you must only use the useradd command from the command line (NO GUI). You must also make sure that each user has a valid home folder under /home. You should set their SHELL to /bin/bash.
Each user should have the necessary password set for their account as well as the description (a.k.a. comment field) for future reference if needed. Each user has to change their password on their first login, and the password needs to be changed every 60 days. Johnny was only hired temporarily and his account will need to expire in 3 months, so after 3 months, Johnny should not be able to gain access to his account.
You have to use the specific commands available in Linux to either create a user with all pertinent information all at once, or by utilizing other commands which will help modify existing users with updated info piece by piece – like comments.
Put your commands here:
PART2:
You must create a directory structure to this effect off the root of the file system (/):
image.png
The Cartoons folder should be owned by root, and the primary group set to cartoons
The Jetsons folder should be owned by jetsong, and the primary group set to cartoons.
· The permissions on the folder should allow George to have FULL permissions and no permissions for anyone else.
The Flintstones folder should be owned by flintstonef, and the primary group set to cartoons.
· The permissions on the folder should allow Fred to have FULL permissions and no permissions for anyone else.
The JohnnyBravo folder should be owned by bravoj, and the primary group set to cartoons.
· The permissions on the folder should allow Johnny to have FULL permissions and no permissions for anyone else.
The Shared folder should be owned by root, and the primary group set to entertainment.
· The permissions should be FULL permissions to root and FULL permissions to the primary group, and the ability for your account to access and read the folder and everything within (including music and videos)
Under each folder in Cartoons, make a symbolic link called ‘Shared’, to the‘Shared’ folder under ‘Entertainment’
The Shows and Movies directories should be owned by root and the primary group should be set to entertainment.
· The permissions should be FULL permissions to root and FULL permissions to the primary group and no other permissions.
Put your commands here:
Question 1: Log into your system using the accounts you created from above and see what happens when you try and access the specific folders within Cartoons, what happens?
Question 2: What permissions are needed in order for anyone in the group cartoons to access any of the individualized folders within Cartoons?
Question 3: What command would you use to assure that regardless of who creates folders within the Shared folder that the primary group is always entertainment?
Question 4: What groups do the users have to be in, to be able to write to the shared folder?
Submission requirements:
· Hilight answers in YELLOW
· Include: a copy of your password file (not a screenshot)
· A copy of your groups file (not a screenshot)… you can put the 3 files in a folder, then compress the folder to zip file
Your submission must be uploaded to SLATE as ONE zip file, called ‘Firstname-Lastname-A1.zip’ (use your name).
If you have any questions, please contact your teacher.
Part -1:-
1. Make sure you are logged in as root user.
2. Create an Entertainment folder on Root directory (/)
mkdir /Entertainment
Create Cartoons folder and inside Entertainment Directory
mkdir /Entertainment/Cartoons
3. Creating 3 users required for the subsequent operations
useradd -c "Gearge Jetson" -d /home/jetsong -s /bin/bash jetsong
useradd -c "Fred Flinstone" -d /home/flintstonef -s /bin/bash flintstonef
useradd -c "Johny Bravo" -d /home/bravoj -s /bin/bash bravoj
Note:
c – For adding a comment of full name
d – For adding a default home directory
s – Assigning a default shell
4. Assigning passwords to the users created above
passwd jetsong
passwd flintstonef
passwd bravoj
5. Forcing the user to change password on first login
chage -d 0 jetsong
chage -d 0 flintstonef
chage -d 0 bravoj
6. Setting the password expiry of each user to 60 days
chage -M 60 jetsong
chage -M 60 flinstonef
chage -M 60 bravoj
7. Setting the account to expire in 3 months for “bravoj” being a temporary employee.
chage -E "2020-09-21" bravoj
-------------------------------------------------------------------
Part -2:-
Remember to be logged in as root user. Issue the “su – root” or just “su” (in some flavours of Linux) command
8. Creating 2 new groups required for the subsequent operations
groupadd cartoons
groupadd entertainment
9. Creating a new folder “Cartoons” as root user and set the primary group to “cartoons”
mkdir Cartoons
chgrp cartoons Cartoons
10. Create a folder “Jetsons” owned by user “jetsons” and set the primary group to “cartoons” and full permission for jetsons and no permission for anyone else.
mkdir Jetsons
chown jetsong Jetsons/
chgrp cartoons Jetsons/
chmod 700 Jetsons/
11. Create a folder “Flintstonesf” owned by user “flintstonef” and set the primary group to “cartoons” and full permission for flintstonef and no permission for anyone else.
mkdir Flintstones
chown flintstonef Flintstones/
chgrp cartoons Flintstones/
chmod 700 Flintstones/
12. Create a folder “JohnyBravo” owned by user “bravoj” and set the primary group to “cartoons” and full permission for bravoj and no permission for anyone else.
mkdir JohnyBravo
chown bravoj JohnyBravo/
chgrp cartoons JohnyBravo/
chmod 700 JohnyBravo/
13. Create a folder “Shared” owned by user “root” and set the primary group to “entertainment” and full permission for root and full permission to primary group users and only read permission for everyone else including everything within (music & video folder)
mkdir Shared
chgrp entertainment Shared/
mkdir Shared/music
mkdir Shared/videos
For recursive file permission change issue the following command
chmod -R 774 Shared/
14. Create a symbolic link called “Shared” of the “Shared” directory inside every folder under “Cartoon” Directory
ln -s /Entertainment/Shared /Entertainment/Jetsons/
ln -s /Entertainment/Shared /Entertainment/Flintstones/
ln -s /Entertainment/Shared /Entertainment/JohnyBravo/
15. “Shows” and “Movies” directory should be owned by “root” and primary group set to “entertainment”
mkdir /Entertainment/Movies
mkdir /Entertainment/Shows
chgrp entertainment /Entertainment/Movies
chgrp entertainment /Entertainment/Shows
chmod 770 /Entertainment/Movies
chmod 770 /Entertainment/Shows
Question 1:
Log into the system as user jetsong and try accessing the folders inside /Entertainment/Cartoons
The users jetsong will only be allowed to enter the Jetsons directory which it owns
The rest of the directories when trying to enter will generate a permission denied message.
+ arun@ubuntu: -/Desktop arun@ubuntu:-/Desktop$ su jetsong Password: jetsong@ubuntu:/home/arun/Desktop$ cd /Entertainment/Car
The same is the case with every other user trying to access the directories not owned by them that is inside the Cartoons directory.
Question 2:
To change this you have two options .
Option 1
Folder permissions can be changed for either of Jetsons, Flintstones or JohnyBravo directories to allow access to users belonging to groups other than the group of the primary user (folder owner).
Let us consider the example scenario of user jetsong. First the users primary group needs to be changed to cartoons.
Next the file permissions of every directory inside /Entertainment/Cartoons including needs to be changed as follows
usermod -g cartoons jetsong
chmod -R 750 /Entertainment/Cartoons
The first command changes the primary group of jetsong to cartoons
The second command allows read, execute permission for users in cartoon group.
jetsong@ubuntu:/Entertainment/Cartoons $ exit exit arun@ubuntu:-/Desktop$ su jetsong Password: jetsong@ubuntu:/home/arun/Desk
Question 3.
New files & folder inside Shared folder should always have the primary group entertainment
cd /Entertainment/Shared
umask 002 # allow group write; everyone must do this
chgrp entertainment . # set directory group to GROUPNAME
chmod g+s . # files created in directory will be in group GROUPNAME
Question 4.
Users have to be in the entertainment group to write to the shared folder.
-------------------------------------------------------------------
Please give me a UPVOTE. Thank you :)