Compare commits

...

57 Commits

Author SHA1 Message Date
6d00283fe2 cmd: show test in journal vacuum 2026-05-01 14:21:48 +02:00
a2c3521c48 add stopping email scams 2026-05-01 13:13:48 +02:00
0a824f10c8 cmd: rephrase text for shell formatting 2026-04-30 20:12:59 +02:00
8bb26740b0 edit users and groups directly 2026-04-30 15:33:23 +02:00
0d053e9a7d cmd: return terminal after ssh freeze 2026-04-30 13:06:14 +02:00
ec3c355ac4 remove necessity to recompile command-lists 2026-04-30 13:03:31 +02:00
2a010a777e make vim links absolute 2026-04-30 00:53:34 +02:00
12064196d2 fix variable syntax 2026-04-30 00:50:02 +02:00
68734cfd1b include markdown as a variable 2026-04-29 17:42:11 +02:00
019736de05 place template makefile 2026-04-29 17:39:37 +02:00
76be2fbd3c fix links 2026-04-29 14:35:17 +02:00
34ef924a09 typo 2026-04-29 12:49:32 +02:00
793d32164e rename pdf to text 2026-04-28 23:56:37 +02:00
39a7317cc5 note: retitle gpg with vim 2026-04-28 19:58:46 +02:00
c06884d434 note: csv to markdown in vim 2026-04-28 18:11:54 +02:00
c25f55054b note: format markdown in vim 2026-04-28 18:01:52 +02:00
73f8dc0feb reformat tables 2026-04-28 17:40:08 +02:00
a4ffedcb6b note: place arch gpu required tags 2026-04-28 13:23:25 +02:00
b27ccb33ab note: how to send email 2026-04-28 02:10:39 +02:00
95b753549b note useage in lowdown.mk example 2026-04-27 17:20:35 +02:00
c586062552 git commit -p 2026-04-27 17:12:52 +02:00
0d25236b27 reword column examples 2026-04-27 17:12:29 +02:00
d53ca311c1 split shell tips into bash and shell 2026-04-27 17:08:41 +02:00
3a7a92de14 edit editors 2026-04-27 15:21:14 +02:00
53eba915b3 explain shell-like writing in readme 2026-04-27 13:35:27 +02:00
6a33521f33 edit shell tips 2026-04-27 13:35:22 +02:00
319ae8df79 clean up old formatting 2026-04-27 13:13:22 +02:00
ea4f44e096 clean up networking 2026-04-27 12:59:27 +02:00
1994d9fbb3 move git cleanup 2026-04-27 12:41:06 +02:00
cc811fc025 edit virtualization setup 2026-04-27 12:34:26 +02:00
c2f72aed84 only ignore db.rec 2026-04-27 12:26:43 +02:00
2e305b3604 clean up cmd tags 2026-04-27 12:02:33 +02:00
b2ded0008c cmd: git request-pull 2026-04-27 12:01:22 +02:00
49e7930541 REBIRTH 2026-04-27 01:30:33 +02:00
9e29b8b096 split setup note 2026-04-21 04:56:49 +02:00
e24b5ffb5d rewrite calcurse imports 2026-04-20 21:32:02 +02:00
fb96f1bd78 make header format yaml 2026-04-20 11:24:45 +02:00
0bd5b53092 metadata touchups 2026-04-20 09:40:23 +02:00
86abe415ad article: Read and scroll 2026-04-20 07:08:32 +02:00
79e150d3df remove old mpd notes 2026-04-20 06:12:09 +02:00
9b933bb58a more cleanup 2026-04-20 06:09:58 +02:00
9b4494b4fd remove taskwarrior 2026-04-20 05:44:36 +02:00
4ced7c9fa0 sc-im example file to example.rec 2026-04-20 05:43:26 +02:00
24efbfeb3b data cleanup 2026-04-20 05:34:14 +02:00
7eb1b16b70 profanity split 2026-04-20 05:34:01 +02:00
4a352f89ef git cleanup 2026-04-20 05:33:50 +02:00
c8acd558a6 make requirements key the filename 2026-04-20 04:28:44 +02:00
af774dcd83 formatting 2026-04-20 04:05:25 +02:00
9b5a261096 name file key 'path' 2026-04-20 03:06:20 +02:00
2ed9dc7221 recset verbosely 2026-04-20 03:03:44 +02:00
bca5337ac3 modify basic filestructure
It's unclear what's 'basic', so `basic/` notes have been mostly moved.
The remainder became `shell/`.
2026-04-20 02:42:41 +02:00
c95176c7a9 add cdpath 2026-04-19 23:48:30 +02:00
8fcc8c67bf note slow terminal in ed 2026-04-19 01:47:14 +02:00
cfb1177928 make vim remote editing a command 2026-04-18 22:30:34 +02:00
da3bc11189 show shell in commands 2026-04-18 22:28:37 +02:00
9d0c46eb32 reorganize soft-serve 2026-04-18 05:21:25 +02:00
bfcd3c6b62 split gpg notes 2026-04-18 05:10:54 +02:00
213 changed files with 2943 additions and 2888 deletions

3
.gitignore vendored
View File

@@ -1,3 +0,0 @@
*.pdf
*.gif
*.jpeg

122
Makefile
View File

@@ -1,13 +1,18 @@
MAKEFLAGS += -j
MAKEFLAGS += -s
EDITOR ?= vi
FZF != command -v sk || command -v fzy || command -v fzf || \
{ echo install a fuzzy finder && exit 1 ;}
PAGER ?= less -Ri
READER != command -v mdless bat glow less more pg | head -1
FZF != command -v fzf sk | head -1
markdown = $(wildcard */*.md */*/*.md)
ifeq "$(FZF)" ""
$(info Install fzf)
endif
ifeq "$(FZF)" "/usr/bin/fzy"
FZF += -i
else
FZF += --print-query | tail -1
endif
spill_contents = sed -e '1,/---/d'
@@ -19,18 +24,9 @@ help: ## Print the help message
articles != find * -type f -name "*.md"
dirs != ls -d */
categories = $(patsubst %/, %, $(dirs))
databases = $(patsubst %, .dbs/%.rec, $(categories))
default += $(databases)
default += db.rec
default += .dbs/notes.rec
default += .dbs/map.fmt
$(foreach dir, $(categories), \
$(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \
)
%/:
mkdir $@
@@ -38,37 +34,51 @@ $(foreach dir, $(categories), \
include cmd.mk
$(databases): .dbs/%.rec: %/ | .dbs/
$(info making $(@F))
for entry in $(shell find $< -type f -name "*.md") ; do \
printf "file: %s\n" "$$entry" ;\
sed -n '2,/^---$$/ {/^---$$/d; p}' "$$entry" |\
tr -d '[]' | tr -s ' ' |\
sed '/tags: /s/, /\ntag: /g ; s/tags:/tag:/ ; /requires/s/, /\nrequires: /g' ;\
printf "wordcount: %s\n\n" "$$(wc -w < $$entry)" ;\
done > $@
# This two-variable read can only happen because of the quotes in the titles.
db.rec: $(databases)
$(info rebuilding from $? )
.dbs/head.rec: | .dbs/
printf '%s\n' '%rec: guide' > $@
printf '%s\n' '%key: title' >> $@
printf '%s\n' '%key: path' >> $@
printf '%s\n' '%type: requires rec guide' >> $@
printf '%s\n' '%type: provides rec guide' >> $@
printf '%s\n' '%type: wordcount int' >> $@
printf '%s\n\n' '%sort: wordcount' >> $@
cat $^ >> $@
recsel $@ -e "requires != ''" -CR title,requires |\
while read title requires; do \
for provider in "$$requires" ; do \
recset $@ -e "title = '$${provider}'" -f provides -a "$${title}" ;\
done ;\
done
sed -i 's/"//g' $@
recfix --sort $@
$(info Created main database: $@)
.git/info/exclude: $(default)
.dbs/new.rec: $(markdown) | .dbs/head.rec
$(info Updating: $?)
grep -q guide $@ 2>/dev/null || cp $| $@
@-$(foreach entry, $?, \
recdel -t guide $@ -e "path = '$(entry)'" 2>/dev/null ;\
)
for entry in $? ; do \
echo '' ;\
printf "path: %s\n" "$$entry" ;\
sed -n '2,/^---$$/ {/^---$$/d; p}' "$$entry" |\
while read -r line; do if [ -z "$${line#*:}" ] ; then type="$$line"; else echo "$$line" | sed -r "s/- (.*)/$$type \1/" | sed s'/tags: /tag: /' ; fi ; done ;\
printf "wordcount: %s\n" "$$(wc -w < $$entry)" ;\
echo 'cmd: ' ;\
sed '1,/^---$$/d' $$entry | sed 's/^.*/+ &/' ;\
echo '' ;\
done >> $@
.dbs/requires.rec: .dbs/new.rec
recinf -d $< > $@
echo "" >> $@
recsel $< -t guide -j requires -G requires -p 'path,title,tag,wordcount,requires_path:requires,requires_requires:requires,cmd' >> $@
.dbs/notes.rec: .dbs/requires.rec .dbs/new.rec
recinf -d $< > $@
echo '' >> $@
sed '/^%/d' $^ | recsel -G path | recsel -U >> $@
default += db.rec
ignored += db.rec
db.rec: command.rec .dbs/notes.rec
recinf -d $< > $@
echo '' >> $@
sed '/^%/d' $^ | recsel -U -p 'title:aim,aim,cmd,note,shell,tag,bin:tag' >> $@
$(info Making main database: $@)
.git/info/exclude: $(ignored)
@echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude
@@ -77,38 +87,40 @@ default += .git/info/exclude
database: $(default) ## Make a recfiles database
.dbs/map.fmt:| .dbs/
printf '%s\n' '[ {{requires[0]}} ] --> [ {{title}} ] {border-style: dashed;}' > $@
printf '%s\n' '[ {{requires[1]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[2]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[3]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[4]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[0]}} ] --> [ {{path}} ] {border-style: dashed;}' > $@
printf '%s\n' '[ {{requires[1]}} ] --> [ {{path}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[2]}} ] --> [ {{path}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[3]}} ] --> [ {{path}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[4]}} ] --> [ {{path}} ] {border-style: dashed;}' >> $@
.PHONY: map
map: db.rec .dbs/map.fmt ## Show knowledge dependency map
recsel -t guide $< -e 'requires != ""' -p title,requires | recfmt -f .dbs/map.fmt |\
grep -vF '[ ]' | graph-easy --boxart | $${PAGER}
map: .dbs/requires.rec .dbs/map.fmt ## Show knowledge dependency map
recsel -t guide $< -e 'requires != ""' -p path,requires | recfmt -f .dbs/map.fmt |\
grep -vF '[ ]' | graph-easy --boxart 2>/dev/null | ${PAGER} -S
.PHONY: clean
clean: ## Remove all generated files
$(RM) $(default)
$(RM) -r $(default) .dbs/
.PHONY: article
article: **/ **/**/ ## Write a new article
category=$(shell echo $^ | tr ' ' '\n' | $(FZF) ) \
article: */ */*/ ## Write a new article
category=$(shell echo $^ | tr ' ' '\n' | $(FZF) --print-query | tail -1 ) \
&& read -p "Article title? " name \
&& filename="$$(echo "$$name" \
| cut -d: -f1 \
| tr -cd '[:alpha:]' | tr '[A-Z ]' '[a-z_]' )" \
| tr '[A-Z ]' '[a-z_]' | tr -cd '[:alpha:]_' )" \
&& $(MAKE) -e TITLE="$$name" "$$category"/"$$filename.md"
.PHONY: all
all: $(default) ## All file targets
%.md:
[ -d "$(@D)" ] || mkdir $(@D)
printf '%s\n' '---' >> $@
printf 'title: %s\n' '$(TITLE)' >> $@
tags="$$(echo $(@D) | sed 's#/$$#"# ; s#/#", "#g ; s#^#"#' )" \
&& printf 'tags [ %s ]\n' "$$tags" >> $@
printf "tags: " >> $@
echo $(@D) | sed 's#\b\w#\n- &#g; s/\///g' >> $@
printf '%s\n\n' '---' >> $@
$(EDITOR) +5 $@
git add $@
git commit -m"article: $(TITLE)"

145
README.md
View File

@@ -1,61 +1,98 @@
---
title: "Linux Knowledge Base"
---
# Linux Knowledge Base
The Linux Knowledge-Base provides quick-start guides for working with terminal programs.
These notes Linux programs have grown into a searchable knowledge base.
If you like this style of short articles with a miniature database, then join me in my quest to remove the nausea of poorly-written documentation.
# Usage
# Setup
## Setup
Install `make`, `recutils`, and any fuzzy-finder (i.e. `sk`, `fzy`, or `fzf`).
Install `make`, `recutils`, and any a fuzzy-finder (like `fzf` or `sk`).
## Usage
To find the options, run `make`.
## Queries
The fuzzy finder opens an interactive menu to find information.
There are two types of notes:
1. Short commands, catalogued by aim (in `command.rec`).
1. Short notes, mostly on getting set up with something (in the markdown files).
### Short Commands
Running `make check` will start a search of the snippets, ordered by what you
want to do, not by the name of the binary:
```
Hard reset ntp service
-> Quickly find and open run-command files
Turn markdown into a man page
Rotate a video
Translate a media file to a new type
```
The output is a couple of lines of code, with changeable components as variables:
```
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
```
### The Function
Running `make function` outputs a shell function which searches through this
knowledge base, so you don't have to `cd` to use it.
Set up the database and try a few queries:
```sh
make
make database
lk(){
/usr/bin/mdless "$(recsel ${your-path-here}/lk/db.rec \
-q "$(recsel ${your-path-here}/lk/db.rec -CP title,tag \
| sort -u \
| /usr/bin/fzf )" -CP path \
| fzf --sync -1 --preview='less -iR {}' )"
}
```
recsel db.rec -m 3
recsel db.rec -q database
recsel db.rec -e "title = 'ssh'"
recsel db.rec -e "title ~ 'ssh'"
recsel db.rec -e "title ~ 'bash'" -R title,wordcount
Add the function to your bash shell like this:
recsel db.rec -t guide -j provides -G title \
-e "title = 'ssh'" \
-p 'sum(provides_wordcount)'
```bash
make function
make function >> ~/.bashrc
exec bash
lk
```
# Style
## No History, No Context
- Nobody cares about how the project started.
- Nobody wants to read what `ffmpeg` is, because anyone who wants to use it already knows what it is.
## State Knowledge Dependencies
Articles should state what you need to understand in order to read them *at the start*.
They should not assume the reader knows much beyond common terminal commands, and should not provide a link to some other resource half-way through an article.
Articles should never link to other resources part-way through.
If the article assumes an understanding of GPG keys, then it should say that at the top.
People should be able to read documentation from the beginning, then keep going until the end, and then stop.
Setup guides should not send the reader on a detour through labyrinths of links.
People should be able to read an article from the beginning, then keep going until the end, and then stop.
Articles should not take a detour through a chain of other articles of unknown size.
## No History, No Context
[Do not Jaquays documentation](https://splint.rs/posts/no_links)
Anyone who wants to read how to use OTP with GPG already knows what those words mean, so guides should not spend time explaining.
Anyone who doesn't know what GPG keys are can find the link to using them, which explains them better than using door-blocking devices as a metaphor for prime number factorization.
## Index by Purpose
Nobody wants to read about `grep`, they want to find words, like 'cat'.
They want to 'download a website', not learn about `wget`.
Guides should be created and indexed by purpose, not by binary.
## Be Opinionated
- Guides should not ask the reader to select options half-way through.
- Guides should not ask the reader to pick from a list of options.
- Options for different filesystems, databases, et c., should be written as separate guides.
## Repetition Beats Reference
If a database requires three commands to set up, it's better to repeat those three commands for every program that requires a database than to just link to another file which discusses databases.
## Show Arguments as Variables
## Show Options as Variables
Look at this line:
@@ -82,28 +119,61 @@ The answer is not obvious.
It's better to make all arbitrary values variables.
```sh
git branch $branch_name
git checkout $branch_name
name=new
git branch ${name}
git checkout ${name}
PAGER='less -R'
grep ls --color=always $HISTFILE | $PAGER
```
Now we can see what can be changed.
## Assume People Follow the Instructions
### Aim to Script
Guides should read like a heavily commented script, so CLI commands are preferred to GUI commands.
- Bad: '*edit the file `.config/tspreed/tspreed.rc` and change `focuscolor` to '2'.*'
- Good: `sed -i '/focuscolor/s/=1/=2/' ~/.config/tspreed/tspreed.rc`
* `cat !$`
Despite being 'script-like', interactive bash commands like `cat !$` are still fine just to show how to double-check results when setting things up interactively.
### Show, Don't Tell
Articles should say what to type, not the output.
If the command is `ls`, users will see files once they try the command, but the article does not need to provide an example list of files unless an important point has to be made about output.
Once a user enters a new group, the change doesn't take effect until you log
in. This could be explained at length, or the reader can see what this means
for themselves:
```sh
groups
grep audio /etc/group
sudo usermod -aG audio $USER
groups
grep audio /etc/group
su $USER
groups
grep audio /etc/group
```
Troubleshooting steps can often be implied by adding commands which do nothing but check the results of previous commands.
# What's Wrong with Everything Else?
Why bother writing yet another cheat-sheet collection?
## Man pages
- Orders items by the alphabet rather than by relevance.
- Often presumes you know everything except that one program.
- Often written in the 80's, and it shows.
- Zero respect for your time.
- Often references `info` pages (yuck).
- Sometimes reference `info` pages (yuck).
## `curl cheat.sh`
@@ -114,9 +184,6 @@ If the command is `ls`, users will see files once they try the command, but the
# Current State
This started as a few personal notes, and will probably continue to look like that for some time.
It's a bit of a mess.
Systemd is taken as a default.
Non-systemd commands are mentioned when required for a distro, e.g. runit for Void Linux.
If you like the format, send me a pull request.

View File

@@ -1,360 +0,0 @@
---
title: "Basics"
tags: [ "basics" ]
---
You need about a dozen commands to move around Linux.
After that, you look up the rest as you go.
Don't worry about understanding any of it, just type it in and the habit forms pretty quickly.
You start in a dark room. You want to know where you are by **p**rinting out your **w**orking '**d**irectory' (i.e. 'location'):
```sh
pwd
```
Have a look at what is here:
```sh
ls
```
If you get no response, the list of items is "", meaning "nothing here".
Have a look at **a**ll the files:
```sh
ls -a
```
```sh
. ..
```
So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the directory behind you').
Change directory (`cd`) down one level:
```sh
cd ..
```
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
```sh
cd bob
```
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
```sh
cd /
```
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up:
```sh
du iptables
```
That's the number of kilobytes the file is taking up.
Do the same again, but in a human-readable format:
```sh
du -h iptables
```
The `du` program has `-h` for 'human', '-s' for 'short', and a bunch of other commands.
Have a look at the manual and try another command:
```sh
man du
```
Once you're done, press 'q' to quit the manual page and try the extra `du` flag you've found.
Now you can try to gain super-powers and take over the system:
```sh
sudo -i
```
At this point, you are 'root'.
All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine.
Best to exit out of the root account:
```sh
exit
```
Go find a file that isn't a directory. You can tell which is which with:
```sh
ls -l
```
A directory starts with a 'd', like this:
```sh
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
```
A standard file starts with '-', like this:
```sh
`-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname`
```
Look inside the file /etc/hostname to find out your computer's name:
```sh
cat /etc/hostname
```
Print out the words "hello world":
```sh
echo "hello world"
```
Move back to your home directory:
```sh
cd
```
Take the words 'hello world', and put them in 'my_file':
```sh
echo 'hello world' > my_file
```
Measure the disk usage of that file, then put the results at the bottom of the file:
```sh
du $FILE >> $FILE
```
And check the results:
```sh
cat $FILE
```
# Autocompletion
Press tab after typing a few keys and bash will guess what you're trying to type.
# Permissions
Look at your file's owner:
```sh
ls -l $FILE
```
If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is owned by 'root'.
Take your file and change the owner to root:
```sh
sudo chown root $FILE
```
Change the same file so it's owned by the group 'audio':
```sh
sudo chown :audio $FILE
```
Check you did that correctly:
```sh
ls -l my_file
```
> -rw-r--r-- 1 root audio 0 Jan 3 19:20 my_file
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
```sh
rm $FILE
```
You'll see you're not allowed, because you don't own it.
Look at which groups you're in:
```sh
groups
```
Change the file so that members of the audio group can write to the file:
```sh
sudo chmod g+w $FILE
```
Check you got it right with `ls -l`:
```sh
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
```
Try to delete the file again:
```sh
rm my_file
```
If you can't, you're not in the audio group. Add yourself. You'll need to *modify* your *user account*, by **a**ppending 'audio' to your list of groups.
Use `-a` to **a**ppend, and `-G`, to say you're modifying groups:
```sh
sudo usermod -a -G audio [ your username here ]
```
Now you should be able to remove (delete) the file. Remember, that using 'rm file' will not send it to a recycling bin. The file is gone.
# Directories
Make a directory called 'new test':
```sh
mkdir 'new test'
```
Make two directories, called 'A', and 'Z':
```sh
mkdir A Z
```
Make a single directory called 'A Z'
```sh
mkdir 'A Z'
```
# Text Searches
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
```sh
du -sch * > A/'disk usage'.txt
```
Look at your file:
```sh
cat A/'disk usage.txt'
```
If you think you have too much information, use `grep` to just get the one line of text you want:
```sh
grep total A/disk\ usage.txt
```
The `grep` program also has a manual ('man page'). You should find out what that `-c` flag does, but the manual is too long to read.
Start the manual:
```sh
man du
```
Then search for `-c` by pressing `/`. Your final keys should be `man du`, then `/-c`
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
```sh
man ls | grep human
```
Now use that flag that you've found in combinatin with the `-l` flag to look at a file.
Remove the directory 'Z':
```sh
rmdir Z
```
Remove the directory 'Z':
```sh
rmdir Z
```
And then remove all the rest:
```sh
rmdir *
```
The 'A' directory will not budge because it's not empty. Remove it recursively, so the computer will remove the things inside the directory as well as the directory itself:
```sh
rm -r A
```
# Installation
You get a package manager which installs programs, fonts, et c.
If you're on something like Debian, you'll have `apt`, or if you're on something like Red Hat, you'll have `yum`.
If unsure, ask where a program is:
```sh
whereis yum
```
```sh
whereis apt
```
If you get a hit, you can use whatever program that is to install things.
Set a reminder of your package manager:
```sh
echo my package manager is yum | lolcat
```
If that failed it's because you don't have `lolcat` installed.
Install lolcat:
```sh
sudo apt install lolcat
```
Try the same command again.
Search for things you want, like `libreoffice`, or `gimp`:
```sh
apt search libreoffice
```
... then install one of them with:
```sh
apt install $PROGRAM
```
Remove `lolcat`, because it's useless:
```sh
sudo apt remove lolcat
```
...and that's pretty much it.
You can move, create, destroy, install things, and look things up.
# Review
- Search for random things with your package manager and install the interesting ones.
* Read the manual with `man thing`
* If it's useless, remember to uninstall it.
- Have a look around the file system in `/`.
- Look in the `.config` folder in your home directory.
* If you copy a program's config to another machine, the program will behave just like you set it up in your own machine.

View File

@@ -1,191 +0,0 @@
---
title: "Quality of Life"
tags: [ "basics", "setup" ]
dependencies: [ "vi", "basics" ]
---
This & That
===========
Refer to 'that last thing', and 'the first thing':
```sh
fortune -l > file1
cat !$ | tr -d u
diff !^ !$
```
**NB:** this can go wrong:
```sh
ls -l file1 file2
cat !^
```
Done
----
`<C-d>`
- If you have a command, Control + d will execute the command.
- If you have nothing, `exit`.
Clear Search Highlights
=======================
`<Esc>+u`
Input Run-Commands (`~/.inputrc`)
=================================
Alias Expansion
---------------
```sh
echo '"\C- ": shell-expand-line' >> ~/.inputrc
exec bash
```
Now you can expand all aliases with 'Control + Space'.
Try just `ls`, then 'Control + Space'.
Glob Expansion (`*`)
--------------------
```sh
echo '"\C-x": glob-expand-word' >> ~/.inputrc
exec bash
ls *<C-x>
```
- Are you sure you want to delete that?
* `rm -r *<C-x>`
- Clean up the Downloads folder:
* `rm Downloads/*pdf<C-x>`
Arbitrary Commands
------------------
Use `\n` as a 'newline' character to automatically press `<Return>`.
```sh
echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
exec bash
ls<C-y>
```
```sh
Control-l: "\C-u clear -x && ls\n"
exec bash
cd /etc/<C-l>
```
Readline as Vi
--------------
```sh
echo 'set editing-mode vi' >> ~/.inputrc
echo 'set keymap vi-insert' >> ~/.inputrc
exec bash
```
The prompt now works according to `vi`-motions.
This goes much further than the bash-option, `set -o vi` ('set option: `vi`').
It changes the cursor in the terminal, not just bash.
Try:
- `ls <C-n>`
- `ls <C-p>`
- Type some words.
- `<Esc>0dw$p`
- <Esc> to normal-mode, and go back with 'b', and forward with 'e'.
- `4b` to step back four times.
- `cE`
- `<Esc>kcw`
- ls -a<Esc>xxxx
Readline can work with python one you set `PYTHON_BASIC_REPL` to `true`.
```sh
echo 'export PYTHON_BASIC_REPL=true' >> ~/.bashrc
exec bash
```
```python
im<C-n>os<Return>
os.li<C-n><Return>
<Esc>kfn
<C-d>
```
Fix Globs!
----------
If you tried the previous commands then they will not work any more, because the `vi`-commands overwrite the other commands.
Remove them.
```sh
sed '/ vi/d' ~/.inputrc
sed -i '/ vi/d' ~/.inputrc
sed '1 i set editing-mode vi' .inputrc
sed -i '1 i set editing-mode vi' ~/.inputrc
sed -i '2 i set keymap vi-insert' ~/.inputrc
```
Vi-sibility
-----------
The `readline` prompt becomes confusing if you don't remember if you're in insert or normal mode.
But you can show the current mode in the prompt:
```sh
echo 'set show-mode-in-prompt on' >> ~/.inputrc
exec bash
```
Set new symbols for normal and insert mode:
```sh
echo 'set vi-ins-mode-string " "' >> ~/.inputrc
echo 'set vi-cmd-mode-string " "' >> ~/.inputrc
```
Fuzzy Sort
==========
Check your repos for `sk-im`, and install.
The program is called `sk`.
```sh
FUZZY=sk
```
If you don't have it, `fzy` or `fzf` should work the same way.
```sh
FUZZY=fzy
```
Find some 'read-config' files to check out:
```sh
find . -maxdepth 2 -name "*rc"
find . -maxdepth 2 -name "*rc" | $FUZZY
```
And read some:
```sh
PAGER='less -R'
$PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)"
```
Make the change long-term:
```sh
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"'
alias | grep rrc= >> ~/.bash_aliases
```

View File

@@ -1,78 +0,0 @@
---
title: "time"
tags: [ "basics", "time" ]
---
# systemd
Set time to synchronize with an ntp server:
```sh
timedatectl set-ntp true
```
This info stays in `/usr/share/zoneinfo`.
# Local Time
Local time is kept in /etc/localtime.
According to Dave's LPIC guide, you can set the local time by making asymboling link from your timezone to /etc/localtime, as so:
```sh
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
```
...however this produced the wrong time for me. Further, /etc/localtime produces an output with cat, while the zoneinfo files do not.
# Locale
See local time, language and character settings with:
```sh
locale
```
List available locales with:
```sh
locale -a
```
To see additional locales which are available (but not necessarily installed):
```sh
cat /usr/share/i18n/SUPPORTED
```
Set a supported locale with:
```sh
locale-gen pl_PL.UTF-8
```
Then set that language, with:
```sh
LANG=pl_PL.UTF-8
```
...then reboot.
# Network Time Protocol
Glimpse an overview with:
```sh
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:
```sh
sudo ntpd -q -g -x -n
```

View File

@@ -1,13 +1,16 @@
---
title: "profanity"
tags: [ "chat", "omemo" ]
title: profanity
tags:
- chat
- omemo
---
# Setup (Commands)
Sign up to an account somewhere.
```
/connect bob@bobserver.org
/connect ${name}@${host}
```
Check if someone wants to be your friend:
@@ -19,13 +22,13 @@ Check if someone wants to be your friend:
Accept a friend's subscription request:
```
/sub add alice@aliceserver.org
/sub add ${name}@${host}
```
Join a room:
```
/join room1@bobserver.org
/join ${room}@${host}
```
Save your configuration so you don't have to do this again:
@@ -38,14 +41,14 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
## Automatically Sign In
To automatically sign in, add your password to [pass](../data/pass.md).
To automatically sign in, add your password to [pass](data/pass.md).
```
/account set *malin@oosm.org* eval_password pass *xmpp*
/account set ${name}@${host} eval_password pass *xmpp*
```
```
/autoconnect set *malin@oosm.org*
/autoconnect set ${name}@${host}}
```
```
@@ -59,7 +62,7 @@ Remember to save the config for other commands too.
## Messages
```
/msg alice@aliceserver.org
/msg ${name}@${host}}
```
This opens in a new tab.
@@ -96,7 +99,7 @@ Tell it how to save files:
Then get the file with:
```
/urlsave *<Tab>*
/urlsave <Tab>
```
Same for `/urlopen`
@@ -140,5 +143,3 @@ You can ensure omemo automatcally turns on:
```
/omemo policy automatic
```
---

View File

@@ -0,0 +1,15 @@
---
title: profanity automation
tags:
- chat
- omemo
requires:
- chat/profanity.md
---
Automate profanity with `--cmd`.
```sh
profanity --cmd /foo --cmd "/sleep 10" --cmd /quit
```

76
chat/send_email.md Normal file
View File

@@ -0,0 +1,76 @@
---
title: Send an email with a CLI command
tags:
- email
requires:
- data/pass.md
---
# Setup the Config
Install `msmtp` and set up the defaults.
```sh
mkdir ~/.config/msmtp/
cat > ~/.config/msmtp/config << EOF
defaults
tls on
auth on
EOF
```
You'll need to fill in some variables, like your provider's hostname and SMTP port.
The `${pass_name}` is just the `pass` command which gives your email password.
```sh
name=posteo
host=posteo.de
port=587
user=bob@posteo.net
pass_name=posteo.net
```
With those in, add that default account.
```sh
cat >> ~/.config/msmtp/config << EOF
account ${name}
host ${host}
port ${port}
user ${user}
from ${user}
passwordeval pass ${pass_name}
```
Finally, set this as the default account:
```sh
account default : ${account} >> ~/.config/msmtp/config
```
# Write an Email
Fill out the headers in a file called `mail`.
```
From: MSMTP ${user}
Subject: Pipes
To: ${recipient_name} <${recipient_email}>
A pipe gives a wise man time to think and a fool something to stick in his
mouth.
```
# Send
Send the email:
```sh
msmtp -t bindrpg@posteo.uk < mail
```

View File

@@ -1,6 +1,7 @@
---
title: "wgetpaste"
tags: [ "chat" ]
title: wgetpaste
tags:
- chat
---
See available pastebins:
@@ -27,3 +28,9 @@ Paste in the file then load the result to the right-hand clipboard:
wgetpaste -s dpaste -X
```
---
title:
tags:
chat
---

35
cmd.mk
View File

@@ -1,25 +1,36 @@
cmds != recsel command.rec -t command -G bin -U -CP bin
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
lists = $(patsubst %,lists/%.md, $(cmds))
default += $(lists)
get_title = printf 'title: "%s"\n' '${1}'
get_title = printf 'title: %s\n' '${1}'
get_tags = recsel -t $(basename $<) $< -G bin \
-e 'bin = "$(1)"' -U -CP tag | \
sed 's/.*/"&",/g' | \
tr '\n' ' ' | \
sed 's/.*/tags: [ &]/'
-e 'bin = "$(1)"' -U -CP tag,bin | \
sed 's/.*/- &/'
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
recfmt -f lists.fmt
lists/%.md: command.rec | lists/
$(lists): lists/%.md: command.rec | lists/
@printf '%s\n' '---' > $@
@$(call get_title,$(basename $(notdir $@))) >> $@
@printf '%s\n' 'tags: ' >> $@
@$(call get_tags,$(basename $(notdir $@))) >> $@
@printf '\n%s\n' '---' >> $@
@printf '%s\n' '---' >> $@
@$(call list_commands,$(basename $(notdir $@))) >> $@
.PHONY: cmd
cmd: $(lists) ## Big lists of commands
.PHONY: function
function: ## Output a search function for .bashrc
${MAKE} --silent --touch query
printf '%s\n' 'lk(){'
${MAKE} --silent --dry-run query | sed 's/^/\t/'
printf '%s\n' '}'
.PHONY: query
query: db.rec ## Search the setup notes
passes=0 count=0; until [ "$$count" -eq "1" ] || [ "$$passes" -gt 2 ] ; do \
query="$$(recsel "${PWD}"/db.rec -p aim,tag | recsel -iq "$$query" -CP aim,tag | sort -u | fzf --preview='recsel "${PWD}"/db.rec -e "aim~{}"')" \
&& count="$$(recsel "${PWD}"/db.rec -q "$$query" -c )" ;\
passes=$$(( passes + 1 )) ;\
done \
&& recsel "${PWD}"/db.rec -q "$$query" | recfmt -f "${PWD}/lists.fmt" | ${PAGER}

View File

@@ -1,51 +1,504 @@
%rec: command
%doc: shell command examples
%type: aim line
%allowed: aim cmd bin tag
%allowed: aim cmd bin tag note shell
%unique: shell
aim: Put output into column
cmd: du -h /etc/* | column
aim: Put output into columns
cmd: ip a | grep inet | column -ts' '
shell: sh
bin: column
tag: format
aim: Reformat file with an explicit separator (`-s`)
aim: Reformat user accounts with an explicit separator (`-s`)
cmd: column -ts: /etc/passwd
shell: sh
bin: column
tag: format
aim: Give columns names (`-N`), so you can hide some (`-H`)
aim: Sort user accounts into columns with names
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
note: Hide some columns with `-H`.
shell: sh
bin: column
tag: format
aim: Reorder with `-O` (unspecified items remain)
aim: Sort user accounts into columns and reorder them
cmd: column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
note: Unspecified items remain.
shell: sh
bin: column
tag: format
aim: Output to json format with `-J`
aim: Output user accounts in json format with `-J`
cmd: column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
shell: sh
bin: column
tag: format
tag: json
aim: Make a QR Code image:
cmd: qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png
aim: Make a QR Code image
cmd: qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "${file}".png
shell: sh
bin: qrencode
tag: qr
aim: Make a QR Coded message in the terminal:
aim: Make a QR Coded message in the terminal
cmd: qrencode -t ansi "Hello World"
shell: sh
bin: qrencode
tag: qr
aim: Read a QR Code image:
cmd: zbarimg $FILE
aim: Read a QR Code image
cmd: zbarimg ${file}
shell: sh
bin: qrencode
tag: qr
aim: Show wifi QR code (only with Network Manager):
aim: Show wifi QR code (only with Network Manager)
cmd: nmcli device wifi show-password
shell: sh
bin: qrencode
bin: nmcli
tag: qr
tag: wifi
aim: Combine many recfiles of different types into one
cmd: sed '1i\ ' *.rec > all.rec
shell: sh
bin: sed
tag: recfiles
tag: database
aim: Combine many recfiles of the same type into one
cmd: recinf -d -t ${type} ${one}.rec > ${all}.rec
+ sed '/^%/d' ${one}.rec ${two}.rec > all.rec
note: The strange syntax used by `sed` only makes sense after using [ed](writing/ed.md)
shell: sh
bin: sed
bin: recinf
tag: recfiles
tag: database
aim: Roll a die
cmd: echo $(( RANDOM % 6+1 ))
shell: bash
tag: random
aim: Remotely edit a file with vim
cmd: vim scp://${server}/~/${file}
cmd: vim scp://${user}@${server}:${port}//${path}/${file}
shell: sh
bin: vim
bin: scp
tag: network
aim: Find and replace across all files open in vim
cmd: :bufdo! %s/${pattern}/${replacement}/g
shell: sh
bin: vim
tag: writing
tag: replace
aim: Find and replace words, but confirm each replacement
cmd: vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file}
shell: sh
bin: vim
tag: replace
tag: substitution
tag: TUI
tag: writing
aim: Hard reset ntp service
cmd: sudo ntpd -q -g -x -n
bin: ntpd
tag: time
tag: system
aim: Check a service
cmd: sudo systemctl status mpd
shell: sh
bin: systemd
tag: system
tag: service
aim: Recognize service changes
cmd: sudo systemctl daemon-reload
shell: sh
bin: systemd
tag: system
tag: service
aim: Start a service (it stops when the computer shuts down)
cmd: sudo systemctl taskd.service start
+ sudo systemctl daemon-reload
shell: sh
bin: systemd
tag: system
tag: service
aim: Find out why the computer takes so long to start
cmd: sudo systemd-analyze
+ sudo systemd-analyze blame
shell: sh
bin: systemd
tag: system
tag: boot
aim: See what the computer is doing
cmd: journalctl -f
shell: sh
bin: journalctl
tag: system
aim: Check your own user services:
cmd: journalctl -f
shell: sh
bin: journalctl
tag: system
aim: Edit users in /etc/passwd directly
cmd: sudo vipw
note: You can't edit passwords with black magic.
shell: sh
bin: vipw
bin: sudo
tag: system
tag: users
aim: Edit groups in /etc/group directly
cmd: sudo vigr
note: You can't edit passwords with black magic.
shell: sh
bin: vipw
bin: sudo
tag: system
tag: groups
aim: Follow the `ssh` daemon service
cmd: journalctl -f -u sshd
shell: sh
bin: journalctl
tag: system
aim: Get back terminal after ssh freezes remote machine
cmd: <Return>~.
shell: sh
bin: ssh
tag: system
tag: comfy
aim: Find errors since a date
cmd: date=2027-01-01
+ journalctl --since=${date} --grep="EXT4-fs error"
shell: sh
bin: journalctl
tag: system
aim: Limit the systemd's journal size to 2 gigabytes
cmd: journalctl --vacuum-size=2G
+ journalctl --disk-usage
shell: sh
bin: journalctl
tag: system
tag: logs
aim: Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can determine why your system's broken later
cmd: logger "Installed new dnsmasq"
+ sudo journalctl -f
shell: sh
bin: journalctl
bin: logger
tag: system
tag: logs
aim: Convert markdown table to csv
cmd: mlr --imarkdown --ocsv cat ${file}.md
bin: mlr
tag: csv
tag: markdown
tag: data
aim: Convert a csv file to markdown
cmd: mlr --icsv --omd cat ${file}.csv
bin: mlr
tag: csv
tag: markdown
aim: Quickly find and open run-command files
cmd: alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
bin: fzf
bin: find
tag: comfy
aim: Quickly hunt and kill processes
cmd: kill $(pgrep less | fzf -m --preview='ps {}')
note: Select many with shift/tab.
bin: fzf
tag: comfy
aim: Search for a short word
cmd: grep "\b${word}\b" ${file}
bin: grep
tag: search
aim: Extract words in quotes
cmd: grep -o "\b${word}\b" ${file}
bin: grep
tag: search
aim: Reformat text for shell input
cmd: printf "%q\n" "${text}"
bin: printf
tag: xargs
tag: stdout
aim: Find your public IP address
cmd: dig +short myip.opendns.com @resolver$((RANDOM % 4 + 1)).opendns.com
shell: bash
bin: dig
tag: ip
tag: network
aim: Turn markdown into a man page
cmd: man <(lowdown -stman ${file}.md)
cmd: top_title="Bugs in netcat"
+ someplace=LK
+ vol=Security
+ sec=6
+ lowdown -m manheader="${top_title}" -m source="${someplace}" -m volume="${vol}" -m section=${sec} -stman ${file}.md > ${file}.${sec}
+ man ./${file}.${sec}
shell: bash
bin: lowdown
bin: groff
bin: man
tag: markdown
aim: Convert jpg to png
cmd: magick ${input}.jpg ${output}.png
bin: magick
tag: vision
aim: Reduce jpg size by reducing quality
cmd: quality=70
+ magick ${input}.jpg -quality ${quality} ${output}.jpg
cmd: size=50
+ magick -resize ${size}% ${input}.jpg ${output}.jpg
bin: magick
tag: vision
aim: Reduce png size
cmd: magick ${input}.png png8:${output}.png
bin: magick
tag: vision
aim: Invert jpg colours
cmd: magick ${input}.jpg ${output}.jpg -negate
bin: magick
tag: vision
aim: Make jpg smaller
cmd: magick ${input}.jpg -resize 25% ${output}.jpg
bin: magick
tag: vision
aim: Trim images to border
cmd: magick -trim ${image}.png ${output}.png
bin: magick
tag: vision
aim: Make the white of an image transparent
cmd: magick -transparent white -fuzz 10% ${input}.png ${output}.png
bin: magick
tag: vision
note: The 'fuzz' option tells the computer that 'close to white' is fine. You might want to use 20% or higher fuzz.
aim: Give transparrent image a dropshadow
cmd: magick ${input}.png \( +clone -background black -shadow 50x8+0+5 \) +swap -background none -layers merge +repage ${output}.png
bin: magick
tag: vision
aim: Convert every jpg in directory to png
cmd: mogrify -format png *.jpg
bin: magick
tag: vision
aim: Convert from jpg to svg
cmd: magick -flatten ${input}.jpg ${output}.ppm
+ potrace -s ${output}.ppm -o ${svgout}.svg
bin: magick
tag: vision
aim: Make an image showing day of the week
cmd: magick -list font
+ font="$(magick -list font | grep -oP 'Font: \K.*' | head -1)"
+
+ magick -fill blue -font "${font}" -gravity center -pointsize 79 label:$(date +%A) day.png
bin: magick
tag: vision
aim: Make a meme
cmd: magick ${input} -font impact -fill white -pointsize 84 -stroke black -strokewidth 3 -gravity north -annotate +0+20 'TOP MEME TEXT' -gravity south -annotate +0+20 'BOTTOM MEME TEXT' ${output}
bin: magick
tag: vision
tag: memes
aim: Rotate a video
cmd: ffmpeg -i "${input}" -vf "transpose=1" "${out.mov}"
note:
+ | No. | Degrees | Flip |
+ |:---:|:-------:|:---------------------------------------|
+ | 0 | 90 Counterclockwise and verfical flip (default) |
+ | 1 | 90 Clockwise |
+ | 2 | 90 CounterClockwise |
+ | 3 | 90Clockwise and vertical flip |
tag: vision
tag: video
shell: sh
aim: Translate a media file to a new type
cmd: ffmpeg -formats
+ ffmpeg -i ${input} ${output}
bin: ffmpeg
tag: vision
tag: music
tag: video
shell: sh
aim: Reduce video quality
cmd: quality=20
+ ffmpeg -i ${input}.mp4 -vcodec libx264 -crf ${quality} ${output}.mp4
note: A crf quality of 18 is high, while 24 is low quality.
bin: ffmpeg
tag: vision
tag: video
shell: sh
aim: Convert from mkv to mp4 with a codec
cmd: ffmpeg -i ${input}.mkv -codec copy ${output}.mp4
note: Both mp4 and mkv are wrappers around other formats, so this conversion loses less quality than other conversion types.
bin: ffmpeg
tag: vision
tag: video
shell: sh
aim: Convert video to audio
cmd: ffmpeg -i ${input}.mp4 -vn ${output}.mp3
bin: ffmpeg
tag: vision
tag: video
shell: sh
aim: Convert all mkv files to mp4
cmd: for i in *.mkv; do
+ ffmpeg -i "$i" -codec copy "${i%.*}.mp4"
+ done
bin: ffmpeg
tag: vision
shell: sh
aim: Change resolution
cmd: ffmpeg -i ${input}.mp4 -filter:v scale=1280:720 -c:a copy ${output}.mp4
bin: ffmpeg
tag: vision
shell: sh
aim: Change video aspect ratio
cmd: ffmpeg -i input.mp4 -aspect 16:9 output.mp4
bin: ffmpeg
tag: vision
tag: video
shell: sh
aim: Trim video to start and stop times
cmd: start=00:00:50
+ stop=50
+ ffmpeg -i ${input}.mp4 -ss ${start} -codec copy -t ${stop} ${output}.mp4
note: The `$stop` time shows how many seconds after the start you want.
bin: ffmpeg
tag: vision
shell: sh
aim: Compress a video file
cmd: quality=21
+ ffmpeg -i ${input}.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf ${quality} ${output}.mp4
note: A crf quality of 18 is high, while 24 is low quality.
bin: ffmpeg
tag: vision
tag: video
shell: sh
aim: Convert video to a series of images
cmd: framerate=1
+ format=image2
+ ffmpeg -i input.mp4 -r ${framerate} -f ${format} image-%2d.png
bin: ffmpeg
tag: vision
shell: sh
aim: Add subtitles to a video file
cmd: fmpeg -i ${input}.mp4 -i subtitle.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast ${output}.mp4
bin: ffmpeg
tag: vision
shell: sh
aim: Convert a web page to markdown
cmd: curl -sL "${url}" | html2markdown > "${file}}".md
cmd: curl -sL "${url}" | html2text > "${file}}".md
note: The `[html2markdown](https://github.com/JohannesKaufmann/html-to-markdown)` and `html2md` programs works better than any other.
bin: html2markdown
bin: curl
tag: writing
tag: web
shell: sh
aim: Decode a URL with function
cmd: urldecode() { echo -e "${@//%/\\x}"; }
+ urldecode "${magnet}"
tag: web
shell: bash
aim: Choose which parts to commit with git
cmd: git commit -p
note: Use `P` to see big changes which cannot fit on the screen.
tag: comfy
bin: git
shell: sh
aim: Request a definition from the terminal.
cmd: word='abderian'
+ curl -s dict://dict.org/define:${word}:
cmd: function wotsa(){
+ def="$(curl -s dict://dict.org/define:${1// /+}: | grep -vP '^\d\d\d ')"
+ if [ "$def" = "" ]; then
+ echo no definition
+ else
+ echo "$def" | $PAGER
+ fi
+ }
bin: curl
tag: writing
tag: comfy
tag: dict
shell: sh
aim: Email a pull request which points to your git server
tag: git
bin: git
tag: email
tag: pr
cmd: repo=ssh://soft.dmz.rs:2222/mkdots/
+ theirHead='HEAD^^^^'
+ head=master
+ git request-pull "${theirHead}" "${repo}" "${head}"
note: You can note where your branch diverged from theirs with a commit hash,
+ or a relative position, like `HEAD^^` (e.g. 'two commits before your latest').
aim: Clean up a bloated git repo
cmd: git fsck --full
+ git gc --prune=now --aggressive
+ git repack
bin: git
tag: maintenance
shell: sh

View File

@@ -1,15 +1,16 @@
---
title: "Archives"
tags: [ "tar", "backups", ".tgz", "tar.gz" ]
title: Archives
tags:
- archives
- backups
---
# `tar`
## Create
# Create
Combine many files and directories into a single t-archive file.
```sh
tar cf "$ARCHIVE".tar $DIR
tar cf "${archive}".tar ${dir}
```
You can remember this with the mnemonic '*C*reate *F*ile'.
@@ -17,13 +18,13 @@ Unfortunately, this stores the full file path, so making a tar archive of `/etc/
It's often better to tell tar which path to start from using the `-C` flag.
```sh
tar cf "$ARCHIVE".tar -C /etc/ nginx
tar cf "${archive}".tar -C /etc/ nginx
```
Check the contents of your archive with:
```sh
tar tf "$ARCHIVE".tar
tar tf "${archive}".tar
```
If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
@@ -32,47 +33,26 @@ Instead, you can store the target in a variable:
```sh
files=$(ls /etc/nginx)
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
tar cf "${archive}".tar -C /etc/nginx/ $file
```
## Extract
# Extract
Extract the tar archive with
```sh
tar xf "$ARCHIVE".tar
tar xf "${archive}".tar
```
You can remember this with the mnemonic 'e*X*tract *F*ile'.
## Compress
# Compress
Create a zip-compressed archive with the `z` flag.
```sh
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
tar czf "${archive}".tgz -C /etc/nginx/ $file
```
You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.
# 7zip
(also called 'p7zip' or '7z')
Make archive:
```sh
7za a -tzip -p "$PASSWORD" -mem=AES256 $ARCHIVE.zip $FILE_1 $FILE_2
```
Note that people can still see every filename in your archive, and can change those files.
They just can't read the contents.
Unzip:
```sh
7za x archive.zip
```
7zip will open anything: zip-files, rar-files, a tin of beans, *anything*.
However, the extracted tgz files will just be tar files, so you will still need to use tar to extract them (see above).

View File

@@ -1,6 +1,7 @@
---
title: "Base 16"
tags: [ "data" ]
title: Base 16
tags:
- data
---
Base 16 numbers often use `0x` at the start, so '10' just means '10', but `0x10` means '10 in base 16' which means '16'.

View File

@@ -1,14 +0,0 @@
---
title: "calcurse"
tags: [ "data", "calendar", "daylight savings" ]
---
## Setup
The UK government keeps an `ics` file with clock.
```sh
wget https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics
calcurse -i united-kingdom.ics
```

34
data/calcurse_import.sh Normal file
View File

@@ -0,0 +1,34 @@
---
title: Import an ICS file into calcurse
tags:
- data
- calendar
- daylight savings
requires:
- calcurse
---
## Setup
The UK government keeps an `ics` file with clock.
```sh
wget https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics
calcurse -i united-kingdom.ics
```
If you already have some of these events, and don't want duplicates, import the events into a temporary file.
```sh
TMP=$(mktemp)
curl -s "$1" | calcurse -q -i - -c "$TMP"
```
Then search for new lines in the new calendar file to put into your appointments file.
```sh
CALDATA=~/.local/share/calcurse/apts
grep -vf "$CALDATA" "$TMP" >> "$CALDATA"
rm $TMP
```

View File

@@ -1,6 +1,8 @@
---
title: "e-mail"
tags: [ "data", "smtp" ]
title: e-mail
tags:
- data
- smtp
---
This is bare-bones, original, primitive e-mail.

View File

@@ -1,6 +1,8 @@
---
title: "exiftool"
tags: [ "metadata", "exifdata" ]
title: exiftool
tags:
- metadata
- exifdata
---
Find metadata:

133
data/git.md Normal file
View File

@@ -0,0 +1,133 @@
---
title: git
tags:
- data
- setup
---
```sh
git config --global user.email "${email}"
```
```sh
git config --global user.name "${name}"
```
Decide on algorithm:
- If you're scared of insecure hash-sums, go with `hash=sha256`.
- If you don't know what a hash sum is, go with `hash=sha1`.
## Init the Git
Start a git in directory `${DIR}`:
```sh
git init --object-format=${hash} ${DIR}
cd ${dir}/
```
Make a file explaining what the project does, and tell `git` to track it:
```sh
echo "I hereby solemnly swear never to commit a binary file." > README.md
git add README.md
```
Then make the initial commit, explaining the change you just made:
```sh
git commit
```
# Working
Once you make a change to some file, add it and make a commit explaining it.
```sh
git add ${file}
```
```sh
git commit -m"change ${file}"
```
Check your history:
```sh
git log
```
# Remotes
If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing).
Give it the same name as the `$DIR` directory, above.
Add this as a remote:
```sh
remote=gitlab
git remote add ${remote} https://gitlab.com/${username}/${dir}
```
Tell git you're pushing the branch 'master' to the remote repo 'origin':
```sh
git push -u master origin
```
Pull down changes that others have made:
```sh
git pull
```
# Branches
A branch is a full copy of the project to test additional ideas.
You can make a new branch called 'featurez' like this:
```sh
git branch ${feature_branch}
```
Have a look at all your branches:
```sh
git branch
```
Switch to your new branch:
```sh
git checkout ${feature_branch}
```
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
```sh
git branch -D ${feature_branch}
```
Or if it's a good branch, push it to the remote:
```sh
remote=origin
git push $remote ${feature_branch}
```
# Merging
Once you like the feature, merge it into the main branch. Switch to master then merge it:
```sh
git merge ${feature_branch}
```
And delete the branch, as you've already merged it:
```sh
git branch -d ${feature_branch}
```

View File

@@ -1,202 +0,0 @@
---
title: "git"
tags: [ "data" ]
---
# Starting
## New Machines
```sh
git config --global user.email "$YOUR_EMAIL"
```
```sh
git config --global user.name "$YOUR_NAME"
```
# New Git
Decide on algorithm:
- If you're scared of insecure hash-sums, go with `hash=sha256`.
- If you don't know what a hash sum is, go with `hash=sha1`.
## Init the Git
Start a git in directory `${DIR}`:
```sh
git init --object-format=${hash} ${DIR}
cd ${DIR}
```
Make a file explaining what the project does, and tell `git` to track it:
```sh
echo "I hereby solemnly swear never to commit a binary file." > README.md
git add README.md
```
Then make the initial commit, explaining the change you just made:
```sh
git commit
```
# Working
Once you make a change to some file, add it and make a commit explaining it.
```sh
git add $FILE
```
```sh
git commit -m"change $FILE"
```
Check your history:
```sh
git log
```
# Remotes
If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing).
Give it the same name as the `$DIR` directory, above.
Add this as a remote:
```sh
REMOTE=gitlab
git remote add $REMOTE https://gitlab.com/$USERNAME/$DIR
```
Tell git you're pushing the branch "master" to the remote repo "origin":
```sh
git push -u master origin
```
If someone makes a change on the remote, pull it down with:
```sh
git pull
```
# Branches
A branch is a full copy of the project to test additional ideas.
You can make a new branch called 'featurez' like this:
```sh
git branch $FEATURE_BRANCH
```
Have a look at all your branches:
```sh
git branch
```
Switch to your new branch:
```sh
git checkout $FEATURE_BRANCH
```
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
```sh
git branch -D $FEATURE_BRANCH
```
Or if it's a good branch, push it to the remote:
```sh
remote=origin
git push $remote $FEATURE_BRANCH
```
## Merging
Once you like the feature, merge it into the main branch. Switch to master then merge it:
```sh
git merge $FEATURE_BRANCH
```
And delete the branch, as you've already merged it:
```sh
git branch -d $FEATURE_BRANCH
```
# Subtree
## Pulling another git repo into a subtree
```sh
git subtree add -P config git@gitlab.com:bindrpg/config.git master
```
# Tricks
## Delete All History
```sh
git checkout --orphan temp
```
```sh
git add -A
```
```sh
git commit -am "release the commits!"
```
```sh
git branch -D master
```
```sh
git branch -m master
```
```sh
git push -f origin master
```
Gitlab requires more changes, such as going to `settings > repository` and switching the main branch, then stripping protection.
## Clean up Bloated Repo
```sh
git fsck --full
```
```sh
git gc --prune=now --aggressive
```
```sh
git repack
```
## Find Binary Blobs
```sh
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
```
# More
For big binary files (like images), see [git large-file-storage](git-lfs.md)

View File

@@ -1,6 +1,10 @@
---
title: "Commit for Another"
tags: [ "data", "git" ]
title: Commit for Another
tags:
- data
- git
requires:
- data/git.md
---
You can make Alice the author, while you are still the commiter:

View File

@@ -1,7 +1,10 @@
---
title: "git-lfs"
tags: [ "data", "git" ]
requires: [ "git" ]
title: git-lfs
tags:
- data
- git
requires:
- data/git.md
---
Git Large File Storage ('LFS') needs to change your `~/.gitconfig` to check out those binary files:

View File

@@ -1,6 +1,9 @@
---
title: "git-secret"
tags: [ "data", "git" ]
title: git-secret
tags:
- data
- git
- review
---
This utility is largely useless, as it can only identify people by their email.

View File

@@ -1,7 +1,10 @@
---
title: "git stash"
tags: [ "data", "git" ]
requires: [ "git" ]
title: git stash
tags:
- data
- git
requires:
- data/git.md
---
Save file-changes without committing anything.

View File

@@ -1,12 +1,14 @@
---
title: "git hooks"
tags: [ "data", "git" ]
title: git hooks
tags:
- data
- git
---
Check out the sample hooks:
```sh
cd $GIT_REPO
cd ${git_repo}
ls .git/hooks
head .git/hooks/pre-commit.sample
```
@@ -21,7 +23,9 @@ chmod u+x .git/hooks/commit-msg
## Committing
Your `git hooks` will not enter the repository, but you can commit them to a repository, then request others add these git hooks to their own branch, by putting a note in the project's `README.md`.
The `git hooks` will not work on other people who use the repository, but you
can commit them to a repository, then request others add these git hooks to
their own branch, by putting a note in the project's `README.md`.
```markdown
The project comes with recommended git hooks.

View File

@@ -1,34 +0,0 @@
---
title: "git subtree"
tags: [ "data", "git", "subtree" ]
---
## Pulling a Subtree from an existing git
The project has subdirectories `sub-1`, `sub-2`, `sub-3`.
The first should be its own repository, but should also retain its own history.
First, we extract its history as an independent item, and make that into a seprate branch.
```sh
git subtree split --prefix=sub-1 -b sub
```
If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3
Then go and create a new git somewhere else:
```sh
cd ..;mkdir sub-1;cd sub-1;git init --bare
```
Then go back to your initial git repo, and do the following:
git push ../subtest sub:master
Finally, you can clone this repo from your original.
```sh
git clone ../subtest
```

View File

@@ -1,7 +1,149 @@
---
title: "gpg"
tags: [ "data", "gpg" ]
title: GPG Basics
tags:
- data
- GPG
---
- [Setup](gpg/basics.md)
- [Extras](gpg/extras.md)
# Making keys
Generate keys:
```sh
gpg --full-generate-key
```
Follow the guide.
# Encrypting a file
```sh
gpg -r malinfreeborn@posteo.net -e file
```
`-r` specifies the recipient.
Check you have an encrypted version of your file.
# Changing Expiration Dates
```sh
gpg --list-keys
# or...
gpg -k
```
... and then use the second part of 'pub', which is the ID. But that's not appearing here so... on with gpg2?
# Making encrypted files with a local password
Make a password with a password (cypher encryption).
```sh
gpg -c --output passwords.txt
```
or
```sh
gpg -c > passwords.txt
```
Put in a password.
Write message then stop with Ctrl+d.
Get the message back out the file with:
```sh
gpg -d passwords.txt
```
# Circles of Trust
Search for a key at any key store:
```sh
gpg --search-keys nestorv
```
Once you've made a decision about someone:
```sh
gpg --list-keys
```
You get something like this:
```
pub rsa3072 2021-08-15 [SC] [expires: 2023-08-15]
CD30421FD825696BD95F1FF644C62C57B790D3CF
uid [ultimate] Malin Freeborn <malinfreeborn@posteo.net>
sub rsa3072 2021-08-15 [E] [expires: after-forever]
```
Notice the long, ugly, string - `CD30421FD825696BD95F1FF644C62C57B790D3CF` - and how horribly ugly it is.
This is a fingerprint.
You can now decide the trust level (this stays on your computer).
```sh
gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
```
Once you're in the interface, type `trust`.
```sh
gpg --sign-key alice@posteo.net
```
# Swapping Keys
This system relies on a ring of people swapping key information.
## Sending
Send those trusted keys up to a server, so people can see you have verified them:
```sh
gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
```
## Upload Your Keys
## Add More Key Servers
Key servers often swap keys, but it's best to just send to multiple places immediately.
You can add key servers by adding this to `~/.gnupg/gpg.conf`.
```
keyserver hkps://keys.openpgp.org
keyserver hkps://mail-api.proton.me
keyserver hkps://keys.mailvelope.com
```
# Refresh Keys
Refreshing keys will tell you if some key you have contains a signature from someone you already trust, or if someone has published a revocation certificate (meaning their key should not be trusted any more).
```sh
gpg --refresh-keys
```
You can use the [crontab](system/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data.
# Export
Your public key:
```sh
gpg --output me.gpg --armor --export
```
Alternatively:
```sh
gpg --export -a person@email.tld > my_key.pub
```

View File

@@ -1,146 +0,0 @@
---
title: "GPG Basics"
tags: [ "data", "GPG" ]
---
# Making keys
Generate keys:
```sh
gpg --full-generate-key
```
Follow the guide.
# Encrypting a file
```sh
gpg -r malinfreeborn@posteo.net -e file
```
`-r` specifies the recipient.
Check you have an encrypted version of your file.
# Changing Expiration Dates
```sh
gpg --list-keys
# or...
gpg -k
```
... and then use the second part of 'pub', which is the ID. But that's not appearing here so... on with gpg2?
# Making encrypted files with a local password
Make a password with a password (cypher encryption).
```sh
gpg -c --output passwords.txt
```
or
```sh
gpg -c > passwords.txt
```
Put in a password.
Write message then stop with Ctrl+d.
Get the message back out the file with:
```sh
gpg -d passwords.txt
```
# Circles of Trust
Search for a key at any key store:
```sh
gpg --search-keys nestorv
```
Once you've made a decision about someone:
```sh
gpg --list-keys
```
You get something like this:
```
pub rsa3072 2021-08-15 [SC] [expires: 2023-08-15]
CD30421FD825696BD95F1FF644C62C57B790D3CF
uid [ultimate] Malin Freeborn <malinfreeborn@posteo.net>
sub rsa3072 2021-08-15 [E] [expires: after-forever]
```
Notice the long, ugly, string - `CD30421FD825696BD95F1FF644C62C57B790D3CF` - and how horribly ugly it is.
This is a fingerprint.
You can now decide the trust level (this stays on your computer).
```sh
gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
```
Once you're in the interface, type `trust`.
```sh
gpg --sign-key alice@posteo.net
```
# Swapping Keys
This system relies on a ring of people swapping key information.
## Sending
Send those trusted keys up to a server, so people can see you have verified them:
```sh
gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
```
## Upload Your Keys
## Add More Key Servers
Key servers often swap keys, but it's best to just send to multiple places immediately.
You can add key servers by adding this to `~/.gnupg/gpg.conf`.
```
keyserver hkps://keys.openpgp.org
keyserver hkps://mail-api.proton.me
keyserver hkps://keys.mailvelope.com
```
# Refresh Keys
Refreshing keys will tell you if some key you have contains a signature from someone you already trust, or if someone has published a revocation certificate (meaning their key should not be trusted any more).
```sh
gpg --refresh-keys
```
You can use the [crontab](../../system/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data.
# Export
Your public key:
```sh
gpg --output me.gpg --armor --export
```
Alternatively:
```sh
gpg --export -a person@email.tld > my_key.pub
```

View File

@@ -1,35 +0,0 @@
---
title: "gpg with vim"
tags: [ "vim", "data", "GPG" ]
requires: [ "GPG Basics", "vim basics" ]
---
The `vim-gnupg` plugin lets vim edit gpg-encrypted files as if they were unencrypted.
It's probably in your package manager.
If not, you'll need to endure the faff of following the [instructions](http://www.vim.org/scripts/script.php?script_id=3645).
## Prompt for password in terminal
Check your current gpg-agent configuration:
```sh
gpgconf --list-options gpg-agent
```
Create file, if it doesnt exit `~/.gnupg/gpg-agent.conf`:
```
# Force terminal prompts for passwords
pinentry-mode loopback
# Optional: specify which pinentry program to use
pinentry-program /usr/bin/pinentry-tty
```
Then restart gpg-agent:
```sh
gpg-connect-agent reloadagent /bye
```

34
data/gpg/gpg_pinentry.md Normal file
View File

@@ -0,0 +1,34 @@
---
title: GPG Password Entry
tags:
- vim
- secrets
- TUI
requires:
- data/gpg.md
- writing/vim.md
---
Check your current gpg-agent configuration:
```sh
gpgconf --list-options gpg-agent
```
Create file, if it doesn't exit `~/.gnupg/gpg-agent.conf`:
```
# Force terminal prompts for passwords
pinentry-mode loopback
# Optional: specify which pinentry program to use
pinentry-program /usr/bin/pinentry-tty
```
Then restart gpg-agent:
```sh
gpg-connect-agent reloadagent /bye
```

View File

@@ -0,0 +1,17 @@
---
title: Edit gpg encrypted files with vim
tags:
- vim
- data
- gpg
- comfy
requires:
- data/gpg.md
- writing/vim.md
---
The `vim-gnupg` plug-in lets vim edit gpg-encrypted files as if they were unencrypted.
It's probably in your package manager.
If not, you'll need to endure the faff of following the [instructions](http://www.vim.org/scripts/script.php?script_id=3645).

View File

@@ -1,6 +1,9 @@
---
title: "groff"
tags: [ "data", "logic" ]
title: groff
tags:
- documentation
- typography
- logic
---
# Basic Documents
@@ -60,8 +63,6 @@ The equation shorthands are predictable:
| Not equal | != |
| Superscript | sup {thing} |
- [List of symbols](https://www.math-linux.com/man/man7/groff_char.7.html)
### Examples
The fraction 2/5ths:

View File

@@ -1,6 +1,11 @@
---
title: "Interactive String Substitution"
tags: [ "data", "vim", "substitution", "replace", "TUI" ]
title: Interactive String Substitution
tags:
- data
- vim
- substitution
- replace
- TUI
---
Want to find and replace, but also confirm each instance?

View File

@@ -1,6 +1,9 @@
---
title: "ijq"
tags: [ "data", "json", "TUI" ]
title: ijq
tags:
- data
- json
- TUI
---
Analyse `json` easier with `ijq`.

View File

@@ -1,6 +1,7 @@
---
title: "khard"
tags: [ "data" ]
title: khard
tags:
- data
---
Get the basic config:

View File

@@ -1,6 +1,7 @@
---
title: "newsboat"
tags: [ "RSS" ]
title: newsboat
tags:
- RSS
---
Create the configuration directory before you start, and add at least 1 URL.
@@ -12,7 +13,7 @@ mkdir ~/.config/newsboat
echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
```
Start `newsobat` and press `r` to load your feed.
Start `newsboat` and press `r` to load your feed.
To add a feed, you can press `E` to edit that `urls` file.

View File

@@ -1,7 +1,8 @@
---
title: "Newsraft"
tags: [ "data", "RSS" ]
requires: [ "Shell Scripts" ]
title: Newsraft
tags:
- data
- RSS
---
# Setup

View File

@@ -1,10 +1,14 @@
---
title: "pass"
tags: [ "data", "credentials", "secrets" ]
requires: "GPG Basics"
title: pass
tags:
- data
- credentials
- secrets
requires:
- data/gpg.md
---
Setup [gpg](./gpg.md) keys.
Setup [gpg](data/gpg.md) keys.
Show your gpg secret it:
@@ -15,28 +19,37 @@ gpg --list-secret-keys
Then use the id number under `sec` to make a pass repo:
```sh
KEY="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
key="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
```
```sh
pass init $KEY
pass init $key
cat .password-store/.gpg-id
```
To add a basic password, e.g. for `$WEBSITE`:
To add a basic password, e.g. for `${website}`:
```sh
pass $WEBSITE
pass ${website}
```
To insert a multi-line password, e.g. with a login name:
```sh
pass add -m $WEBSITE
pass add -m ${website}
```
Remove a password:
```sh
pass rm $WEBSITE
pass rm ${website}
```
You can generate passwords with `xkcdpass`.
Automatically insert a password with `pass insert`:
```sh
xkcdpass | pass insert --echo ${website}
```

View File

@@ -1,7 +1,13 @@
---
title: "pass with otp"
tags: [ "data", "credentials", "secrets", "2fa", "otp" ]
requires: "pass"
title: pass with otp
tags:
- data
- credentials
- secrets
- 2fa
- otp
requires:
- data/pass.md
---
Need a Microsoft or Google authenticator?

View File

@@ -1,6 +1,9 @@
---
title: "pdf to txt"
tags: [ "data", "pdf", "ocr" ]
title: Convert a scanned pdf to text
tags:
- data
- pdf
- ocr
---
How to translate pdfs to text (results are very poor, and will need lots of corrections).

View File

@@ -1,25 +0,0 @@
#!/bin/bash
pdftoppm -png input.pdf page
for x in *png; do
tesseract -l eng "$x" - >> out.tex
done
rm *png
sed -i -ze :a -e 's/\([a-z]\)\(-\)\n\+\([a-zA-Z]\)/\1\3/g' out.tex
sed -i -ze :a -e 's/\([a-z]\)\n\+\([a-zA-Z]\)/\1 \2/g' out.tex
sed -i -ze :a -e 's/\([A-Z]\){3}\+\n/\1 XYZ/g' out.tex
sed -i -ze :a -e 's/\n\([A-Z]\{3\}\+\)\n/\\section{\1}\n/g' out.tex
sed -i -ze :a -e 's/\([a-z]\)\. \([A-Z]\)/\1\.\n\2/g' out.tex
sed -i 's/“//g' out.tex
sed -i "s/”/''/g" out.tex
sed -i "s//'/g" out.tex
sed -i "s//'/g" out.tex
sed -i "s/\.''/''\./g" out.tex
sed -i "s/ — / -- /g" out.tex
sed -i 's/\$/\\$/g' out.tex
sed -i 's/%/\\%/g' out.tex
sed -i 's/&/\\&/g' out.tex

View File

@@ -1,6 +1,10 @@
---
title: "PDF Metadata Erasure"
tags: [ "metadata", "ghost script", "gs", ".pdf" ]
title: PDF Metadata Erasure
tags:
- metadata
- ghost script
- gs
- pdf
---
You cannot erase pdf metadata with `exiftool` (it only *appends* your changes).

View File

@@ -1,7 +1,10 @@
---
title: "radicale and nginx"
tags: [ "data", "calendar" ]
requires: [ "nginx", "certbot" ]
title: radicale and nginx
tags:
- data
- calendar
requires:
- networking/nginx.md
---
Check before you start:
@@ -41,10 +44,11 @@ You might get it in the `apache` package or similar.
`htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`.
```sh
PASS="$(xkcdpass)"
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users
echo "Your username is $USER"
echo "Your password is $PASS"
pass="$(xkcdpass)"
username=alice
htpasswd -nb ${username} "${pass}" | sudo tee -a /etc/radicale/users
echo "Your username is ${username}"
echo "Your password is ${pass}"
```
Right now, you can't sign into the server except through the localhost, which is pointless.
So now we add a subdomain to `nginx`.
@@ -94,8 +98,8 @@ sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/
Finally, replace the example `DOMAIN` with your actual domain name.
```sh
DOMAIN=whatever.com
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
domain=whatever.com
sudo sed -i "s/DOMAIN/${domain}/g" /etc/nginx/sites-available/radicale
```
(optional: replace that `cal.` prefix with anything else)
@@ -108,7 +112,7 @@ sudo nginx -t
You will almost certainly need a new SSL certificate for the site:
```sh
sudo certbod -d cal.$DOMAIN
sudo certbod -d cal.${domain}
```
Start or restart both services:

View File

@@ -1,6 +1,8 @@
---
title: "Recfiles"
tags: [ "data", "database" ]
title: Recfiles
tags:
- data
- database
---
Create:

View File

@@ -1,7 +1,14 @@
---
title: "Recfile Bibliography for TeX"
tags: [ "data", "database", "recfiles", "tex" ]
requires: [ "Recfiles", "TeX", "Makefile" ]
title: Recfile Bibliography for TeX
tags:
- data
- database
- recfiles
- tex
requires:
- data/recfiles.md
- writing/tex.md
- system/makefiles.md
---
Store your bibliography in a `recfile` database, then extract any part with `make`.

View File

@@ -1,7 +1,11 @@
---
title: "Board Games with Recfiles"
tags: [ "data", "recfiles", "games" ]
requires: "Recfiles"
title: Board Games with Recfiles
tags:
- data
- recfiles
- games
requires:
- data/recfiles.md
---
You can play with a board games database from boardgamegeek.com.

View File

@@ -1,6 +1,11 @@
---
title: "Recfiles Extended Example"
tags: [ "data", "database", "recfiles" ]
title: Recfiles Extended Example
tags:
- data
- database
- recfiles
requires:
- data/recfiles.md
---
## Create
@@ -11,23 +16,23 @@ Make a database for your boardgames, specifying only one field and value:
database=games.rec
n=Name
g=Vojvodina
touch $database
recins -f $n --value $g $database
recsel $database
touch ${database}
recins -f ${n} --value ${g} ${database}
recsel ${database}
```
Insert a few more, with the estimated playtime:
```sh
recins -f Name -v Saboter -f Playtime -v 30 $database
recins -f Name -v Chess -f Playtime -v 30 $database
recins -f Name -v Saboter -f Playtime -v 30 ${database}
recins -f Name -v Chess -f Playtime -v 30 ${database}
```
View all games, or select one by number:
```sh
recsel $database
recsel -n 0 $database
recsel ${database}
recsel -n 0 ${database}
```
Each game should note whether or not you have played it yet, so you can add that field and set the default to `yes`.
@@ -35,14 +40,14 @@ Each game should note whether or not you have played it yet, so you can add that
```sh
f=played
v=yes
recset -f $f -a $v $database
recset -f ${f} -a ${v} ${database}
```
...but the field is wrong, it should have a capital letter:
```sh
new_field=Played
recset -f $f --rename $new_field
recset -f ${f} --rename ${new_field}
```
## Read
@@ -50,20 +55,20 @@ recset -f $f --rename $new_field
Check how many records the database has:
```sh
recinf $database
recinf ${database}
```
Look at just the games you've never played:
```sh
recsel --expression="Played = 'no'" $database
recsel --expression="Played = 'no'" ${database}
```
Print how many, then just print the names:
```sh
recsel -e "Played = 'no'" --count $database
recsel -e "Played = 'no'" --print=Name $database
recsel -e "Played = 'no'" --count ${database}
recsel -e "Played = 'no'" --print=Name ${database}
```
## Update
@@ -74,8 +79,8 @@ To change a game's `Played` field from `no` to `yes`, use `recset` to specify th
num=0
f=Played
value=yes
recsel --number=$num $database
recset --number=$num -f $f --set=$value $database
recsel --number=${num} ${database}
recset --number=${num} -f ${f} --set=${value} ${database}
```
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
@@ -97,22 +102,22 @@ Remove `Played` record from first game:
```sh
num=0
recset --number=$num -f Played --delete $database
recset --number=${num} -f Played --delete ${database}
```
You can comment the line instead of deleting it:
```sh
num=1
recset --number=$num -f Played --delete $database
recsel $database
cat $database
recset --number=${num} -f Played --delete ${database}
recsel ${database}
cat ${database}
```
Delete an entire record:
```sh
num=2
recdel --number=$num $database
recdel --number=${num} ${database}
```

View File

@@ -1,7 +1,11 @@
---
title: "IP Addresses with Recfiles"
tags: [ "data", "recfiles", "games" ]
requires: "Recfiles"
title: IP Addresses with Recfiles
tags:
- data
- recfiles
- games
requires:
- data/recfiles.md
---
## Download the Database

View File

@@ -1,7 +1,12 @@
---
title: "nginx logs with recfiles"
tags: [ "data", "recfiles", "logs" ]
requires: [ "Recfiles", "nginx" ]
title: nginx logs with recfiles
tags:
- data
- recfiles
- logs
requires:
- data/recfiles.md
- networking/nginx.md
---
The standard `nginx` log format has such a lack of consistency or meaning that you might squint your face into a whirlpool making sense of them:

View File

@@ -1,7 +1,10 @@
---
title: "Recfixes"
tags: [ "data", "recfiles" ]
requires: "Recfiles"
title: Recfixes
tags:
- data
- recfiles
requires:
- data/recfiles.md
---
Sometimes `recsel` chokes on a large query, and you need to break the query into chunks with a pipe.

View File

@@ -1,11 +1,14 @@
---
title: "sc-im"
tags: [ "TUI", "data", "spreadsheet", ".csv" ]
requires: [ "vim basics" ]
title: sc-im
tags:
- TUI
- data
- spreadsheet
- csv
requires:
- writing/vim.md
---
- [Sample file](sc-im/sample.sc)
# Basic Commands
## See Cells

View File

@@ -1,6 +1,8 @@
---
title: "Convert Spreadsheets"
tags: [ "data", "sc-im" ]
title: Convert Spreadsheets
tags:
- data
- sc-im
---
Convert between spreadsheet formats with `sc-im`.

View File

@@ -1,38 +0,0 @@
# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
# You almost certainly shouldn't edit it.
newsheet "Sheet1"
movetosheet "Sheet1"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 1
nb_frozen_cols 0
nb_frozen_screenrows 2
nb_frozen_screencols 0
format A 14 1 0
format B 18 2 0
format 0 2
freeze 0
label A0 = "Food by Weight"
leftstring B0 = "No. Meals"
leftstring A1 = "Ajvar"
let A1 = 5
let B1 = A1*$A$10
leftstring A2 = "Apples"
let A2 = 3
let B2 = A2*$A$10
leftstring A3 = "Rocket"
let A3 = 0.2
let B3 = A3*$A$10
leftstring A4 = "Beli Cheese"
let A4 = 1
let B4 = A4*$A$10
leftstring A6 = "Total"
let A6 = @sum(A1:A4)
leftstring B6 = "Total"
let B6 = @sum(B1:B4)
leftstring A7 = "Average"
let A7 = @avg(A1:A4)
leftstring A10 = "Weight of Meal"
let A10 = 0.3
goto A0

View File

@@ -1,7 +1,12 @@
---
title: "Search System"
tags: [ "data", "search", "locate", "plocate" ]
requires: "cron"
title: Search System
tags:
- data
- search
- locate
- plocate
requires:
- system/cron.md
---
You can search every file on the computer instantly by installing `plocate`.
@@ -21,7 +26,7 @@ Once you have the database, you can find nearly any file instantly.
- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg`
- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'`
For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md).
For best results, run `updatedb` regularly, perhaps in [crontab](system/cron.md).
## Search More Places

View File

@@ -1,6 +1,8 @@
---
title: "Search Video Audio"
tags: [ "data", "video" ]
title: Search Video Audio
tags:
- data
- video
---
Check subtitles available:

View File

@@ -1,6 +1,9 @@
---
title: "Sharing Secrets"
tags: [ "data", "death", "secrets", "ssss" ]
title: Sharing Secrets
tags:
- data
- death
- secrets
---
You can share parts of a secret with multiple people, so only some of them need to agree to see the secret.

14
data/soft-serve.md Normal file
View File

@@ -0,0 +1,14 @@
---
title: Soft-Serve
tags:
- data
- git server
- lfs
- TUI
requires:
- data/git.md
- networking/nginx.md
---
- [Soft-Serve with https](soft-serve/soft_https.md)
- [Maintenance](soft-serve/soft_maintenance.md)

View File

@@ -1,7 +1,12 @@
---
title: "Soft Serve through https"
tags: [ "data", "git server", "lfs" ]
requires: [ "git", "nginx" ]
title: Soft Serve through https
tags:
- data
- git server
- lfs
requires:
- data/git.md
- networking/nginx.md
---
## `http` Setup
@@ -36,7 +41,7 @@ git clone http://localhost:23232/${some_repo}.git
### `https` Setup
Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](../../networking/website/nginx.md).
Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](networking/nginx.md).
(replace `${DOMAIN_NAME}` with your domain's name).

View File

@@ -1,7 +1,12 @@
---
title: "Soft Serve Maintenance"
tags: [ "data", "git server", "maintenance" ]
requires: [ "git", "nginx" ]
title: Soft Serve Maintenance
tags:
- data
- git server
- maintenance
requires:
- data/git.md
- networking/nginx.md
---
Over time git repositories become bloated with old data, but never get cleaned.

View File

@@ -1,8 +0,0 @@
---
title: "Soft-Serve"
tags: [ "data", "git server", "lfs", "TUI" ]
requires: [ "git", "nginx" ]
---
- [Soft-Serve with https](soft-serve/soft_https.md)
- [Maintenance](soft-serve/maintenance.md)

View File

@@ -1,6 +1,7 @@
---
title: "sqlite"
tags: [ "data" ]
title: sqlite
tags:
- data
---
Work with a database:

View File

@@ -1,34 +0,0 @@
---
title: "Taskwarrior Contexts"
tags: [ "data", "task" ]
requires: [ "Taskwarrior" ]
---
# Contexts
Set three contexts by their tags:
```sh
task context define work +sa or +hr
```
```sh
task context define study +ed or +void or +rat
```
```sh
task context define home -sa -hr -ed -void -rat
```
Change to the first context.
```sh
task context work
```
Then stop.
```sh
task context none
```

View File

@@ -1,115 +0,0 @@
---
title: "Taskwarrior"
tags: [ "data", "organization" ]
---
Set up the configuration file:
```sh
task
```
Taskwarrior published a new feature to synchronize tasks others, but the feature was not ready.
The server's default installation instructions assume that users pay for hosting services.
All listed providers run proprietary software and actively support genocide.
To ignore the synchronization, tell the configuration file to use a local synchronization file.
```sh
task config sync.local.server_dir
task config data.location ~/.local/state/
```
Add a task:
```sh
task add update linux
```
See which task is next:
```sh
task next
```
Note the id number.
Mark a task as started:
```sh
task start 1
```
Once finished:
```sh
task 1 done
```
# Projects
Add a project:
```sh
task add project:house buy potted plant
task add proj:house.repair buy screwdriver
task add proj:house.repair buy shelf brackets
task add pro:house.paint buy white paint
for t in "buy red paint" "buy black paint" "buy brushes" ; do
task add pro:house.paint $t
done
```
## Summary
```sh
task pro:house sum
task burndown.daily pro:house
```
The summaries will show how fast a project is being completed, and when you can expect it to finish at the present rate.
# Tags
```sh
task add +buy toothbrush
task +buy
```
# Review
View list of tasks completed in the last week:
```sh
task end.after:today-1wk completed
```
# User Defined Attributes
Define a new attribute for tasks called 'size'.
The 'user defined attribute' (UDA) needs a `type` and `label`.
```sh
task config uda.size.type string
task config uda.size.label Size
```
You can also ensure task tasks can only be `large`, `medium`, or `small`, then set a default.
```sh
task config uda.size.values large,medium,small
uda.size.default=medium
```
# Tricks
This command shows tasks I'm most interested in:
```sh
task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
```
The command is long, so `alias` is your friend.

View File

@@ -1,20 +0,0 @@
---
title: "Taskwarrior Configuration"
tags: [ "data", "task" ]
requires: [ "Taskwarrior" ]
---
Show your current config:
```sh
task show
```
Use machine-readable output to make a config file with all configuration keys shown, then make it your configuration file.
```sh
task _show > ${file}
mv ${file} ~/.config/task/taskrc
```

View File

@@ -1,172 +0,0 @@
---
title: "timewarrior"
tags: [ "data", "tracking", "time", "timew" ]
---
# Summaries
Try:
```sh
timew summary :yesterday
```
You can also use :week, :lastweek, :month, :quarter, :year, or a range such as:
```sh
timew summary today to tomorrow
timew today - tomorrow
2018-10-15T06:00 - 2018-10-17T06:00
```
Each of these can gain with the :ids tag.
# Basics
```sh
timew start
timew stop
timew continue
timew summary
timew tags
```
And add ids with:
```sh
timew summary :ids
timew track 10am - 1pm timewarrior
timew track 1pm for 2h walk
```
# Adjusting Timewarrior
First get ids.
```sh
timew summary :ids
```
Then if we're looking at task @2:
```sh
timew move @2 12:00
timew lengthen @2 3mins
```
```sh
time shorten @2 40mins
```
# Forgetting
```sh
timew start 1h ago @4
```
Or if your action actually had a break:
```sh
timew split @8
```
Or maybe not?
```sh
timew join @4 @8
timew @8 delete
```
Start at previous time
```sh
timew start 3pm 'Read chapter 12'
timew start 90mins ago 'Read chapter 12'
```
Cancel currently tracked time.
```sh
timew cancel
```
# Backdated tracking
> timew untag @3
# Hints
* :quit - for automation
* :yes
* :color
* :fill - expand the time to fill out available time
* :adjust - automatically correct overlaps
* :ids - show id numbers
# Times
* :yesterday
* :day
* :week
* :month
* :quarter
* :lastweek
* :lastmonth
* :lastquarter
* :lastyear
# Mistakes
task end.after:2015-05-01 and end.before:2015-05-31 completed
task end.after:today-1wk completed
# Errors with Python3
Replace
> os.system('timew start ' + combined + ' :yes')
with:
> os.system('timew start ' + combined.decode() + ' :yes')
and
> os.system('timew stop ' + combined + ' :yes')
with:
> os.system('timew stop ' + combined.decode() + ' :yes')
# Fixing Errors
```sh
curl -O https://taskwarrior.org/download/timew-dbcorrection.py
```
```sh
python timew-dbcorrections.py
```
# Setup
With taskwarrior installed as well, `locate on-modify-time`, then add it to ~/.task/hooks and make it executable.
This will track the time of any tasks used with [taskwarrior](task.md).

View File

@@ -1,6 +1,10 @@
---
title: "unison"
tags: [ "backups", "synch" ]
title: unison
tags:
- backups
- synch
requires:
- networking/ssh.md
---
Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems).
@@ -14,7 +18,7 @@ Create the `~/.unison` directory on both machines.
Make a job called `backup`:
```sh
JOB=backup
job=backup
```
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
@@ -24,16 +28,16 @@ Here is an example job, which synchronizes the `~/music` directory with a remote
echo "
auto = true
root=$HOME
root=ssh://$USER@$IP_ADDRESS/$HOME
root=ssh://${user}@${ip_address}/$HOME
path=music
ignore=Name *.flac
" > ~/.unison/"$JOB".prf
" > ~/.unison/"${job}".prf
```
Remember to specify `$IP_ADDRESS`
Remember to specify `${ip_address}`
The last command means it will ignore any file with a name ending in `.flac`.
@@ -43,7 +47,7 @@ The first command means this will run but also confirm which files will be delet
Or you can deleted that line in the `.prf` file and run it with a flag:
```sh
unison -batch *backup*.prf
unison -batch ${job}.prf
```
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.

View File

@@ -1,11 +1,14 @@
---
title: "View Torrents"
tags: [ "data", "transmission", "torrenting" ]
title: View Torrents
tags:
- data
- transmission
- torrenting
---
```sh
transmission-show $file.torrent | less
transmission-show ${file}.torrent | less
```
`TRACKERS` shows where transmission will ask who has the torrent, but will probably be out of date.

View File

@@ -1,6 +1,7 @@
---
title: "w3m"
tags: [ "browsers" ]
title: w3m
tags:
- browser
---
Open a search tab:

View File

@@ -1,6 +1,9 @@
---
title: "ssh to phone"
tags: [ "networking", "ssh", "android" ]
title: ssh to phone
tags:
- networking
- ssh
- android
---
1. Install fdroid on phone.

View File

@@ -1,6 +1,9 @@
---
title: "Arch on a Raspberry Pi 4"
tags: [ "distros", "raspberry pi", "rpi" ]
title: Arch on a Raspberry Pi 4
tags:
- distros
- raspberry pi
- rpi
---
The [Official Instructions](https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4) for a Raspberry pi 4 do not allow for working sound from the headphone jack, unless you use the aarch64 Installation.

View File

@@ -1,6 +1,8 @@
---
title: "autologin"
tags: [ "distros", "arch" ]
title: autologin
tags:
- distros
- arch
---
# Automatic Login

View File

@@ -1,7 +1,9 @@
---
title: "Install Arch"
tags: [ "arch" ]
requires: [ "partitions", "time" ]
title: Install Arch
tags:
- arch
requires:
- system/partitions.md
---
Keyboard layout changed.

View File

@@ -1,6 +1,7 @@
---
title: "fonts"
tags: [ "distros" ]
title: fonts
tags:
- distros
---
# Basics

View File

@@ -1,6 +1,10 @@
---
title: "Ach Linux GPU Setup"
tags: [ "arch", "GPU" ]
title: Arch Linux GPU Setup
tags:
- arch
- GPU
requires:
- distros/arch/install_yay.md
---
# Step 1: Multilib

View File

@@ -1,7 +1,10 @@
---
title: "Install yay"
tags: [ "distros", "arch" ]
requirements: [ "pacman" ]
title: Install yay
tags:
- distros
- arch
requires:
- distros/arch/basic_install.md
---
```sh
@@ -15,14 +18,14 @@ The flags are mostly the same as in `pacman`.
But running `yay` without flags will do the update like `yay -Syu` and with package name it will search packages in the AUR and `pacman` repos, and let you choose which to install.
```sh
yay <search_term>
yay ${search_term}
```
Building the package can usually take some time, and after the build it will ask for the `sudo` password.
If you leave, the installation will fail.
To avoid this, you can use the flag `--sudoloop` and enter the sudo password initially and it will loop it until the installation is finished.
To avoid this, you can use the flag `--sudoloop` and enter the `sudo` password initially and it will loop it until the installation is finished.
```sh
yay -S --noconfirm --sudoloop <package_name>
yay -S --noconfirm --sudoloop ${package_name}
```

View File

@@ -1,7 +1,10 @@
---
title: "Arch Maintenance"
tags: [ "arch" ]
requirements: [ "pacman" ]
title: Arch Maintenance
tags:
- arch
requires:
- pacman
- vim
---
# Package Cache

View File

@@ -1,7 +1,9 @@
---
title: "pacman"
tags: [ "distros" ]
requirements: [ "Install Arch" ]
title: pacman
tags:
- distros
requires:
- distros/arch/basic_install.md
---
Packages are kept in /var/cache/pacman/pkg.

View File

@@ -1,7 +1,9 @@
---
title: "pacman - Extras"
tags: [ "distros" ]
requirements: [ "pacman" ]
title: pacman - Extras
tags:
- distros
requires:
- distros/arch/pacman.md
---
## Unattended Actions
@@ -23,7 +25,7 @@ You can tell `pacman` that this is a dependency for another package:
```sh
pacman -S --noconfirm --asdeps <weird music player>
pacman -S --noconfirm --asdeps ${weird_music_player}
```
When you [remove orphaned packages](pacman.md), the package will be automatically uninstalled.

View File

@@ -1,12 +1,15 @@
---
title: "Arch Maintenance with yay"
tags: [ "arch" ]
requirements: [ "Arch Maintenance" ]
title: Arch maintenance with yay
tags:
- arch
- maintenance
requires:
- distros/arch/maintenance.md
---
# Package Cache
Just like `pacman`
Just like `[pacman](distros/arch/pacman.md)` with a couple of extras.
```sh
ls ~/.cache/yay/ | wc -l

View File

@@ -1,15 +1,13 @@
---
title: "apt"
tags: [ "distros" ]
title: apt troubleshooting
tags:
- debian
---
## apt
### Configurations?
Messed up a package's configuration files?
```sh
sudo apt-get purge [thing]
sudo apt-get purge ${package}
```
```sh
@@ -19,16 +17,16 @@ sudo apt autoremove
Check if you still have related things:
```sh
apt search [thing]
apt search ${package}
```
```sh
sudo apt-get install [ thing ]
sudo apt-get install ${package}
```
Still have problems?
```sh
sudo dpgk --force-confmiss -i /var/cache/apt/archives/[thing]
sudo dpgk --force-confmiss -i /var/cache/apt/archives/${package}
```

View File

@@ -1,7 +1,9 @@
---
title: "Aeroplane Mode in Void"
tags: [ "void" ]
title: Aeroplane Mode in Void
tags:
- void
---
Put your device in 'aeroplane' mode (e.g. where no trace of signal leaves it) by turning off Wi-Fi and blue-tooth.
```sh

View File

@@ -1,34 +1,54 @@
---
title: "Void Autologin"
tags: [ "void" ]
title: Void Autologin
tags:
- void
- autologin
---
Make the autologin service:
The virtual terminals are run as services.
Make a new service by making symbolic links to the generic one.
```sh
cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1
login=agetty-autologin
sudo cp -rs /etc/sv/agetty-generic/ /etc/sv/${login}/
```
Copy the configuration file for the `agetty-tty1` service, and add the `--autologin` argument.
```sh
sed "s/--noclear/--autologin ${USER} &/" /etc/sv/agetty-tty1/conf | sudo tee /etc/sv/${login}/conf
```
It should look like this:
```
if [ -x /sbin/agetty -o -x /bin/agetty ]; then
# util-linux specific settings
if [ "${tty}" = "tty1" ]; then
GETTY_ARGS="--noclear"
GETTY_ARGS="--autologin ${your_username} --noclear"
fi
fi
GETTY_ARGS="--autologin [ your username ] --noclear"
BAUD_RATE=38400
TERM_NAME=linux
```
Then stick this at the end of the bashrc:
If you see the actual variable `${USER}` then you probably used the wrong quotes.
Disable the `tty1` service (because the login takes its place).
```sh
# autologin on tty1
if [ -z "$DISPLAY" ] && [ "$(fgconsole)" -eq 1 ]; then
exec startx
fi
sudo touch /etc/sv/agetty-tty1/down
```
Enable your `${login}` service:
```sh
sudo ln -s /etc/sv/${login} /var/service/
```
Reboot.
Pizza party for one.

View File

@@ -1,6 +1,7 @@
---
title: "Brand Name Wallpaper"
tags: [ "void" ]
title: Brand Name Wallpaper
tags:
- void
---
To automatically stick the logo onto your background, do these commands in the directory.

View File

@@ -1,6 +1,7 @@
---
title: "extrace"
tags: [ "void" ]
title: extrace
tags:
- void
---
Monitor all processes:

View File

@@ -1,6 +1,8 @@
---
title: "jenkins"
tags: [ "void", "build" ]
title: jenkins
tags:
- void
- build
---
# Jenkins on Void

View File

@@ -1,6 +1,8 @@
---
title: "Laptops with Void Linux"
tags: [ "void", "laptop" ]
title: Laptops with Void Linux
tags:
- void
- laptop
---
Install and enable `tlp`.

View File

@@ -1,6 +1,8 @@
---
title: "Void locale"
tags: [ "void", "locale" ]
title: Void locale
tags:
- void
- locale
---
Check the current locales:

View File

@@ -1,6 +1,7 @@
---
title: "sv"
tags: [ "void" ]
title: sv
tags:
- void
---
# List Services

View File

@@ -1,6 +1,7 @@
---
title: "Void Linux Basics"
tags: [ "void" ]
title: Void Linux Basics
tags:
- void
---
# Updates
@@ -53,9 +54,8 @@ brightnessctl s 10%-
brightnessctl s 10%+
```
# Other Tricks
# Related
- [autologin](autologin.md)
- [services](sv.md)
- [wifi](../../networking/wpa_supplicant.md)
- [autologin](distros/void/autologin.md)
- [services](distros/void/sv.md)

View File

@@ -1,6 +1,7 @@
---
title: "xbps"
tags: [ "void" ]
title: xbps
tags:
- void
---
## Search

155
example.rec Normal file
View File

@@ -0,0 +1,155 @@
%rec: example
%key: filename
%type: note line
filename: default.service
bin: systemd
usage: mv {{filename}} /usr/lib/systemd/system/
+ systemctl daemon-reload
+ systemctl enable --now {{filename}}
note: Basic systemd service file
content: [Unit]
+
+ Description={{script}}
+
+ [Service]
+
+ ExecStart=/home/{{user}}/.local/bin/{{script}}.sh
+
+ Restart=always
+
+ Type=simple
+
+ User={{user}}
+
+ Group={{group}}
+
+ [Install]
+
+ WantedBy=multi-user.target
+
+ Alias=test.service
+
filename: food.sc
bin: sc-im
usage: {{bin}} {{filename}}
note: Basic sc-im example of adding and averaging
content: # This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
+ # You almost certainly shouldn't edit it.
+
+ newsheet "Food"
+ movetosheet "Food"
+ offscr_sc_cols 0
+ offscr_sc_rows 0
+ nb_frozen_rows 1
+ nb_frozen_cols 0
+ nb_frozen_screenrows 2
+ nb_frozen_screencols 0
+ format A 24 1 0
+ format B 13 2 0
+ format 0 2
+ format 4 2
+ format 10 2
+ freeze 0
+ label A0 = "Food by Weight"
+ leftstring B0 = "No. Meals"
+ leftstring A1 = "Ajvar"
+ let A1 = 5
+ let B1 = A1*$A$10
+ leftstring A2 = "Apples"
+ let A2 = 3
+ let B2 = A2*$A$10
+ leftstring A3 = "Rocket"
+ let A3 = 0.2
+ let B3 = A3*$A$10
+ leftstring A4 = "Beli Cheese"
+ let A4 = 1
+ let B4 = A4*$A$10
+ leftstring A6 = "Total"
+ let A6 = @sum(A1:A4)
+ leftstring B6 = "Total"
+ let B6 = @sum(B1:B4)
+ leftstring A7 = "Average"
+ let A7 = @avg(A1:A4)
+ leftstring A10 = "Weight of Meal"
+ let A10 = 0.3
+ pad 4 A0:A4
+ pad 2 B0:B4
+ pad 4 A6:A8
+ pad 2 B6
+ pad 4 A10
+ goto A10
filename: lowdown.mk
bin: make
usage: {{bin}} -f {{filename}} example
content: output: all
+
+ .PHONY: example
+ example: html/foot.html html/head.html
+ mkdir -p articles/
+ fortune > articles/fort_1.md
+ fortune > articles/fort_2.md
+
+ HTML = $(patsubst articles/%.md,public/%.html,$(wildcard articles/*.md))
+
+ $(HTML): public/ articles/ $(wildcard html/*)
+
+ html/head.html:
+ @mkdir $(@D)
+ echo '<head> Something about CSS probably </head>' > $@
+ echo '<body>' >> $@
+
+ html/foot.html: html/head.html
+ echo '</body>' >> $@
+
+ public/%.html : articles/%.md
+ cat html/head.html > $@
+ lowdown $< >> $@
+ cat html/foot.html >> $@
+
+ .PHONY: all
+ all : $(HTML)
+
+ articles/:
+ mkdir $@
+
+ public/:
+ mkdir $@
+
+ clean :
+ rm -rf public html
filename: Makefile
bin: make
usage: make
content: ### Variables
+
+ PAGER ?= $(shell command -v mdless bat less | head -1 )
+ EDITOR ?= vi
+
+ requirements += lowdown
+
+ ### Dependencies
+
+ out: help
+
+ ### Patterns
+
+
+ ### Phonies
+
+ .PHONY: help
+ help:
+ @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
+ sort | \
+ column -s ':' -t
+
+ .PHONY: check
+ check: ## Check you have the required dependencies
+ @$(foreach dep, $(requirements), type $(dep) >/dev/null || echo "Install $(dep)." ; )
+
+ .PHONY: clean
+ clean: ## Remove generated files.
+ $(RM) $(defaults)

View File

@@ -1,6 +1,8 @@
---
title: "brightness"
tags: [ "hardware", "laptop" ]
title: brightness
tags:
- hardware
- laptop
---
# Brightness

View File

@@ -1,6 +1,8 @@
---
title: "keyboard"
tags: [ "keyboard", "vim" ]
title: keyboard
tags:
- keyboard
- vim
---
# System-Wide Capslock and Escape Swap

View File

@@ -1,6 +1,7 @@
---
title: "monitor"
tags: [ "hardware" ]
title: monitor
tags:
- hardware
---
See screen size

View File

@@ -1,10 +1,12 @@
---
title: "printers"
tags: [ "hardware" ]
title: printers
tags:
- hardware
---
# Cups: The Common Unix Printing System
Configure cups at /etc/cups/supsd.conf, or visit the local webpage at http://localhost:631 if you want to use the Apple interface, otherwise, it's the printing daemon.
Configure cups at `/etc/cups/supsd.conf`, or visit the local webpage at http://localhost:631 if you want to use the Apple interface, otherwise, it's the printing daemon.
# The Printing Daemon

View File

@@ -4,3 +4,5 @@
```{{shell}}
{{cmd}}
```
{{note}}

View File

@@ -1,6 +1,11 @@
---
title: "Agate on Arch Linux"
tags: [ "networking", "arch", "gemini" ]
title: Agate on Arch Linux
tags:
- networking
- arch
- gemini
requires:
- distros/arch/install_yay.md
---
Docs are [here](https://github.com/mbrubeck/agate).
@@ -51,7 +56,7 @@ agate --content $GEMDIR --certs $GEMDIR/.certs \
Once that works, it's time to make a service file; select any name for it:
`SVFILE=st`
`${svfile}=st`
```
echo "
@@ -60,27 +65,27 @@ CERT=--certs $GEMDIR/.certs
ADDR=--addr [::]:1965 --addr 0.0.0.0:1965
HOSTNAME=--hostname $DOMAIN1 --hostname $DOMAIN2
LANG=--lang $LANG
" > $SVFILE.conf
" > ${svfile}.conf
```
Check the service file has all those variables and looks right:
`cat $SVFILE.conf`
`cat ${svfile}.conf`
Now move it into the agate config directory:
`mv $SVFILE.conf /etc/agate/`
`mv ${svfile}.conf /etc/agate/`
And finally, start the service:
```
systemctl daemon-reload
systemctl enable --now agate@$SVFILE.conf
systemctl enable --now agate@${svfile}.conf
```
Your Gemini capsule should be available, and you should be able to see any access in the logs:
```
journalctl -xeu agate@$SVFILE.conf
journalctl -xeu agate@${svfile}.conf
```

View File

@@ -1,6 +1,9 @@
---
title: "Mapping the Net"
tags: [ "networking", "graph", "fun" ]
title: Mapping the Net
tags:
- networking
- graph
- fun
---
Find the path to a domain:

View File

@@ -1,6 +1,8 @@
---
title: "dns"
tags: [ "networking", "host" ]
title: DNS Record List
tags:
- networking
- host
---
| Record | Type | Example |
@@ -10,10 +12,9 @@ tags: [ "networking", "host" ]
| CNAME | Alternative Address | "$domain".rs, "$subdomain.$domain".com |
| NS | Nameserver | ns1.fastname.com |
| MX | Email server | "$domain".com |
| TXT | Literally anything,including ownership of a domain | |
| | | |
| TXT | Literally anything | "drunk giraffes can't spell" |
Query a host with the `host` command.
Query a host's IP and email handlers with the `host` command.
```sh
host $domain.$tld

View File

@@ -1,7 +1,9 @@
---
title: "fail2ban"
tags: [ "networking" ]
requires: [ "ssh" ]
title: fail2ban
tags:
- networking
requires:
- networking/ssh.md
---
# SSH Daemon Jail

Some files were not shown because too many files have changed in this diff Show More