Compare commits

...

37 Commits

Author SHA1 Message Date
andonome 13b3d7a839 Sort commands by shell then bin 2026-05-06 13:53:42 +02:00
andonome d2b2bdf2b3 CMD: uncompress a PDF 2026-05-06 13:43:48 +02:00
andonome c551e7220a CMD: read info with vim 2026-05-05 14:32:46 +02:00
andonome 968236e4bb CMD: background jobs 2026-05-05 09:58:46 +02:00
andonome 6d00283fe2 cmd: show test in journal vacuum 2026-05-01 14:21:48 +02:00
andonome a2c3521c48 add stopping email scams 2026-05-01 13:13:48 +02:00
andonome 0a824f10c8 cmd: rephrase text for shell formatting 2026-04-30 20:12:59 +02:00
andonome 8bb26740b0 edit users and groups directly 2026-04-30 15:33:23 +02:00
andonome 0d053e9a7d cmd: return terminal after ssh freeze 2026-04-30 13:06:14 +02:00
andonome ec3c355ac4 remove necessity to recompile command-lists 2026-04-30 13:03:31 +02:00
andonome 2a010a777e make vim links absolute 2026-04-30 00:53:34 +02:00
andonome 12064196d2 fix variable syntax 2026-04-30 00:50:02 +02:00
andonome 68734cfd1b include markdown as a variable 2026-04-29 17:42:11 +02:00
andonome 019736de05 place template makefile 2026-04-29 17:39:37 +02:00
andonome 76be2fbd3c fix links 2026-04-29 14:35:17 +02:00
andonome 34ef924a09 typo 2026-04-29 12:49:32 +02:00
andonome 793d32164e rename pdf to text 2026-04-28 23:56:37 +02:00
andonome 39a7317cc5 note: retitle gpg with vim 2026-04-28 19:58:46 +02:00
andonome c06884d434 note: csv to markdown in vim 2026-04-28 18:11:54 +02:00
andonome c25f55054b note: format markdown in vim 2026-04-28 18:01:52 +02:00
andonome 73f8dc0feb reformat tables 2026-04-28 17:40:08 +02:00
andonome a4ffedcb6b note: place arch gpu required tags 2026-04-28 13:23:25 +02:00
andonome b27ccb33ab note: how to send email 2026-04-28 02:10:39 +02:00
andonome 95b753549b note useage in lowdown.mk example 2026-04-27 17:20:35 +02:00
andonome c586062552 git commit -p 2026-04-27 17:12:52 +02:00
andonome 0d25236b27 reword column examples 2026-04-27 17:12:29 +02:00
andonome d53ca311c1 split shell tips into bash and shell 2026-04-27 17:08:41 +02:00
andonome 3a7a92de14 edit editors 2026-04-27 15:21:14 +02:00
andonome 53eba915b3 explain shell-like writing in readme 2026-04-27 13:35:27 +02:00
andonome 6a33521f33 edit shell tips 2026-04-27 13:35:22 +02:00
andonome 319ae8df79 clean up old formatting 2026-04-27 13:13:22 +02:00
andonome ea4f44e096 clean up networking 2026-04-27 12:59:27 +02:00
andonome 1994d9fbb3 move git cleanup 2026-04-27 12:41:06 +02:00
andonome cc811fc025 edit virtualization setup 2026-04-27 12:34:26 +02:00
andonome c2f72aed84 only ignore db.rec 2026-04-27 12:26:43 +02:00
andonome 2e305b3604 clean up cmd tags 2026-04-27 12:02:33 +02:00
andonome b2ded0008c cmd: git request-pull 2026-04-27 12:01:22 +02:00
46 changed files with 989 additions and 677 deletions
+6 -3
View File
@@ -5,6 +5,8 @@ PAGER ?= less -Ri
READER != command -v mdless bat glow less more pg | head -1 READER != command -v mdless bat glow less more pg | head -1
FZF != command -v fzf sk | head -1 FZF != command -v fzf sk | head -1
markdown = $(wildcard */*.md */*/*.md)
ifeq "$(FZF)" "" ifeq "$(FZF)" ""
$(info Install fzf) $(info Install fzf)
endif endif
@@ -32,7 +34,7 @@ default += .dbs/map.fmt
include cmd.mk include cmd.mk
.dbs/head.rec: | .dbs/ $(lists) .dbs/head.rec: | .dbs/
printf '%s\n' '%rec: guide' > $@ printf '%s\n' '%rec: guide' > $@
printf '%s\n' '%key: path' >> $@ printf '%s\n' '%key: path' >> $@
printf '%s\n' '%type: requires rec guide' >> $@ printf '%s\n' '%type: requires rec guide' >> $@
@@ -40,7 +42,7 @@ include cmd.mk
printf '%s\n' '%type: wordcount int' >> $@ printf '%s\n' '%type: wordcount int' >> $@
printf '%s\n\n' '%sort: wordcount' >> $@ printf '%s\n\n' '%sort: wordcount' >> $@
.dbs/new.rec: $(wildcard */*.md */*/*.md) | .dbs/head.rec .dbs/new.rec: $(markdown) | .dbs/head.rec
$(info Updating: $?) $(info Updating: $?)
grep -q guide $@ 2>/dev/null || cp $| $@ grep -q guide $@ 2>/dev/null || cp $| $@
@-$(foreach entry, $?, \ @-$(foreach entry, $?, \
@@ -68,6 +70,7 @@ include cmd.mk
sed '/^%/d' $^ | recsel -G path | recsel -U >> $@ sed '/^%/d' $^ | recsel -G path | recsel -U >> $@
default += db.rec default += db.rec
ignored += db.rec
db.rec: command.rec .dbs/notes.rec db.rec: command.rec .dbs/notes.rec
recinf -d $< > $@ recinf -d $< > $@
echo '' >> $@ echo '' >> $@
@@ -75,7 +78,7 @@ db.rec: command.rec .dbs/notes.rec
$(info Making main database: $@) $(info Making main database: $@)
.git/info/exclude: $(default) .git/info/exclude: $(ignored)
@echo $^ | tr ' ' '\n' > $@ @echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude default += .git/info/exclude
+10 -5
View File
@@ -38,11 +38,6 @@ The output is a couple of lines of code, with changeable components as variables
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"' alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
``` ```
### Guides
The notes are mostly written like a heavily commented script.
Most are setup guides.
### The Function ### The Function
Running `make function` outputs a shell function which searches through this Running `make function` outputs a shell function which searches through this
@@ -133,6 +128,16 @@ grep ls --color=always $HISTFILE | $PAGER
Now we can see what can be changed. Now we can see what can be changed.
### 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 ### Show, Don't Tell
Articles should say what to type, not the output. Articles should say what to type, not the output.
+1 -1
View File
@@ -41,7 +41,7 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
## Automatically Sign In ## 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 ${name}@${host} eval_password pass *xmpp* /account set ${name}@${host} eval_password pass *xmpp*
+76
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
```
-5
View File
@@ -2,8 +2,6 @@
cmds != recsel command.rec -t command -G bin -CP bin | sort -u cmds != recsel command.rec -t command -G bin -CP bin | sort -u
lists = $(patsubst %,lists/%.md, $(cmds)) 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 \ get_tags = recsel -t $(basename $<) $< -G bin \
-e 'bin = "$(1)"' -U -CP tag,bin | \ -e 'bin = "$(1)"' -U -CP tag,bin | \
@@ -20,9 +18,6 @@ $(lists): lists/%.md: command.rec | lists/
@printf '%s\n' '---' >> $@ @printf '%s\n' '---' >> $@
@$(call list_commands,$(basename $(notdir $@))) >> $@ @$(call list_commands,$(basename $(notdir $@))) >> $@
.PHONY: cmd
cmd: $(lists) ## Big lists of commands
.PHONY: function .PHONY: function
function: ## Output a search function for .bashrc function: ## Output a search function for .bashrc
${MAKE} --silent --touch query ${MAKE} --silent --touch query
+425 -318
View File
@@ -1,234 +1,20 @@
%rec: command %rec: command
%doc: shell command examples %doc: shell command examples
%type: aim line %type: aim,bin line
%allowed: aim cmd bin tag note shell %allowed: aim cmd bin tag note shell
%unique: shell %unique: shell
%sort: shell bin
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`)
cmd: column -ts: /etc/passwd
shell: sh
bin: column
tag: format
aim: Sort lines 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: Sort lines 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`
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
shell: sh
bin: qrencode
tag: qr
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}
shell: sh
bin: qrencode
tag: qr
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 aim: Roll a die
cmd: echo $(( RANDOM % 6+1 )) cmd: echo $(( RANDOM % 6+1 ))
shell: bash shell: bash
tag: random tag: random
aim: Remotely edit a file with vim aim: Decode a URL with function
cmd: vim scp://${server}/~/${file} cmd: urldecode() { echo -e "${@//%/\\x}"; }
cmd: vim scp://${user}@${server}:${port}//${path}/${file} + urldecode "${magnet}"
shell: sh tag: web
bin: vim shell: bash
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: Follow the `ssh` daemon service
cmd: journalctl -f -u sshd
shell: sh
bin: journalctl
tag: system
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 journal's size to 2 gigabytes
cmd: journalctl --vacuum-size=2G
shell: sh
bin: journalctl
tag: system
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
tag: system
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 variable for shell input
cmd: printf "%q\n" "${variable}"
bin: printf
tag: xargs
tag: stdout
aim: Find your public IP address aim: Find your public IP address
cmd: dig +short myip.opendns.com @resolver$((RANDOM % 4 + 1)).opendns.com cmd: dig +short myip.opendns.com @resolver$((RANDOM % 4 + 1)).opendns.com
@@ -251,88 +37,69 @@ bin: groff
bin: man bin: man
tag: markdown 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 aim: Rotate a video
cmd: ffmpeg -i "${input}" -vf "transpose=1" "${out.mov}" cmd: ffmpeg -i "${input}" -vf "transpose=1" "${out.mov}"
note: note:
+ | No. | Degrees | Flip | + | No. | Degrees | Flip |
+ |:---:|:-------:|:---------------------------------------| + |:---:|:-------:|:---------------------------------------------|
+ | 0 | 90 Counterclockwise and verfical flip (default) | + | 0 | 90 | Counterclockwise and verfical flip (default) |
+ | 1 | 90 Clockwise | + | 1 | 90 | Clockwise |
+ | 2 | 90 CounterClockwise | + | 2 | 90 | CounterClockwise |
+ | 3 | 90Clockwise and vertical flip | + | 3 | 90 | Clockwise and vertical flip |
tag: vision tag: vision
tag: video tag: video
shell: sh shell: sh
aim: Put output into columns
cmd: ip a | grep inet | column -ts' '
shell: sh
bin: column
tag: format
aim: Reformat user accounts with an explicit separator (`-s`)
cmd: column -ts: /etc/passwd
shell: sh
bin: column
tag: format
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: 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 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: 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: Translate a media file to a new type aim: Translate a media file to a new type
cmd: ffmpeg -formats cmd: ffmpeg -formats
+ ffmpeg -i ${input} ${output} + ffmpeg -i ${input} ${output}
@@ -359,7 +126,6 @@ tag: vision
tag: video tag: video
shell: sh shell: sh
aim: Convert video to audio aim: Convert video to audio
cmd: ffmpeg -i ${input}.mp4 -vn ${output}.mp3 cmd: ffmpeg -i ${input}.mp4 -vn ${output}.mp3
bin: ffmpeg bin: ffmpeg
@@ -375,7 +141,6 @@ bin: ffmpeg
tag: vision tag: vision
shell: sh shell: sh
aim: Change resolution aim: Change resolution
cmd: ffmpeg -i ${input}.mp4 -filter:v scale=1280:720 -c:a copy ${output}.mp4 cmd: ffmpeg -i ${input}.mp4 -filter:v scale=1280:720 -c:a copy ${output}.mp4
bin: ffmpeg bin: ffmpeg
@@ -421,6 +186,60 @@ bin: ffmpeg
tag: vision tag: vision
shell: sh shell: sh
aim: Quickly find and open run-command files
cmd: alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | fzf)"'
shell: sh
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.
shell: sh
bin: fzf
tag: comfy
aim: Email a pull request which points to your git server
tag: git
shell: sh
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: 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: Clean up a bloated git repo
cmd: git fsck --full
+ git gc --prune=now --aggressive
+ git repack
bin: git
tag: maintenance
shell: sh
aim: Search for a short word
cmd: grep "\b${word}\b" ${file}
shell: sh
bin: grep
tag: search
aim: Extract words in quotes
cmd: grep -o "\b${word}\b" ${file}
shell: sh
bin: grep
tag: search
aim: Convert a web page to markdown aim: Convert a web page to markdown
cmd: curl -sL "${url}" | html2markdown > "${file}}".md cmd: curl -sL "${url}" | html2markdown > "${file}}".md
cmd: curl -sL "${url}" | html2text > "${file}}".md cmd: curl -sL "${url}" | html2text > "${file}}".md
@@ -431,25 +250,313 @@ tag: writing
tag: web tag: web
shell: sh shell: sh
aim: Decode a URL with function aim: Run commands in background
cmd: urldecode() { echo -e "${@//%/\\x}"; } cmd: du -sh .* | sort -h | tail &
+ urldecode "${magnet}" cmd: jobs
tag: web cmd: grep -ri password /etc/ &
shell: bash cmd: jobs
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 shell: sh
bin: jobs
tag: shell
tag: comfy
aim: Stop background command having output
cmd: disown
note: The command will continue as it was. You can see it with `top`.
shell: sh
bin: jobs
tag: shell
tag: comfy
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: Follow the `ssh` daemon service
cmd: journalctl -f -u sshd
shell: sh
bin: journalctl
tag: system
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 jpg to png
cmd: magick ${input}.jpg ${output}.png
shell: sh
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
shell: sh
bin: magick
tag: vision
aim: Reduce png size
cmd: magick ${input}.png png8:${output}.png
shell: sh
bin: magick
tag: vision
aim: Invert jpg colours
cmd: magick ${input}.jpg ${output}.jpg -negate
shell: sh
bin: magick
tag: vision
aim: Make jpg smaller
cmd: magick ${input}.jpg -resize 25% ${output}.jpg
shell: sh
bin: magick
tag: vision
aim: Trim images to border
cmd: magick -trim ${image}.png ${output}.png
shell: sh
bin: magick
tag: vision
aim: Make the white of an image transparent
cmd: magick -transparent white -fuzz 10% ${input}.png ${output}.png
shell: sh
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
shell: sh
bin: magick
tag: vision
aim: Convert every jpg in directory to png
cmd: mogrify -format png *.jpg
shell: sh
bin: magick
tag: vision
aim: Convert from jpg to svg
cmd: magick -flatten ${input}.jpg ${output}.ppm
+ potrace -s ${output}.ppm -o ${svgout}.svg
shell: sh
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
shell: sh
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}
shell: sh
bin: magick
tag: vision
tag: memes
aim: Convert markdown table to csv
cmd: mlr --imarkdown --ocsv cat ${file}.md
shell: sh
bin: mlr
tag: csv
tag: markdown
tag: data
aim: Convert a csv file to markdown
cmd: mlr --icsv --omd cat ${file}.csv
shell: sh
bin: mlr
tag: csv
tag: markdown
aim: Hard reset ntp service
cmd: sudo ntpd -q -g -x -n
shell: sh
bin: ntpd
tag: time
tag: system
aim: Uncompress a PDF
cmd: pdftk ${input}.pdf output ${output}.pdf uncompress
shell: sh
bin: pdftk
tag: pdf
tag: compression
aim: Reformat text for shell input
cmd: printf "%q\n" "${text}"
shell: sh
bin: printf
tag: xargs
tag: stdout
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
cmd: qrencode -t ansi "Hello World"
shell: sh
bin: qrencode
tag: qr
aim: Read a QR Code image
cmd: zbarimg ${file}
shell: sh
bin: qrencode
tag: qr
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: Get back terminal after ssh freezes remote machine
cmd: <Return>~.
shell: sh
bin: ssh
tag: system
tag: comfy
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: 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: Read info files with vim
cmd: info ()
+ {
+ [ -n "$1" ] && file="${1}" || file="$(ls /usr/share/info/ | sed 's/\.info.gz$//' | fzf )";
+ file="$(ls /usr/share/info/"$file"* | fzf -1 )"
+ vim "$file"
+ }
shell: sh
bin: vim
bin: info
tag: documentation
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: 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
+6 -6
View File
@@ -10,7 +10,7 @@ tags:
Combine many files and directories into a single t-archive file. Combine many files and directories into a single t-archive file.
```sh ```sh
tar cf "$ARCHIVE".tar $DIR tar cf "${archive}".tar ${dir}
``` ```
You can remember this with the mnemonic '*C*reate *F*ile'. You can remember this with the mnemonic '*C*reate *F*ile'.
@@ -18,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. It's often better to tell tar which path to start from using the `-C` flag.
```sh ```sh
tar cf "$ARCHIVE".tar -C /etc/ nginx tar cf "${archive}".tar -C /etc/ nginx
``` ```
Check the contents of your archive with: Check the contents of your archive with:
```sh ```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. If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
@@ -33,7 +33,7 @@ Instead, you can store the target in a variable:
```sh ```sh
files=$(ls /etc/nginx) files=$(ls /etc/nginx)
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file tar cf "${archive}".tar -C /etc/nginx/ $file
``` ```
# Extract # Extract
@@ -41,7 +41,7 @@ tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
Extract the tar archive with Extract the tar archive with
```sh ```sh
tar xf "$ARCHIVE".tar tar xf "${archive}".tar
``` ```
You can remember this with the mnemonic 'e*X*tract *F*ile'. You can remember this with the mnemonic 'e*X*tract *F*ile'.
@@ -51,7 +51,7 @@ You can remember this with the mnemonic 'e*X*tract *F*ile'.
Create a zip-compressed archive with the `z` flag. Create a zip-compressed archive with the `z` flag.
```sh ```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'. You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.
-22
View File
@@ -1,22 +0,0 @@
---
title: Clean up a bloated git repo
tags:
- data
- setup
requires:
- data/git.md
---
```sh
git fsck --full
```
```sh
git gc --prune=now --aggressive
```
```sh
git repack
```
+1 -1
View File
@@ -132,7 +132,7 @@ Refreshing keys will tell you if some key you have contains a signature from som
gpg --refresh-keys 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. 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 # Export
+1 -1
View File
@@ -1,5 +1,5 @@
--- ---
title: Edit gpg encrypted files easily title: Edit gpg encrypted files with vim
tags: tags:
- vim - vim
- data - data
+16 -7
View File
@@ -8,7 +8,7 @@ requires:
- data/gpg.md - data/gpg.md
--- ---
Setup [gpg](gpg.md) keys. Setup [gpg](data/gpg.md) keys.
Show your gpg secret it: Show your gpg secret it:
@@ -19,28 +19,37 @@ gpg --list-secret-keys
Then use the id number under `sec` to make a pass repo: Then use the id number under `sec` to make a pass repo:
```sh ```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 ```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 ```sh
pass $WEBSITE pass ${website}
``` ```
To insert a multi-line password, e.g. with a login name: To insert a multi-line password, e.g. with a login name:
```sh ```sh
pass add -m $WEBSITE pass add -m ${website}
``` ```
Remove a password: Remove a password:
```sh ```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}
```
+1 -1
View File
@@ -1,5 +1,5 @@
--- ---
title: pdf to txt title: Convert a scanned pdf to text
tags: tags:
- data - data
- pdf - pdf
+8 -7
View File
@@ -44,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`. `htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`.
```sh ```sh
PASS="$(xkcdpass)" pass="$(xkcdpass)"
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users username=alice
echo "Your username is $USER" htpasswd -nb ${username} "${pass}" | sudo tee -a /etc/radicale/users
echo "Your password is $PASS" 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. Right now, you can't sign into the server except through the localhost, which is pointless.
So now we add a subdomain to `nginx`. So now we add a subdomain to `nginx`.
@@ -97,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. Finally, replace the example `DOMAIN` with your actual domain name.
```sh ```sh
DOMAIN=whatever.com domain=whatever.com
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale sudo sed -i "s/DOMAIN/${domain}/g" /etc/nginx/sites-available/radicale
``` ```
(optional: replace that `cal.` prefix with anything else) (optional: replace that `cal.` prefix with anything else)
@@ -111,7 +112,7 @@ sudo nginx -t
You will almost certainly need a new SSL certificate for the site: You will almost certainly need a new SSL certificate for the site:
```sh ```sh
sudo certbod -d cal.$DOMAIN sudo certbod -d cal.${domain}
``` ```
Start or restart both services: Start or restart both services:
+20 -20
View File
@@ -16,23 +16,23 @@ Make a database for your boardgames, specifying only one field and value:
database=games.rec database=games.rec
n=Name n=Name
g=Vojvodina g=Vojvodina
touch $database touch ${database}
recins -f $n --value $g $database recins -f ${n} --value ${g} ${database}
recsel $database recsel ${database}
``` ```
Insert a few more, with the estimated playtime: Insert a few more, with the estimated playtime:
```sh ```sh
recins -f Name -v Saboter -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 recins -f Name -v Chess -f Playtime -v 30 ${database}
``` ```
View all games, or select one by number: View all games, or select one by number:
```sh ```sh
recsel $database recsel ${database}
recsel -n 0 $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`. Each game should note whether or not you have played it yet, so you can add that field and set the default to `yes`.
@@ -40,14 +40,14 @@ Each game should note whether or not you have played it yet, so you can add that
```sh ```sh
f=played f=played
v=yes 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: ...but the field is wrong, it should have a capital letter:
```sh ```sh
new_field=Played new_field=Played
recset -f $f --rename $new_field recset -f ${f} --rename ${new_field}
``` ```
## Read ## Read
@@ -55,20 +55,20 @@ recset -f $f --rename $new_field
Check how many records the database has: Check how many records the database has:
```sh ```sh
recinf $database recinf ${database}
``` ```
Look at just the games you've never played: Look at just the games you've never played:
```sh ```sh
recsel --expression="Played = 'no'" $database recsel --expression="Played = 'no'" ${database}
``` ```
Print how many, then just print the names: Print how many, then just print the names:
```sh ```sh
recsel -e "Played = 'no'" --count $database recsel -e "Played = 'no'" --count ${database}
recsel -e "Played = 'no'" --print=Name $database recsel -e "Played = 'no'" --print=Name ${database}
``` ```
## Update ## Update
@@ -79,8 +79,8 @@ To change a game's `Played` field from `no` to `yes`, use `recset` to specify th
num=0 num=0
f=Played f=Played
value=yes value=yes
recsel --number=$num $database recsel --number=${num} ${database}
recset --number=$num -f $f --set=$value $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`. Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
@@ -102,22 +102,22 @@ Remove `Played` record from first game:
```sh ```sh
num=0 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: You can comment the line instead of deleting it:
```sh ```sh
num=1 num=1
recset --number=$num -f Played --delete $database recset --number=${num} -f Played --delete ${database}
recsel $database recsel ${database}
cat $database cat ${database}
``` ```
Delete an entire record: Delete an entire record:
```sh ```sh
num=2 num=2
recdel --number=$num $database recdel --number=${num} ${database}
``` ```
-2
View File
@@ -9,8 +9,6 @@ requires:
- writing/vim.md - writing/vim.md
--- ---
- [Sample file](sc-im/sample.sc)
# Basic Commands # Basic Commands
## See Cells ## See Cells
+1 -1
View File
@@ -26,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 jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg`
- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'` - 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 ## Search More Places
+1 -1
View File
@@ -41,7 +41,7 @@ git clone http://localhost:23232/${some_repo}.git
### `https` Setup ### `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). (replace `${DOMAIN_NAME}` with your domain's name).
+3 -1
View File
@@ -1,8 +1,10 @@
--- ---
title: Ach Linux GPU Setup title: Arch Linux GPU Setup
tags: tags:
- arch - arch
- GPU - GPU
requires:
- distros/arch/install_yay.md
--- ---
# Step 1: Multilib # Step 1: Multilib
+3 -4
View File
@@ -54,9 +54,8 @@ brightnessctl s 10%-
brightnessctl s 10%+ brightnessctl s 10%+
``` ```
# Other Tricks # Related
- [autologin](autologin.md) - [autologin](distros/void/autologin.md)
- [services](sv.md) - [services](distros/void/sv.md)
- [wifi](../../networking/wpa_supplicant.md)
+34 -1
View File
@@ -83,7 +83,7 @@ content: # This data file was generated by the Spreadsheet Calculator Improvised
filename: lowdown.mk filename: lowdown.mk
bin: make bin: make
usage: {{bin}} -f {{filename}} usage: {{bin}} -f {{filename}} example
content: output: all content: output: all
+ +
+ .PHONY: example + .PHONY: example
@@ -120,3 +120,36 @@ content: output: all
+ +
+ clean : + clean :
+ rm -rf public html + 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)
+2 -1
View File
@@ -3,9 +3,10 @@ title: printers
tags: tags:
- hardware - hardware
--- ---
# Cups: The Common Unix Printing System # 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 # The Printing Daemon
@@ -12,7 +12,7 @@ tags:
| CNAME | Alternative Address | "$domain".rs, "$subdomain.$domain".com | | CNAME | Alternative Address | "$domain".rs, "$subdomain.$domain".com |
| NS | Nameserver | ns1.fastname.com | | NS | Nameserver | ns1.fastname.com |
| MX | Email server | "$domain".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's IP and email handlers with the `host` command. Query a host's IP and email handlers with the `host` command.
+1
View File
@@ -3,6 +3,7 @@ title: rclone
tags: tags:
- networking - networking
- synch - synch
- backup
--- ---
The manpage's 'Synopsis' provides a fast reference. The manpage's 'Synopsis' provides a fast reference.
``` ```
+1
View File
@@ -3,6 +3,7 @@ title: Download Website
tags: tags:
- networking - networking
- scraping - scraping
- web
--- ---
```sh ```sh
+5 -4
View File
@@ -2,29 +2,30 @@
title: Download videos title: Download videos
tags: tags:
- scraping - scraping
- video
--- ---
Install `yt-dlp`. Install `yt-dlp`.
```sh ```sh
yt-dlp --write-auto-sub *<URL>* yt-dlp --write-auto-sub ${url}
``` ```
It will default to English, but you can specify another language with the flag --sub-lang: It will default to English, but you can specify another language with the flag --sub-lang:
```sh ```sh
youtube-dl --sub-lang sv --write-auto-sub *<URL>* youtube-dl --sub-lang sv --write-auto-sub ${url}
``` ```
You can list all available subtitles with: You can list all available subtitles with:
```sh ```sh
yt-dlp --list-subs *<URL>* yt-dlp --list-subs ${url}
``` ```
It's also possible to skip the video and only download the subtitle if you add the flag --skip-download: It's also possible to skip the video and only download the subtitle if you add the flag --skip-download:
```sh ```sh
yt-dlp --sub-lang sv --write-auto-sub --skip-download *<URL>* yt-dlp --sub-lang sv --write-auto-sub --skip-download ${url}
``` ```
## Alternative ## Alternative
+3
View File
@@ -33,6 +33,7 @@ Then start that service:
```sh ```sh
sudo systemctl start sshd sudo systemctl start sshd
``` ```
Test it works by using ssh into your own system, from inside: Test it works by using ssh into your own system, from inside:
@@ -77,6 +78,7 @@ Look at your keys:
```sh ```sh
ls ~/.ssh ls ~/.ssh
ls -l ~/.ssh
``` ```
You can share the one ending in `.pub` freely. You can share the one ending in `.pub` freely.
@@ -86,6 +88,7 @@ Now send those keys to a remote computer:
```sh ```sh
ssh-copy-id ${username}@{ip_address} ssh-copy-id ${username}@{ip_address}
ssh ${username}@{ip_address}
``` ```
Now you can log in without a password. Now you can log in without a password.
+22
View File
@@ -0,0 +1,22 @@
---
title: Stop email impersonating your domain
tags:
- networking
requires:
- networking/dns_records.md
---
There is nothing to stop scammers from sending email claiming to be coming from your domain.
And the older it gets, the more valuable it is for spoofing.
Just add these two TXT records to the DNS for your domain:
Name | Type | Value
:------|:----:|:-----
@ | TXT | v=spf1 -all
_dmarc | TXT | v=DMARC1; p=reject;
The first says there is not a single SMTP server on earth authorized to send email on behalf of your domain.
The second says that any email that says otherwise should be trashed.
-94
View File
@@ -1,94 +0,0 @@
---
title: network
tags:
- networking
---
# Netstat Stuff
Stats on local net usage within domain.
```sh
iftop -p -n
```
```sh
whois domain.com
```
Info on domain, whether it's taken, et c.:
```sh
dig domain.com
```
```sh
ifconfig
```
Versatile wifi tool:
```sh
nmcli
```
# Examples
You want to connect to the internet.
```sh
sudo iwconfig
```
Get knowledge of wireless state. The output might be:
> wlp3s0 IEEE 802.11 ESSID:"Gandalf WajFaj"
> Mode:Managed Frequency:2.412 GHz Access Point: 10:05:01:90:AC:1A
> Bit Rate=144.4 Mb/s Tx-Power=15 dBm
> Retry short limit:7 RTS thr:off Fragment thr:off
> Encryption key:off
> Power Management:on
> Link Quality=64/70 Signal level=-46 dBm
> Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag
> Tx excessive retries:0 Invalid misc:363 Missed beacon
This tells you that your ESSID is 'Gandalf WajFaj', and the access point name is 10:05:......
```sh
nmcli radio
```
You get an overview of your radio devices.
You're told that eth0 deals with your ethernet and `wlan0` deals with wifi.
`wlan0` is a file which represents your wifi device.
```sh
nmcli wlan0 wifi rescan
```
```sh
nmcli device wifi list
```
Now to connect.
```sh
nmcli device wifi connect [SSID] [your password] [wifi password]
```
Alternatively, you can use
```sh
nmcli -ask device wifi connect [SSID]
```
And it'll ask for your password, so you're not typing it in in full view.
-4
View File
@@ -4,10 +4,6 @@ tags:
- networking - networking
- VPN - VPN
--- ---
<!--
from
https://engineerworkshop.com/blog/how-to-set-up-wireguard-on-a-raspberry-pi/
-->
## On Server ## On Server
-66
View File
@@ -1,66 +0,0 @@
---
title: wireless
tags:
- networking
---
Check wifi's working
```sh
lspci -k
```
Or for usb wifi:
```sh
dmesg | grep usbcore
```
...and hopefully it'll say the new interface is registered.
Check if a wifi interface has been created
```sh
ip link
```
...or
```sh
iw dev
```
Assuming it's wlan0, bring it up with
```sh
ip link set wlan0 up
```
Error messages probably means your wireless chipset requires a firmware to function. In this case, check the kernel messages for firmware being loaded
```sh
dmesg | grep firmware
```
# Utilities
- `iw` doesn't do wpa/wpa2.
- `iwd` does everything except WEXT encryption.
- `wpa_supplicant` does everything.
# Connecting
Get the link status:
```sh
iw dev wlan0 link
```
Scan for available points:
```sh
iw dev wlan0 scan
```
The connecting commands do not cover wpa2.
+70
View File
@@ -0,0 +1,70 @@
---
title: Bash tips
tags:
- shell
- comfy
- bash
---
# This & That
Refer to 'that last thing', and 'the first thing':
```sh
fortune -l > file1
cat !$ | tr -d u > file2
cat file1 !$
diff !^ !$
```
**NB:** this can go wrong:
```sh
ls -l file1 file2
cat !^
```
**NB:** this only works when running `bash` interactively, never in scripts.
# Lists
You can put a list inside any `bash` argument, and `bash` will expand that part into a new argument.
```bash
echo file {one,two,three}.txt
echo file-{one,two,three}.txt
touch !$
```
Look at text files:
```bash
ls *.{txt,md}
```
Look at size of jpg or png files in the `img/` directory:
```bash
du img/*.{jpg,png}
```
# Automatic Lists
```bash
echo {a..d}
echo Archive_{B..E}
```
Using multiple lists works fine.
```bash
mkdir first second third
echo {first,second,third}/file_{1..3}.txt
x={first,second,third}/file_{1..3}.txt
echo $x
echo {first,second,third}/file_{1..3}.txt
x="$(!!)"
echo $x
for file in $x ; do fortune > $file ; done
```
+1 -1
View File
@@ -46,5 +46,5 @@ Just press `!`, e.g. `!ls`.
# Edit a File # Edit a File
While reading a file, press `v` to edit it ('v' stands of `vi`). While reading a file, press `v` to edit it ('v' stands for `vi`).
+3 -21
View File
@@ -5,23 +5,6 @@ tags:
- comfy - comfy
--- ---
# 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 # Done
`<C-d>` `<C-d>`
@@ -29,9 +12,8 @@ cat !^
- If you have a command, Control + d will execute the command. - If you have a command, Control + d will execute the command.
- If you have nothing, `exit`. - If you have nothing, `exit`.
# Clear Search Highlights # Search & Clear Highlights
`<Esc>+u` You can search in many programs by using `/`.
Most programs let you clearn the highlighting with `<Esc>+u`.
Works in most programs with search.
+1 -1
View File
@@ -16,7 +16,7 @@ rdfind $dir
$EDITOR results.txt $EDITOR results.txt
``` ```
Replace the duplicated files with [hard links](../basics/hard_links.md). Replace the duplicated files with [hard links](system/hard_links.md).
```sh ```sh
rdfind -makehardlinks true $dir rdfind -makehardlinks true $dir
+12 -12
View File
@@ -1,25 +1,25 @@
--- ---
title: $EDITOR title: Setting an EDITOR
tags: tags:
- system - system
- defaults
--- ---
The System's default text editor can be defined within /etc/profile. It's given the variable `EDITOR`.
Add these lines to `/etc/profile.d/custom.sh`: Programs expect a default 'line EDITOR' and 'VISUAL editor' so they know how you want to edit text.
Add these lines to automatically set the variables in `bash`:
```sh ```sh
echo 'export EDITOR=vim' >> /etc/profile.d/custom.sh echo 'export EDITOR=vim' >> ~/.bashrc
echo 'export VISUAL=$EDITOR' >> /etc/profile.d/custom.sh echo 'export VISUAL=$EDITOR' >> ~/.bashrc
``` ```
Then reload that profile with: Make the change system-wide by adding them to `/etc/profile.d/custom.sh` instead, which is loaded at startup.
You can add a GUI editor as the `$VISUAL` editor:
```sh ```sh
source /etc/profile VISUAL=gedit
``` ```
If you want to ensure `nano` never appears again: To use a true line editor, as `$EDITOR`, see [ed][writing/ed.md].
```sh
sudo ln -sf $(which vim) $(which nano)
```
+3 -3
View File
@@ -180,6 +180,6 @@ In this case, the makefile can see that `backup` depends on the current backup f
# The Rest # The Rest
- [File patterns](makefiles/patterns.md) - [File patterns](system/makefiles/patterns.md)
- [Makefile graphs](makefiles/graph-easy.md) - [Makefile graphs](system/makefiles/graph-easy.md)
- [In-build help](makefiles/help.md) - [In-build help](system/makefiles/help.md)
+1 -1
View File
@@ -5,7 +5,7 @@ tags:
- make - make
--- ---
Using the [basic example](../makefiles.md), you can make a complete backup of all backup files. Using the [basic example](system/makefiles.md), you can make a complete backup of all backup files.
This file will depend upon everything inside the `$(storage_directory)`. This file will depend upon everything inside the `$(storage_directory)`.
Unlike `bash`, you can't just say `storage_directory/*`: the pattern must be stated as a 'wildcard'. Unlike `bash`, you can't just say `storage_directory/*`: the pattern must be stated as a 'wildcard'.
+12 -12
View File
@@ -25,10 +25,10 @@ Note the asterisk marking the boot partition.
# IDs # IDs
| ID | Meaning | | ID | Meaning |
|----|:--------| |:----------:|:-----------|
|83 |Linux | | 83 | Linux |
| 5 |Extended | | 5 | Extended |
| 82 |Swap | | 82 | Swap |
fdisk will not help with a GPT formatted drive. For this, use gdisk, which is mostly the same. fdisk will not help with a GPT formatted drive. For this, use gdisk, which is mostly the same.
@@ -53,14 +53,14 @@ mkreiserfs /dev/sdc2
# File System Types # File System Types
| Type | Advantages | Disadvantages | | Type | Advantages | Disadvantages |
|------|:-----------|:--------------| |----------------|:----------------------------------------------|:-------------------------------------------------------------|
|ext2 | |No journaling means that the file offers no crash recovery. | ext2 | | No journaling means that the file offers no crash recovery. |
|ext3 | Journaling | | ext3 | Journaling | |
|ext4 | Journaling and handles files of up to 16TB.| | ext4 | Journaling and handles files of up to 16TB. | |
|reiserfs| Journalin and stable.| | reiserfs | Journalin and stable. | |
|btrfs |Reliable and stable| | btrfs | Reliable and stable | |
|XFS |Journaling, great for large files.| | XFS | Journaling, great for large files. | |
|VFAT |Comptable with Windows, like FAT32| | VFAT | Comptable with Windows, like FAT32 | |
# Parted # Parted
+5 -5
View File
@@ -14,7 +14,7 @@ Input a command with C-b
In addition to Windows, there are panes. In addition to Windows, there are panes.
|Commands | Key | |Commands | Key |
| ---- | ---- | |------------------|------|
| New Window | c | | New Window | c |
| Previous Window | p | | Previous Window | p |
| next window | n | | next window | n |
@@ -26,10 +26,10 @@ In addition to Windows, there are panes.
| kill session | d | | kill session | d |
|Name Commands| ### Name Commands
| --------|
| split-window | - split-window
| rename-window | - rename-window
# Sessions # Sessions
+8 -10
View File
@@ -1,21 +1,19 @@
--- ---
title: Docker title: Setup Docker
tags: tags:
- documentation - documentation
- virtualization - setup
- containers
requires: requires:
- system/groups.md - system/groups.md
--- ---
Install docker, add your user to the docker group, and start the service.
```sh ```sh
sudo pacman -S docker sudo pacman -S docker
```
```sh
sudo usermod -aG docker $USER sudo usermod -aG docker $USER
``` sudo su $USER
```sh
sudo systemctl start docker sudo systemctl start docker
``` ```
@@ -69,9 +67,9 @@ docker rm 97796727e883
# Networking # Networking
Get a list of docker container ips Get a list of docker container IPs
```sh ```sh
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' *container_name_or_id* docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${name}
``` ```
+3 -2
View File
@@ -1,11 +1,12 @@
--- ---
title: virtualbox title: Setup Virtualbox
tags: tags:
- system - system
- setup
- virtualization
requires: requires:
- system/groups.md - system/groups.md
--- ---
# Setup
Load the modules (or just reboot): Load the modules (or just reboot):
-8
View File
@@ -12,14 +12,6 @@ Turn a markdown file into a pdf:
lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf
``` ```
*Example:* put [this Makefile](lowdown/example.txt) in a directory, rename it `Makefile`, then do:
```sh
make example
make
```
To give the document a title, put that title in the metadata: To give the document a title, put that title in the metadata:
```sh ```sh
+5 -6
View File
@@ -3,8 +3,13 @@ title: Ed: The Standard Editor
tags: tags:
- writing - writing
- guide - guide
- sed
- vim
--- ---
Understanding `ed` will let you understand all that feels strange about the system.
It set the standards for `sed` and `vi`.
`ed` was designed for real terminals, i.e. a typewriter. `ed` was designed for real terminals, i.e. a typewriter.
You would type a command to the computer, and it would type out any errors. You would type a command to the computer, and it would type out any errors.
It would not waste paper, ink, and time by typing out `COMMAND RUN SUCCESSFULLY` after each command. It would not waste paper, ink, and time by typing out `COMMAND RUN SUCCESSFULLY` after each command.
@@ -12,7 +17,6 @@ A silent machine meant a happy machine.
To fully appreciate `ed`, you can slow down your terminal with the following command: To fully appreciate `ed`, you can slow down your terminal with the following command:
```sh ```sh
ff=/tmp/bashpipe ff=/tmp/bashpipe
mkfifo $ff mkfifo $ff
@@ -24,7 +28,6 @@ Try running `dir` and `dir -F`!
Okay, now onto `ed`... Okay, now onto `ed`...
# Basic Usage # Basic Usage
Open a file: Open a file:
@@ -67,11 +70,8 @@ Delete the current line:
d d
``` ```
Write the 'buffer' to disk: Write the 'buffer' to disk:
```ed ```ed
w w
``` ```
@@ -86,7 +86,6 @@ q
Open that file: Open that file:
```ed ```ed
ed file.md ed file.md
``` ```
+6 -5
View File
@@ -20,8 +20,9 @@ Keybind to exit this mode is `Ctrl+q`
## Extras ## Extras
- [Learning Vim](vim/vi.md) - [Learning Vim](writing/vim/vi.md)
- [Navigation](vim/navigate.md) - [Navigation](writing/vim/navigate.md)
- [Completion](vim/completion.md) - [Completion](writing/vim/completion.md)
- [Window Splits](vim/windows.md) - [Window Splits](writing/vim/windows.md)
- [Use vim bindings in bash](vim/vim_in_bash.md) - [Use vim bindings in bash](writing/vim/vim_in_bash.md)
- [A game to learn how to code in Vim](https://www.vim-hero.com/)
+116
View File
@@ -0,0 +1,116 @@
---
title: CSV to Markdown in Vim
tags:
- writing
- vim
- csv
- markdown
requires:
- writing/vim.md
---
Open a CSV table (I made this one with `:r!sed 's/:/,/g' /etc/passwd | head`).
```csv
root,x,0,0,,/root,/bin/bash
bin,x,1,1,,/,/usr/bin/nologin
daemon,x,2,2,,/,/usr/bin/nologin
mail,x,8,12,,/var/spool/mail,/usr/bin/nologin
ftp,x,14,11,,/srv/ftp,/usr/bin/nologin
http,x,33,33,,/srv/http,/usr/bin/nologin
nobody,x,65534,65534,Nobody,/,/usr/bin/nologin
dbus,x,81,81,System Message Bus,/,/usr/bin/nologin
systemd-coredump,x,981,981,systemd Core Dumper,/,/usr/bin/nologin
systemd-network,x,980,980,systemd Network Management,/,/usr/bin/nologin
```
Highlight the table.
- Go to the top, with 'root'.
- Type `V9j`.
- `:!column -ts, -o '|'`
- Return!
```csv
root |x|0 |0 | |/root |/bin/bash
bin |x|1 |1 | |/ |/usr/bin/nologin
daemon |x|2 |2 | |/ |/usr/bin/nologin
mail |x|8 |12 | |/var/spool/mail|/usr/bin/nologin
ftp |x|14 |11 | |/srv/ftp |/usr/bin/nologin
http |x|33 |33 | |/srv/http |/usr/bin/nologin
nobody |x|65534|65534|Nobody |/ |/usr/bin/nologin
dbus |x|81 |81 |System Message Bus |/ |/usr/bin/nologin
systemd-coredump|x|981 |981 |systemd Core Dumper |/ |/usr/bin/nologin
systemd-network |x|980 |980 |systemd Network Management|/ |/usr/bin/nologin
```
The command displays as `:'<,'>!column -ts, -o '|'`.
This looks better, but the spacing is bad because the output separate is `-o '|'`.
You can put spaces around that pipe by making the separator a pipe (`-s'|'`)
and making the output separator a pipe with spaces (`-o' | '`).
```vim
:'<,'>!column -ts'|' -o ' | '
```
```csv
root | x | 0 | 0 | | /root | /bin/bash
bin | x | 1 | 1 | | / | /usr/bin/nologin
daemon | x | 2 | 2 | | / | /usr/bin/nologin
mail | x | 8 | 12 | | /var/spool/mail | /usr/bin/nologin
ftp | x | 14 | 11 | | /srv/ftp | /usr/bin/nologin
http | x | 33 | 33 | | /srv/http | /usr/bin/nologin
nobody | x | 65534 | 65534 | Nobody | / | /usr/bin/nologin
dbus | x | 81 | 81 | System Message Bus | / | /usr/bin/nologin
systemd-coredump | x | 981 | 981 | systemd Core Dumper | / | /usr/bin/nologin
systemd-network | x | 980 | 980 | systemd Network Management | / | /usr/bin/nologin
```
Make a header by copying the top line and replacing text (`yypkR`).
That's nicer, but the formatting's wrong again.
```markdown
User | Passwords | UID | GID | Description | Home | Shell
root | x | 0 | 0 | | /root | /bin/bash
[...]
```
Time to fix it with `:'<,'>!column -ts'|' -o'|'`.
```csv
User | Passwords | UID | GID | Description | Home | Shell
----------------- | ----------- | ------- | ------- | ---------------------------- | ----------------- | ----------
root | x | 0 | 0 | | /root | /bin/bash
bin | x | 1 | 1 | | / | /usr/bin/nologin
daemon | x | 2 | 2 | | / | /usr/bin/nologin
mail | x | 8 | 12 | | /var/spool/mail | /usr/bin/nologin
ftp | x | 14 | 11 | | /srv/ftp | /usr/bin/nologin
http | x | 33 | 33 | | /srv/http | /usr/bin/nologin
nobody | x | 65534 | 65534 | Nobody | / | /usr/bin/nologin
dbus | x | 81 | 81 | System Message Bus | / | /usr/bin/nologin
systemd-coredump | x | 981 | 981 | systemd Core Dumper | / | /usr/bin/nologin
systemd-network | x | 980 | 980 | systemd Network Management | / | /usr/bin/nologin
```
Now we just need the spacer line.
Copy the top line (`yyp`) and replace (`:s/not-pipe/-/g`).
You can say 'not the pipe symbol' with `[^|]` or 'not-pipe-or-colon' with `[^:|]`.
```vim
:s/[^:|]/-/g
```
# Keyboard Shortcut
Put this in your `~/.vimrc` to map 'Control + s' to reformat CSV while in visual mode.
```vim
vmap <C-s> :!column -ts, -o " \| "<Enter>yyp:s/[^\|:]/-/g<Enter>
```
+82
View File
@@ -0,0 +1,82 @@
---
title: Reformat a Markdown Table
tags:
- writing
- vim
- markdown
requires:
- writing/vim.md
---
This markdown table is badly messed up:
```markdown
| File | Category |
|:------|:---------|
| calendar.md | tex|
| tex_packages.md | tex|
| completion.md | vim|
| csv_to_md.md | vim|
| format_md.md | vim|
```
Highight from the top with `V6j`, then run `column` to fix the output:
```vim
:!column -ts'|' -o '|'
```
It displays like this:
```vim
:'<,'>!column -ts'|' -o '|'
```
```markdown
| File | Category |
|:------ |:---------|
| calendar.md | tex |
| tex_packages.md | tex |
| completion.md | vim |
| csv_to_md.md | vim |
| format_md.md | vim |
```
That's better, but the header is broken.
Fix is by replacing spaces with dashes.
```vim
:s/ /-/g
```
The lines have too much whitespace.
You can fix this with the 'truncate' command, to squeeze repeating spaces or dashes.
```vim
tr -s ' -' |column -ts '|' -o '|'
```
```markdown
| File | Category |
|:----------------|:---------|
| calendar.md | tex |
| tex_packages.md | tex |
| completion.md | vim |
| csv_to_md.md | vim |
| format_md.md | vim |
```
# Keyboard Shortcut
Put this in your `~/.vimrc` to map 'Control + t' to reformat markdown tables in visual mode.
```vim
vmap <C-t> :!tr -s ' -' \|column -ts '\|' -o '\|'<Enter>j:s/ /-/g<Enter>k
```