How would I accomplish the following in Linux using the BTRFS filesystem?

In Mac OS X El Capitan you can use tags to organize files. You can tag files and folders to make them easier to find. Tags work with all files and folders. You can add multiple tags to any file (or folder?).


Of course, the purpose of these tags is for finding / searching by tag. Mac OS X Finder includes support for tags.

In Linux, it's OK if I have to use command line tools to accomplish tagging and search by tags (and related functions).

  • Are you looking for 3rd party tools to accomplish this or are you only interested in a (possibly non-existent) native-to-the-filesystem solution?
    – B Layer
    Aug 24, 2017 at 12:51
  • Any solution is of interest. I just learned that KDE Baloo might do this, and that would be of interest to me.
    – MountainX
    Aug 24, 2017 at 19:32

3 Answers 3


A possibility might be to use extended attributes, see xattr(7) for an introduction.

(But I believe they are not widely used today; on Debian and related distributions you need to install the xattr package then use the xattr command)


As far as simple file tagging goes the fundamental question is where/how the tags are stored? If the file system doesn't have native support for tagging of heterogeneous file types two common (though far from ideal) approaches you'll find are filename embedding and sidecars. The former means that your tags are actually inserted into the filename, e.g. foo.txt becomes foo-[tag1,tag2].txt. The latter, sidecar, means the tags are stored in a file located in the same directory, or a common subdirectory, as the file to be tagged. For example foo.txt might be accompanied by .foo.txt.tags.

Neither of those sound too appealing do they? Embedding strikes me as plain ugly but at least you don't have to worry about how to keep your tags with a file if you move or delete it as is the case with sidecars.

But apparently these tradeoffs are acceptable to some people and there are some satisfied customers of offerings like...

I've heard some positive things about an open-source, cross-platform solution called TagSpaces. This uses the embedded approach by default but there is an Enterpri$e version with support for sidecars. The feature set is appealing and the UI looks nice as well as easy to use. There also look to be APIs if you want to integrate with other clients or create your own (e.g. CLI). And there's something to be said about the cross-platform aspect if you like to keep your files on more than one platform.

For this and other similar solutions it all comes down to whether you can live with the...let's face it...kinda hacky tag persistence details! :)

Edit: Here's some info from someone who uses embedded tags: Adding tags to files (PDFs) and process from the command-line or script The rest of the thread may be of interest, too.


The simplest way is to create a tags/ directory and in there make directories for each tag. Then link (hard links are probably best) your file into the tag directory to assign it that tag. One thing you have to deal with though is files with the same name, so adding a digest number to the filename would probably be necessary. Only downside to this approach (other then lack of tooling to make easier to use) is that after about 10,000 files per directory performance become an issue.

  • I like this answer and I am tempted to accept it. However, since I use KDE and Dolpin now supports tags (via xattr), that is the solution I chose.
    – MountainX
    May 25 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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