Hands-on lab – setting security-related extended file attributes

For this lab, you'll need to create a perm_demo.txt file with some text of your choice. You'll set the i and a attributes and view the results. Let's get started:

  1. Using your preferred text editor, create the perm_demo.txt file with a line of text.
  2. View the extended attributes of the file:
lsattr perm_demo.txt
  1. Add the a attribute:
sudo chattr +a perm_demo.txt
lsattr perm_demo.txt
  1. Try to overwrite and delete the file:
echo "I want to overwrite this file." > perm_demo.txt
sudo echo "I want to overwrite this file." > perm_demo.txt
rm perm_demo.txt
sudo rm perm_demo.txt
  1. Now, append something to the file:
echo "I want to append this line to the end of the file." >> perm_demo.txt
  1. Remove the a attribute and add the i attribute:
sudo chattr -a perm_demo.txt
lsattr perm_demo.txt
sudo chattr +i perm_demo.txt
lsattr perm_demo.txt
  1. Repeat Step 4.
  2. Additionally, try to change the filename and create a hard link to the file:
mv perm_demo.txt some_file.txt
sudo mv perm_demo.txt some_file.txt
ln ~/perm_demo.txt ~/some_file.txt
sudo ln ~/perm_demo.txt ~/some_file.txt
  1. Now, try to create a symbolic link to the file:
ln -s ~/perm_demo.txt ~/some_file.txt
Note that the i attribute won't let you create hard links to a file, but it will let you create symbolic links.

That's the end of the lab – congratulations!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.56.45