As the system administrator, you have received a memo saying
that Leslie, Ronsam, Xochi, and Sara have been assigned to a work
group to do some analysis and they need to work on your Linux
system. You need to add these folks as regular users and give them
an alternate group that they can switch into. You also need to set
up a common folder for them to work in. Your plan is to create a
new group called ‘analysis’ and you will create a
folder off the root folder called
/analysis_work
Execute the following commands to effect this new set-up:
First, add the users and set their passwords(just use the uid for
the password):
useradd leslie ; passwd leslie
useradd ronsam ; passwd ronsam
useradd xochi ; passwd xochi
useradd sara ; passwd sara
Now, add the common group for the new users
groupadd -g 234 analysis
Next, add the folder for them all to work in, set the permissions
and change the group on the folder to ‘analysis’
mkdir /analysis_work
chmod 670 /analysis_work
chown root:analysis /analysis_work
Finally, modify the new user accounts so they can switch out of
their primary group into the work group
usermod -G analysis leslie
usermod -G analysis ronsam
usermod -G analysis xochi
usermod -G analysis sara
Test the system with the following:
su - leslie
newgrp analysis
cd /analysis_work
touch tmp.file
chmod g+w tmp.file
su - ronsam
newgrp analysis
cd /analysis_work
vi tmp.file
As user ‘ronsm’, you should be able to change (write) the file that
‘leslie’ created
Were you able to change the file using ‘vi’?____________
Ans - No, you can't edit the tmp.file in ronsam user as the file is created by leslie.
Explanation:
We hav given chmod 670 /analysis_work ,chown root:analysis /analysis_work - It means all user having group name analysis can access the directory but not all the files created in that directory. When any user creates a file in that directory it will create a file with his own group name and file permission will be based on UMASK value.
exp:
$ whoami
leslie
$ pwd
/analysis_work
$ mkdir tmp.file
$ ls -ltr
-rw-rwx--- 1 leslie leslie 48 Oct 28 17:31
tmp.file
here you can see the owner is lensle and group is leslie so if you login with different user id with same group id of leslie then you will not be able to edit the file as the group of the file is leslie.
How to Change the File Group Ownership:
$ chgrp analysis tmp.file
$ ls -ltr
total 1
-rw-rw-r-- 1 leslie analysis 0 Oct 28 17:49
tmp.file
In this case other user belongs to analysis group able to edit the file.
Get Answers For Free
Most questions answered within 1 hours.