Practical Exercise: Managing User Home Directories and Permissions
Scenario:
You are a system administrator responsible for setting up user accounts on a Linux server. A new developer, Bob, has joined the team, and you need to create his user account, set up his home directory, and configure appropriate permissions.
Steps:
- Create Bob’s User Account:
- Use the
adduser
command to create Bob’s user account.
sudo adduser bob
- Set a password for Bob when prompted.
- Use the
- Verify Bob’s Home Directory:
- Confirm that Bob’s home directory has been created under
/home
or the designated home directory location on your system.
ls /home
- Confirm that Bob’s home directory has been created under
- Inspect Default Permissions:
- Use the
ls -l
command to view the permissions of Bob’s home directory and its contents.
ls -l /home/bob
- Note the default permissions set by the system.
- Use the
- Customize Bob’s
.bashrc
:- Switch to Bob’s account.
su - bob
- Edit Bob’s
.bashrc
file to add a custom alias. For example, create an alias for a development command:
echo "alias deploy='./deploy_script.sh'" >> ~/.bashrc
- Save and exit the text editor.
- Set Default Permissions for New Files:
- Check Bob’s current
umask
setting to see the default file permissions.
umask
- If needed, modify Bob’s
umask
to adjust default permissions.
- Check Bob’s current
- Test the Customization:
- Log out of Bob’s account:
exit
- Log back in as Bob and test the newly created alias:
deploy
- This command should execute the deployment script.
- Verify Permissions:
- Check the permissions of the files and directories in Bob’s home directory to ensure they reflect the customizations made.
ls -l /home/bob
- Bonus: Implement ACLs (Optional)
- If your system supports Access Control Lists (ACLs), you can explore setting specific permissions for Bob’s files or directories.
Conclusion:
In this exercise, you have successfully created a new user account for Bob, customized his .bashrc
to include a custom alias, and set default permissions. This exercise demonstrates how system administrators can tailor user environments to suit specific needs while maintaining security and privacy.