From 75df3febf607c5fbf7503acb34a10e66514ccb09 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Wed, 26 Jul 2023 23:50:16 +0200 Subject: [PATCH] feat: tagging in linux --- .vscode/settings.json | 2 ++ knowledge base/linux/getfattr.md | 39 ++++++++++++++++++++++++++++ knowledge base/linux/setfattr.md | 42 +++++++++++++++++++++++++++++++ knowledge base/linux/tag files.md | 22 ++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 knowledge base/linux/getfattr.md create mode 100644 knowledge base/linux/setfattr.md create mode 100644 knowledge base/linux/tag files.md diff --git a/.vscode/settings.json b/.vscode/settings.json index bf07811..13b88b9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,6 +42,7 @@ "freshclam", "gcloud", "getfacl", + "getfattr", "gettext", "gopass", "gpgconf", @@ -96,6 +97,7 @@ "runcmd", "scrollback", "setfacl", + "setfattr", "slurm", "sshfs", "sshpass", diff --git a/knowledge base/linux/getfattr.md b/knowledge base/linux/getfattr.md new file mode 100644 index 0000000..457e15b --- /dev/null +++ b/knowledge base/linux/getfattr.md @@ -0,0 +1,39 @@ +# `getfattr` + +## Table of contents + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) +1. [Sources](#sources) + +## TL;DR + +```sh +# Get values for specific extended attributes. +getfattr -n 'name' 'path/to/file.1' … 'path/to/file.N' +``` + +## Further readings + +- [`setfattr`][setfattr] + +## Sources + +All the references in the [further readings] section, plus the following: + +- [`man` page][man page] +- [Tag files in GNU/Linux] + + + + +[further readings]: #further-readings + + +[setfattr]: setfattr.md +[tag files in gnu/linux]: tag%20files.md + + +[man page]: https://linux.die.net/man/1/getfattr diff --git a/knowledge base/linux/setfattr.md b/knowledge base/linux/setfattr.md new file mode 100644 index 0000000..ba86c52 --- /dev/null +++ b/knowledge base/linux/setfattr.md @@ -0,0 +1,42 @@ +# `setfattr` + +## Table of contents + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) +1. [Sources](#sources) + +## TL;DR + +```sh +# Add extended attributes. +setfattr -n 'name' -v 'value' 'path/to/file.1' … 'path/to/file.N' + +# Remove extended attributes. +setfattr -x 'name' 'path/to/file.1' … 'path/to/file.N' +``` + +## Further readings + +- [`getfattr`][getfattr] + +## Sources + +All the references in the [further readings] section, plus the following: + +- [`man` page][man page] +- [Tag files in GNU/Linux] + + + + +[further readings]: #further-readings + + +[getfattr]: getfattr.md +[tag files in gnu/linux]: tag%20files.md + + +[man page]: https://linux.die.net/man/1/setfattr diff --git a/knowledge base/linux/tag files.md b/knowledge base/linux/tag files.md new file mode 100644 index 0000000..495240b --- /dev/null +++ b/knowledge base/linux/tag files.md @@ -0,0 +1,22 @@ +# Tag files in GNU/Linux + +The more native way is to use extended attributes.
+This allows to store the information within the file in its "filesystem entry", and it stays with the file when one moves it on the drive. + +Query them with [`getfattr`][getfattr].
+Set, modify and remove them using [`setfattr`][setfattr]. + +## Sources + +- [How to tag any file on the Unix system?] + + + + +[getfattr]: getfattr.md +[setfattr]: setfattr.md + + +[how to tag any file on the unix system?]: https://unix.stackexchange.com/questions/683017/how-to-tag-any-file-on-the-unix-system