From d4c4463f708bd8b644b730ebbd95c24d096c9286 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Wed, 7 Aug 2024 18:03:14 +0200 Subject: [PATCH 1/4] embiggen links --- basics/hard_links.md | 38 +++++++++++++++++++++++ basics/links.md | 18 +++-------- basics/soft_links.md | 72 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 14 deletions(-) create mode 100644 basics/hard_links.md create mode 100644 basics/soft_links.md diff --git a/basics/hard_links.md b/basics/hard_links.md new file mode 100644 index 0000000..e34b084 --- /dev/null +++ b/basics/hard_links.md @@ -0,0 +1,38 @@ +--- +title: "hard links" +tags: [ "basics", "links" ] +--- + +A hard link is one file which exists in multiple locations. + +Each file has an ID, which is kept on the hard disk's partition. +Each hard link has the same ID, because they are the same file. +This ID is called the 'inode'. + +Create a file, and a hard link: + +```bash +fortune > $file_1 +mkdir -p x/y/z/ +ln $file_1 x/y/z/$file_2 +``` +Have a long look at the file with the `-l` flag, and check the inode with `-i`: + +```bash +ls -li $file_1 x/y/z/$file_2 +``` + +Since they are the same file, you can make a change to one, and it changes both: + +```bash +fortune | tee x/y/z/$file_2 +cat $file_1 +cat x/y/z/$file_2 +``` + +# Danger Zone + +- hard links will not work on directories, only standard files and fifos. +- `git` will destroy and remake files, so it will not respect hard links. +- Files cannot have a hard link on another disk partition, because the inode is stored on each partition. + diff --git a/basics/links.md b/basics/links.md index 3c5d028..733dc85 100644 --- a/basics/links.md +++ b/basics/links.md @@ -1,19 +1,9 @@ --- title: "links" -tags: [ "Documentation", "Basics" ] +tags: [ "basics", "links" ] --- -Link from X to Y. -```bash -ln -s X ../otherdir/Y -``` - -If you want a hard link, this will make a single file exist in two locations. -If it is deleted in one location, it continues to exist in the other. - -```bash -ln *X* *Y* -``` - -Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`). +There are two types: +- [Soft links](soft_links.md) +- [Hard links](hard_links.md) diff --git a/basics/soft_links.md b/basics/soft_links.md new file mode 100644 index 0000000..0af7d04 --- /dev/null +++ b/basics/soft_links.md @@ -0,0 +1,72 @@ +--- +title: "soft links" +tags: [ "basics", "links" ] +--- +A soft link is a file which says how to go to another file. +When a program encounters a soft link, it will make a guess at whether it should ignore it, or try to get to that file. + +To make a soft link to a file in the current directory, linking is easy: + +```bash +fortune > $file_1 +ln -s $file_1 $link_1 +``` + +Now imagine your directory looks like this: + +``` +dir_0/ +├── dir_1 +│   └── file_1 +├── dir_2 +│   └── file_1 +├── file_1 +└── link_1 + +``` + +Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file: + +```bash +cd dir_1 +ln -s ../file_1 link_1 +``` + +The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file: + +```bash +ln -s ../file_1 dir_2/link_2 +``` + +Both symlinks are identical, except for the name. + +``` +dir_0/ +├── dir_1 +│   ├── file_1 +│   └── link_1 <-- This one points to ../file_1 +├── dir_2 +│   ├── file_1 +│   └── link_2 <-- This one points to ../file_1 as well. +└── file_2 + +``` + +Since it's just an address, you can delete the original file, then make another. + +```bash +rm file_1 +ls -l dir_1/ +fortune > file_1 +cat dir_2/link_2 +fortune | tee -a file_1 +cat dir_1/link_1 +``` + +Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link): + +```bash +ln -s -f ../dir_1/file_1 dir_2/link_2 +cat dir_2/link_2 +``` + From 377a85c2b0add3e97cdf6f75439cb3f25550fbf4 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Wed, 7 Aug 2024 18:03:53 +0200 Subject: [PATCH 2/4] deduplicate with rdfind --- system/deduplicate.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 system/deduplicate.md diff --git a/system/deduplicate.md b/system/deduplicate.md new file mode 100644 index 0000000..b9fbbac --- /dev/null +++ b/system/deduplicate.md @@ -0,0 +1,19 @@ +--- +title: "deduplicate" +tags: [ "system", "deduplicate", "duplicates", "maintenance" ] +--- + +`rdfind`: find duplicate files, then delete them, or turn them into links. + +Ask if a directory has duplicates (`rdfind` will not delete anything): + +```bash +rdfind $dir +$EDITOR results.txt +``` + +Replace the duplicated files with [hard links](../basics/hard_links.md). + +```bash +rdfind -makehardlinks true $dir +``` From b5123a0d012e24b93ff3175fabbaa3b5671311de Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Sun, 11 Aug 2024 23:38:03 +0200 Subject: [PATCH 3/4] note force-reset with ntpd --- basics/time.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/basics/time.md b/basics/time.md index a69a4fe..f99bf89 100644 --- a/basics/time.md +++ b/basics/time.md @@ -68,3 +68,11 @@ ntpq -p Usually this is run as a service, so just start that service. +# Force Reset + +If your clock drifts too far from the right time, it will not reset happily. +For it to reset like this: + +```bash +sudo ntpd -q -g -x -n +``` From 31f12e2161f52cab4e4c206de35a2c8f043c5112 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Tue, 13 Aug 2024 18:58:50 +0200 Subject: [PATCH 4/4] note how to erase pdf metadata --- system/exiftool => data/exiftool.md | 2 ++ data/pdf_erasure.md | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) rename system/exiftool => data/exiftool.md (83%) create mode 100644 data/pdf_erasure.md diff --git a/system/exiftool b/data/exiftool.md similarity index 83% rename from system/exiftool rename to data/exiftool.md index 520b21e..86cb6bf 100644 --- a/system/exiftool +++ b/data/exiftool.md @@ -22,6 +22,7 @@ And overwrite all metadata: ```bash exiftool -all= -overwrite_original -ext jpg . ``` +(NB: This does not work on pdf data. See [here](pdf_erasure.md) for erasing all pdf data) Or just GPS data: @@ -36,3 +37,4 @@ identify -verbose ``` + diff --git a/data/pdf_erasure.md b/data/pdf_erasure.md new file mode 100644 index 0000000..2f3947d --- /dev/null +++ b/data/pdf_erasure.md @@ -0,0 +1,25 @@ +--- +title: "PDF Metadata Erasure" +tags: [ "Documentation", "Metadata", "Ghost Script" ] +--- + +Make a text file called 'pdfmark.txt'. + + +```text +[ /Title () +/Author () +/Subject () +/Creator () +/ModDate () +/Producer () +/Keywords () +/CreationDate () +/DOCINFO pdfmark +``` + +Then run: + +```bash +gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt +```