Is there a way to give any file a customized "ID card", so that I can identify its source, or record anything that I want. But at the same time, firstly, do not modify the file content, because some of files are encryped. Secondly, I also donot want to create another file to record the customized info, becasue I want this attribute can "come and go" with the file.
I`ve found a method implemented with SELinux: https://wiki.gentoo.org/wiki/SELinux/Labels However, I am not very familiar with linux file system and I think SELinux is a security control software that is not accessable easily.
I think there must be a way to easily tag or label a file in Linux. Just like in Window system, you can give a file custom attributes.
You can use file attributes to assign custom metadata or tags to a file using Extended File Attributes (xattr). This doesn't modify the file's content.
-Seting a custom attribute:
setfattr -n user.customattribute -v "your_value" /your/file/path
"your_value" is the value you want to assign to the attribute.
-Retrieving the custom attribute:
getfattr -n user.customattribute /path/to/file
This displays the value of the custom attribute.