Merge branch 'master' into vhs
This commit is contained in:
		
							
								
								
									
										38
									
								
								basics/hard_links.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								basics/hard_links.md
									
									
									
									
									
										Normal file
									
								
							| @@ -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. | ||||
|  | ||||
| @@ -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) | ||||
|   | ||||
							
								
								
									
										72
									
								
								basics/soft_links.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								basics/soft_links.md
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| ``` | ||||
|  | ||||
| @@ -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 | ||||
| ``` | ||||
|   | ||||
| @@ -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 | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
							
								
								
									
										25
									
								
								data/pdf_erasure.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								data/pdf_erasure.md
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| ``` | ||||
							
								
								
									
										19
									
								
								system/deduplicate.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								system/deduplicate.md
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| ``` | ||||
		Reference in New Issue
	
	Block a user