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:
- Using your preferred text editor, create the perm_demo.txt file with a line of text.
- View the extended attributes of the file:
lsattr perm_demo.txt
- Add the a attribute:
sudo chattr +a perm_demo.txt
lsattr perm_demo.txt
- 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
- Now, append something to the file:
echo "I want to append this line to the end of the file." >> perm_demo.txt
- 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
- Repeat Step 4.
- 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
- 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!