setfacl
Demea is a Master Linux Sysadmin at Red Hat. She has a multi-part task in from of her.
- Angela Davis is a new Red Hat employee. She needs an account on the main RHEL server with this username angela.y.davis@redhat.com.
- Angela's shell should be /bin/zsh and her custom home directory should be /home/angelad. He Gecos field should be "Angela Y. Davis - Engineering Dept.".
- Demea must create a new file outside of Angela Home Directory in /home/new_employees/new_employees_log.txt and create a new group called new_employees, and give it read-write access to the file.
- Demea must then make Angela a part of that group.
- Finally Demea must create a new file in /home/angelad called angelas_notes.txt and copy the ACL from new_employees_log.txt to angelas_notes.txt using getfacl and setfacl.
Please list all of the commands that Demea must run. Note: Demea is a highly seasoned Linux Sysdamin, so she NEVER runs commands as root.
Sure, here are the commands that Demea can run to complete the multi-part task:
- Create a new user account for Angela Davis:
- sudo useradd -m -s /bin/zsh -d /home/angelad -c "Angela Y. Davis - Engineering Dept." angela.y.davis@redhat.com
- This command creates a new user account with the specified shell, custom home directory, and GECOS field.
- Create a new file outside of Angela's home directory and give the new_employees group read-write access to it:
- sudo touch /home/new_employees/new_employees_log.txt
sudo chgrp new_employees /home/new_employees/new_employees_log.txt
sudo chmod g+rw /home/new_employees/new_employees_log.txt - These commands create a new file and change its group ownership to
new_employees
. Then, they add read and write permissions to thenew_employees
group.
- sudo touch /home/new_employees/new_employees_log.txt
- Add Angela Davis to the new_employees group:
- sudo usermod -a -G new_employees angela.y.davis@redhat.com
- This command adds Angela Davis to the
new_employees
group.
- Create a new file in Angela Davis's home directory and copy the ACL from new_employees_log.txt to angelas_notes.txt:
- sudo touch /home/angelad/angelas_notes.txt
sudo getfacl /home/new_employees/new_employees_log.txt | sudo setfacl --set-file=- /home/angelad/angelas_notes.txt
- sudo touch /home/angelad/angelas_notes.txt
These commands create a new file in Angela Davis's home directory, and then use getfacl
to obtain the ACL from new_employees_log.txt
, and then setfacl
to copy the ACL to angelas_notes.txt
.
After running these commands, Angela Davis should have a new user account with the specified shell and home directory. She should also have read-write access to the file /home/new_employees/new_employees_log.txt
, along with any other users in the new_employees
group. Finally, Angela Davis should have a new file in her home directory called angelas_notes.txt
with the same ACL as new_employees_log.txt
.