Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i want to save notes against a file on linux... i want to save meta data about a file..because the file names are restricted in max length...

so how to save notes or comments about a file on linux so that it gets saved along with the file itself...

i used the notes tab in the file properties dialogbox.. but that way the notes stick to the file only on that OS only.. if i open that file in another linux os.. those comments/notes are gone...

please suggest me a way to embedd these notes into the file so that i dont lose them ever..

at lease a solution that makes this possible on switching linux distros. if its not portable enough that these notes stick b/w windows and linux its ok for me.. but atleast if i format my linux os.. atleast i shouldnt lose those important notes..and be able to access on newer linux..

and i also have no idea if this notes tab was implemented to be linked with the OS only.. i dont see much use of it.. and a normal user also has noway to know this.. i also came to know on superuser chat from a buddy.. @Sathya .. this thing is more useless especially if u use ubuntu which has 6 months timeline..and crazy people like me who are always eager to upgrade their os as soon a new one is available..

and any way i can search these notes from the terminal?? that would be awsome too..

kindly help.. Thanks.

share|improve this question
add comment

3 Answers

Linux filesystems support a feature called extended file attributes or "xattr".

You have to mount the filesystem with the user_xattr mount option, and if you do then any application that has the right to read/write the file can also read/write a bunch of metadata to it, including 'user' attributes with any name and value, though few applications will use them as they are not common.

The attr command can read and edit them - here's a bit of a tutorial. Don't know which GUI apps (nautilus?) will let you view or edit them though. Applications like beagle are aware of them, so you should be able to use that to search through them.

Note that if you copy the file between filesystems, not only do both filesystems need to be mounted with the user_xattr mount option, but the application doing the copying needs to be told to preserve them.

For cp, use:

--preserve=xattr

(-a won't do it).

For rsync, use:

--xattrs

(or -X).

It's not exactly something that everyone's doing.

share|improve this answer
add comment

How about saving the notes in a free-form text file with a special extension along with the file?

I usually save 'exif' files along with a 'jpg' or 'raw' which starts with the basic EXIF information and can have additional notes.

1. File picture.jpg
2. jhead picture.jpg > picture.exif
3. vim picture.exif # Add annotations, notes, checksum, et al
4. Keep the jpg and exif files together

Of course, there will be other formats which handle meta data which would be more easy to handle. But, there is not much that will beat the portability and flexibility of this meta-file scheme.

share|improve this answer
add comment

Normal textfiles don't support this, but you can create your own "filetype" in the same way as OpenOffice did. The OpenOffice filetypes is more or less a zip file with a lot of small files inside that file.

So you can have your origianal file, and a file with meta, and then zip them together and there you have your "new file with meta".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.