Compare commits

...

85 Commits

Author SHA1 Message Date
5feb513b38 add kubernetes proxy api 2025-08-29 22:08:16 +02:00
3063b65d34 kubectl explain: an affront to basic decency 2025-08-29 21:58:16 +02:00
35f2663330 add basic kubernetes commands 2025-08-29 21:48:16 +02:00
26ee7243e3 kubernetes setup 2025-08-29 15:14:25 +02:00
afcd5699a7 calm the makefile messages 2025-08-29 08:07:53 +02:00
399358d810 note how to set up with python readline 2025-08-29 07:49:26 +02:00
596a4a9746 ansible: store host password 2025-08-23 18:59:47 +02:00
af52292ef8 tempfs article 2025-08-22 16:18:28 +02:00
865b4a2da1 remove duplicate entry 2025-08-22 16:02:19 +02:00
8eea348112 change ``bash headers to ``sh 2025-08-22 15:59:04 +02:00
3e049e1687 introduce ansible with docker 2025-08-21 23:00:43 +02:00
d1a1146260 allow ascii dependency map 2025-08-18 01:37:40 +02:00
3dface826f playing with ansible 2025-08-16 02:54:41 +02:00
a55712032b make all file names lowercase 2025-08-14 06:35:44 +02:00
33a959fcea note makefile warning 2025-08-13 22:09:48 +02:00
4ed4c87acf improve group logins 2025-08-13 22:09:12 +02:00
68f9eb2a7d note ijq for json 2025-08-06 05:28:58 +02:00
c407e8be9e note git requirement for lfs 2025-07-29 16:38:28 +02:00
f52b241dc2 write make a gif 2025-07-29 16:38:18 +02:00
c0755da29f fix ffmpeg headers 2025-07-29 16:31:02 +02:00
c3afb4b562 add git stash 2025-07-24 07:23:42 +02:00
f5b3d969fd grok vi 2025-07-14 12:42:45 +02:00
7e2487f0d3 formatting 2025-06-05 20:46:33 +02:00
3fec180a14 add python projects with Makefiles 2025-06-05 20:46:13 +02:00
c08ad6f175 update taskwarrior 2025-05-25 20:10:05 +02:00
1a17ffda7f do not jaquays the docs 2025-05-24 23:27:45 +02:00
556dba6f29 scan ports with havn 2025-05-24 23:27:06 +02:00
b7a79951c5 adjust LaTeX notes 2025-05-21 16:11:11 +02:00
2d95304da4 rejig git 2025-05-18 00:01:48 +02:00
8e64f8f58e note how to use git with sha256 2025-05-14 21:33:16 +02:00
3b04aaf8be add string substitution 2025-05-06 16:41:57 +02:00
1dfdac516b add basic vim requirements to vim 2025-04-30 15:39:11 +02:00
63e4c409bb fix missing links 2025-04-30 15:39:05 +02:00
98dbb5e3d6 write sc-im conversions 2025-04-15 13:51:33 +02:00
45eae50c24 typo 2025-04-09 15:40:38 +02:00
24bb7014f9 write tex setup 2025-04-02 01:11:02 +02:00
92145ac4b7 make a writing category 2025-04-01 23:29:17 +02:00
7292e0625e formatting 2025-04-01 15:06:21 +02:00
ffa4dbc51a commit for another 2025-04-01 15:02:26 +02:00
641b8fb825 update vim syntax 2025-03-26 14:07:27 +01:00
a6b8420c26 update warrior syntax 2025-03-26 13:51:17 +01:00
68d3a850c0 how to show torrents 2025-03-26 13:46:04 +01:00
7e75763cee expand on readme style 2025-03-22 23:45:43 +01:00
2d3961e0f5 update readme 2025-03-22 23:41:04 +01:00
72ad0786c8 allow joins on related articles 2025-03-22 23:26:20 +01:00
b64d9de0c4 bad.horse bad.horse 2025-03-20 13:10:43 +01:00
fa9c8edb1d edit Makefile intro 2025-03-18 18:54:17 +01:00
741e988536 base 16 notes 2025-03-18 18:11:57 +01:00
a72e2b117d syntax fix 2025-03-13 14:06:45 +01:00
cc574d5358 backup syntax 2025-03-07 12:12:17 +01:00
0d76eb0531 edit virtualbox 2025-03-05 16:46:46 +01:00
3bfeacd2d7 write managing groups 2025-03-05 16:46:36 +01:00
ed4b54cf7e tag 2025-03-03 19:44:41 +01:00
4e89c5ab9b more grammarlier 2025-03-02 22:04:04 +01:00
1732c62734 add soft serve maintenance 2025-03-02 18:15:59 +01:00
fb157895fb add requirements 2025-03-02 18:11:52 +01:00
b3258d9f5f refactor db creation 2025-03-02 10:14:20 +01:00
d793bca3ea search video audio 2025-02-28 17:10:25 +01:00
14470b6f92 typo 2025-02-27 16:59:11 +01:00
59fb0ada24 lowercase tags 2025-02-24 09:19:15 +01:00
b68fa25cea syntax and colouration 2025-02-19 15:11:37 +01:00
5bd45973b4 clean makefile help syntax 2025-02-17 19:04:09 +01:00
66cdca5c85 give articles lowercase tags 2025-02-17 00:27:30 +01:00
aa32bfc249 bibliographies with recfiles 2025-02-14 13:05:28 +01:00
fc88ab6200 recfile example 2025-02-13 17:39:55 +01:00
eaec01076b ip addresses with recfiles 2025-02-13 17:39:38 +01:00
0abc2818e8 use title as db key 2025-02-13 03:52:15 +01:00
4250f619c3 unify kernel notes 2025-02-13 01:42:50 +01:00
4d53f7c7d6 rebuild on $dir/$file.md changes
Still not rebuilding on changes to $dir/$dir/$file.md.
2025-02-13 01:34:33 +01:00
38feabb79f name fix 2025-02-13 01:16:24 +01:00
b4683a8681 add contents to databases 2025-02-13 00:08:34 +01:00
d2934bf8a3 recfile fixes 2025-02-12 23:01:50 +01:00
5afc414a52 small edits 2025-02-12 23:01:40 +01:00
d8b4a9d00b stop duplicate db entries 2025-02-12 22:51:27 +01:00
a15b565e09 metadata fixes 2025-02-12 22:50:27 +01:00
6ccba626c8 edit git lfs 2025-02-12 17:46:59 +01:00
415985d08c make silently be default 2025-02-12 17:00:34 +01:00
d6c3cd6387 set default editor 2025-02-12 16:51:02 +01:00
4c3d51ff83 use parallel execution by default 2025-02-12 16:49:10 +01:00
8f3da4558f split database into parts
Each category - sound/, networking/, et c. - now has its own little
database in .dbs/.  So the database only recompiles based on categories,
rather than a complete recompile every time a single file changes.
2025-02-12 16:47:47 +01:00
137466a423 edit article categories in makefile 2025-02-12 15:46:02 +01:00
37df47cf3b fix mark article target 2025-02-12 15:37:05 +01:00
b6280a8581 separate system search 2025-02-12 15:36:40 +01:00
1ce84ebc53 edit metadata 2025-02-12 15:01:15 +01:00
341b6ed46f remove old otr notes 2025-02-12 14:38:02 +01:00
177 changed files with 3025 additions and 1500 deletions

View File

@@ -1,38 +1,66 @@
MAKEFLAGS += -j
MAKEFLAGS += -s
EDITOR ?= vi
FZF != command -v sk || command -v fzy || command -v fzf || \
{ echo install a fuzzy finder && exit 1 ;}
help: ## Print the help message
spill_contents = sed -e '1,/---/d'
help: .git/info/exclude ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
column -s ':' -t
articles != find * -type f -name "*.md"
db.rec: $(articles)
dirs != ls -d */
categories = $(patsubst %/, %, $(dirs))
databases = $(patsubst %, .dbs/%.rec, $(categories))
default += $(databases)
default += db.rec
default += .dbs/map.fmt
$(foreach dir, $(categories), \
$(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \
)
.dbs/:
mkdir $@
$(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 $? )
printf '%s\n' '%rec: guide' > $@
printf '%s\n' '%key: title' >> $@
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: title' >> $@
for x in $^ ; do \
sed -n '2,/^---$$/ {/^---$$/d; p}' "$$x" |\
sed -e 's/\[ //' -e 's/ \]//' |\
tr -d '"' ;\
printf "file: %s\n\n" "$$x" ;\
done >> $@
for entry in $^; do \
recset $@ -e "file = '$${entry}'" -f wordcount --set-add="$$(wc -w < $${entry})" ;\
done
printf '%s\n\n' '%sort: wordcount' >> $@
cat $^ >> $@
recsel $@ -e "requires != ''" -CR title,requires |\
while read title requires; do \
IFS=', ' && for provider in $$requires; do \
for provider in "$$requires" ; do \
recset $@ -e "title = '$${provider}'" -f provides -a "$${title}" ;\
done ;\
done
sed -i 's/"//g' $@
recfix --sort $@
default += db.rec
$(info Created main database: $@)
.git/info/exclude: $(default)
echo $^ | tr ' ' '\n' > $@
@echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude
@@ -41,13 +69,26 @@ database: $(default) ## Make a recfiles database
.PHONY: article
article: ## Write an article
@path=$$(find . -type d -printf '%P\n' | $(FZF)); \
read -p "Title: " title; \
printf '%s\n' '---' >> $$path/$$title.md ; \
printf 'title: "%s"\n' "$$title" >> $$path/$$title.md ; \
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$title.md ; \
printf '%s\n\n' '---' >> $$path/$$title.md ;\
$(EDITOR) +5 $$path/$$title.md
@path=$$(find $(categories) -type d | sort | uniq | $(FZF)) ;\
read -p "Title: " title ;\
filename="$$(echo "$$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')" ;\
printf '%s\n' '---' >> $$path/$$filename.md ;\
printf 'title: "%s"\n' "$$title" >> $$path/$$filename.md ;\
printf 'tags: [ "%s" ]\n' "$$path" | tr '[:upper:]' '[:lower:]' | sed 's#\/#", "#g' >> $$path/$$filename.md ;\
printf '%s\n\n' '---' >> $$path/$$filename.md ;\
$(EDITOR) +5 "$$path/$$filename.md"
.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;}' >> $@
.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}
.PHONY: clean
clean: ## Remove all generated files

View File

@@ -4,22 +4,29 @@ title: "Linux Knowledge Base"
The Linux Knowledge-Base provides quick-start guides for working with terminal programs.
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.
# Setup
Install `make`, `recutils`, and any fuzzy-finder (i.e. `sk`, `fzy`, or `fzf`).
## Usage
Set up the database and try a few queries:
```sh
make
make database
recsel db.rec -m 3
recsel db.rec -q database
recsel db.rec -q gpg
recsel db.rec -e "title = 'ssh'"
recsel db.rec -e "title ~ 'ssh'"
recsel db.rec -e "title ~ 'bash'" -R title,wordcount
recsel db.rec -t guide -j provides -G title \
-e "title = 'ssh'" \
-p 'sum(provides_wordcount)'
```
# Style
@@ -29,6 +36,16 @@ recsel db.rec -e "title ~ 'bash'" -R title,wordcount
- 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.
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.
[Do not Jaquays documentation](https://splint.rs/posts/no_links)
## Be Opinionated
- Guides should not ask the reader to select options half-way through.
@@ -73,6 +90,11 @@ grep ls --color=always $HISTFILE | $PAGER
Now we can see what can be changed.
## Assume People Follow the Instructions
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.
# What's Wrong with Everything Else?
## Man pages

View File

@@ -1,46 +1,46 @@
---
title: "at"
tags: [ "Basics" ]
tags: [ "basics", "time" ]
---
Install with:
```bash
```sh
sudo apt install at
```
Enable the daemon service with:
```bash
```sh
sudo systemctl enable --now atd
```
Then jobs can be specified with absolute time, such as:
```bash
```sh
at 16:20
```
```bash
```sh
at noon
```
```bash
```sh
at midnight
```
```bash
```sh
at teatime
```
Type in your command, e.g.:
```bash
```sh
touch /tmp/$FILE.txt
```
The jobs can also be specified relative to the current time:
```bash
```sh
at now +15 minutes
```
@@ -50,7 +50,7 @@ Finally, accept the jobs with ^D.
Display a list of commands to run with:
```bash
```sh
atq
```
@@ -58,7 +58,7 @@ atq
This will print all pending IDs. Remove a job by the ID with:
```bash
```sh
atrm 2
```
@@ -68,7 +68,7 @@ Check `/var/spool/atd/` to see the jobs.
Automatically add a job for later, by setting the date, then using echo for the command.
```bash
```sh
t="$(date -d "2 minutes" +%R)"
echo "fortune > ~/$FILE" | at "$t"
watch cat $FILE

View File

@@ -1,6 +1,6 @@
---
title: "Basics"
tags: [ "Basics" ]
tags: [ "basics" ]
---
You need about a dozen commands to move around Linux.
@@ -9,13 +9,13 @@ Don't worry about understanding any of it, just type it in and the habit forms p
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'):
```bash
```sh
pwd
```
Have a look at what is here:
```bash
```sh
ls
```
@@ -23,11 +23,11 @@ If you get no response, the list of items is "", meaning "nothing here".
Have a look at **a**ll the files:
```bash
```sh
ls -a
```
```bash
```sh
. ..
```
@@ -35,38 +35,38 @@ So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the
Change directory (`cd`) down one level:
```bash
```sh
cd ..
```
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
```bash
```sh
cd bob
```
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
```bash
```sh
cd /
```
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up:
```bash
```sh
du iptables
```
That's the number of kilobytes the file is taking up.
Do the same again, but in a human-readable format:
```bash
```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:
```bash
```sh
man du
```
@@ -74,7 +74,7 @@ Once you're done, press 'q' to quit the manual page and try the extra `du` flag
Now you can try to gain super-powers and take over the system:
```bash
```sh
sudo -i
```
@@ -82,61 +82,61 @@ 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:
```bash
```sh
exit
```
Go find a file that isn't a directory. You can tell which is which with:
```bash
```sh
ls -l
```
A directory starts with a 'd', like this:
```bash
```sh
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
```
A standard file starts with '-', like this:
```bash
```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:
```bash
```sh
cat /etc/hostname
```
Print out the words "hello world":
```bash
```sh
echo "hello world"
```
Move back to your home directory:
```bash
```sh
cd
```
Take the words 'hello world', and put them in 'my_file':
```bash
```sh
echo 'hello world' > my_file
```
Measure the disk usage of that file, then put the results at the bottom of the file:
```bash
```sh
du $FILE >> $FILE
```
And check the results:
```bash
```sh
cat $FILE
```
@@ -148,7 +148,7 @@ Press tab after typing a few keys and bash will guess what you're trying to typ
Look at your file's owner:
```bash
```sh
ls -l $FILE
```
@@ -156,19 +156,19 @@ If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is own
Take your file and change the owner to root:
```bash
```sh
sudo chown root $FILE
```
Change the same file so it's owned by the group 'audio':
```bash
```sh
sudo chown :audio $FILE
```
Check you did that correctly:
```bash
```sh
ls -l my_file
```
@@ -176,7 +176,7 @@ ls -l my_file
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
```bash
```sh
rm $FILE
```
@@ -184,32 +184,32 @@ You'll see you're not allowed, because you don't own it.
Look at which groups you're in:
```bash
```sh
groups
```
Change the file so that members of the audio group can write to the file:
```bash
```sh
sudo chmod g+w $FILE
```
Check you got it right with `ls -l`:
```bash
```sh
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
```
Try to delete the file again:
```bash
```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:
```bash
```sh
sudo usermod -a -G audio [ your username here ]
```
@@ -219,19 +219,19 @@ Now you should be able to remove (delete) the file. Remember, that using 'rm fi
Make a directory called 'new test':
```bash
```sh
mkdir 'new test'
```
Make two directories, called 'A', and 'Z':
```bash
```sh
mkdir A Z
```
Make a single directory called 'A Z'
```bash
```sh
mkdir 'A Z'
```
@@ -239,19 +239,19 @@ mkdir 'A Z'
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
```bash
```sh
du -sch * > A/'disk usage'.txt
```
Look at your file:
```bash
```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:
```bash
```sh
grep total A/disk\ usage.txt
```
@@ -259,7 +259,7 @@ The `grep` program also has a manual ('man page'). You should find out what tha
Start the manual:
```bash
```sh
man du
```
@@ -267,7 +267,7 @@ Then search for `-c` by pressing `/`. Your final keys should be `man du`, then
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
```bash
```sh
man ls | grep human
```
@@ -275,25 +275,25 @@ Now use that flag that you've found in combinatin with the `-l` flag to look at
Remove the directory 'Z':
```bash
```sh
rmdir Z
```
Remove the directory 'Z':
```bash
```sh
rmdir Z
```
And then remove all the rest:
```bash
```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:
```bash
```sh
rm -r A
```
@@ -303,11 +303,11 @@ 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:
```bash
```sh
whereis yum
```
```bash
```sh
whereis apt
```
@@ -315,14 +315,14 @@ If you get a hit, you can use whatever program that is to install things.
Set a reminder of your package manager:
```bash
```sh
echo my package manager is yum | lolcat
```
If that failed it's because you don't have `lolcat` installed.
Install lolcat:
```bash
```sh
sudo apt install lolcat
```
@@ -330,13 +330,13 @@ Try the same command again.
Search for things you want, like `libreoffice`, or `gimp`:
```bash
```sh
apt search libreoffice
```
... then install one of them with:
```bash
```sh
apt install $PROGRAM
```

View File

@@ -1,41 +1,41 @@
---
title: "clock"
tags: [ "Basics" ]
tags: [ "basics", "time" ]
---
Show system time:
```bash
```sh
date
```
Show hardware time:
```bash
```sh
sudo hwclock -r
```
Change system time to match hardware time:
```bash
```sh
sudo hwclock --hctosys
```
Change hardware time to match system time:
```bash
```sh
sudo hwclock --systohc
```
Manually set the hardware time to a specified date:
```bash
```sh
sudo hwclock --set --date="8/25/19 13:30:00"
```
## Normal Date
```bash
```sh
date +%d/%m/%y
```
@@ -45,7 +45,7 @@ Computers started counting time on January 1st, 1970, and added one second-per-s
Track the time in Unix-time:
```bash
```sh
date +%s
```
@@ -55,13 +55,13 @@ Servers which take their time from an observatory we call Stratum 1 servers. Se
Install ntp with:
```bash
```sh
sudo apt-get install -y ntp
```
The shell command for this is `ntpq`. Monitor the service providers using:
```bash
```sh
ntpq -p
```

View File

@@ -5,32 +5,32 @@ tags: [ "basics", "format", "json" ]
Put output into column.
```bash
```sh
du -h /etc/* | column
```
Reformat file with an explicit separator (`-s`):
```bash
```sh
column -ts: /etc/passwd
```
Give columns names (`-N`), so you can hide some (`-H`):
```bash
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
```
Reorder with `-O` (unspecified items remain):
```bash
```sh
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
```
Output to json format with `-J`:
```bash
```sh
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
```

View File

@@ -1,6 +1,6 @@
---
title: "conditionals"
tags: [ "Basics" ]
tags: [ "basics" ]
---
# If statements
@@ -46,7 +46,7 @@ esac
# While and Until
This prints from 1 until 9.
```bash
```sh
COUNTER=1
while [ $COUNTER -lt 2 ]; do
> ((COUNTER++))
@@ -58,7 +58,7 @@ There's also 'until', which stops when something is true, rather than keeping go
# For
```bash
```sh
for i in $( ls ); do
> du -sh $i
> done
@@ -70,19 +70,19 @@ The sequences tool counts up from X in jumps of Y to number Z.
Count from 1 to 10.
```bash
```sh
seq 10
```
Count from 4 to 11.
```bash
```sh
seq 4 11
```
Count from 1 to 100 in steps of 5.
```bash
```sh
seq 1 5 100
```

View File

@@ -1,129 +0,0 @@
---
title: "cron"
tags: [ "Basics" ]
---
# Cronie
The `cronie` program is also known as `crond`.
## Install
```bash
sudo apt search -n ^cron
```
Once installed, search for the service name, and start it.
```bash
sudo systemctl list-unit-files | grep cron
sudo systemctl enable --now $NAME
```
## Usage
Show your current crontab:
```bash
crontab -l
```
You can put this in a file and edit it:
```bash
crontab -l > $filename
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
```
Then apply that crontab:
```bash
crontab $filename
rm $filename
```
The `cron` program will check your syntax before adding the tab.
Your crontab file sits somewhere in `/var/spool/`.
Probably in `/var/spool/cron`.
## Syntax
`* * * * *`
These five points refer to:
`minute hour day month weekday`
So '3pm every Sunday' would be:
`0 15 * * 7`
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
The minute is '0' (i.e. '0 minutes past three pm').
Doing the same thing, but only in February, would be:
`0 15 * 2 7`
### Variables
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
```bash
echo "HOME=$HOME" > $filename
crontab -l >> $filename
crontab $filename
```
`cronie` doesn't know where anything lives, including programs.
You can give it your usual `$PATH` variable like this:
```bash
echo $PATH > $filename
crontab -l >> $filename
crontab $filename
```
Now instead of doing this
`40 */3 * * * /usr/bin/du -sh $HOME/* | sort -h > $HOME/sum.txt`
You can simply do this:
`40 */3 * * * du -sh $HOME/* | sort -h > $HOME/sum.txt`
## Run as Root
You can execute a script as root by putting it into a directory, instead of in the tab.
Look at the available cron directories:
```bash
ls -d /etc/cron.*
```
Make a script which runs daily:
```bash
f=apt_update.sh
echo '#!/bin/bash' > $f
echo 'apt update --yes' >> $f
chmod +x $f
sudo mv $f /etc/cron.daily/
```
### Testing with runparts
Run-parts runs all executable scripts in a directory.
```bash
run-parts /etc/cron.hourly
```
# Troubleshooting
### `date` Commands
Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`.

View File

@@ -5,7 +5,7 @@ tags: [ "basics" ]
Compose a statement for execution.
```bash
```sh
x='echo $y'
echo $x
y=dragon
@@ -14,7 +14,7 @@ eval "$x"
The results remain in the current shell, unlike sub-shells.
```bash
```sh
b=basilisk
sh -c 'echo $b'
eval "g=goblin"

View File

@@ -1,6 +1,6 @@
---
title: "bash games"
tags: [ "Games" ]
tags: [ "games" ]
---
Games are a great way to learn bash.

View File

@@ -11,20 +11,20 @@ This ID is called the 'inode'.
Create a file, and a hard link:
```bash
```sh
fortune > $file_1
mkdir -p x/y/z/
ln $file_1 x/y/z/$file_2
```
Have a long look at the file with the `-l` flag, and check the inode with `-i`:
```bash
```sh
ls -li $file_1 x/y/z/$file_2
```
Since they are the same file, you can make a change to one, and it changes both:
```bash
```sh
fortune | tee x/y/z/$file_2
cat $file_1
cat x/y/z/$file_2

View File

@@ -1,34 +0,0 @@
---
title: "kernel"
tags: [ "Basics" ]
---
## Living Space
Kernel modules live in lib/modules/$(uname -r)
## Change
Load them with
```bash
sudo modprobe ath9k
```
Or remove one with
```bash
sudo modprove uvcvideo
```
The PC's irritating speaker beep can be really annoying. Disable it with:
```bash
sudo modprobe -r pcspeaker
```
Permanently disable a module by blacklisting it in `/etc/modprobe.d`:
```bash
echo 'blacklist pcspkr' > /etc/modprobe.d/*nobeep*.conf
```

View File

@@ -1,13 +1,13 @@
---
title: "kill"
tags: [ "Basics" ]
tags: [ "basics" ]
---
If you want to kill a program in a graphical environment, open a terminal and type:
# Graphical Programs
```bash
```sh
xkill
```
@@ -17,7 +17,7 @@ Then click on the application which you want to kill.
To kill a program, find it with:
```bash
```sh
pgrep discord
```
@@ -25,7 +25,7 @@ This will give you the UUID, e.g. `19643`.
Kill the program with:
```bash
```sh
kill 19643
```
@@ -33,7 +33,7 @@ kill 19643
To see an ordered list of termination signals:
```bash
```sh
kill -l
```
@@ -49,7 +49,7 @@ Higher numbers are roughly equivalent to insistence.
For example:
```bash
```sh
kill -1 3498
```
@@ -57,7 +57,7 @@ This roughly means 'maybe stop the program, if you can, maybe reload'.
Or the famous:
```bash
```sh
kill -9 3298
```

View File

@@ -1,6 +1,6 @@
---
title: "locale"
tags: [ "Basics" ]
tags: [ "basics", "time" ]
---
Your locale tells the computer your location, preferred time-and-date format, standard language, papersize, et c.
@@ -8,25 +8,25 @@ A list of supported locales is available at /usr/share/i18n/SUPPORTED
See a full list with:
```bash
```sh
cat /usr/share/i18n/SUPPORTED
```
Take the first portion to generate full locale information for a region:
```bash
```sh
locale-gen ru_RU.UTF-8
```
Then use this for the current shell session with
```bash
```sh
LANG=ru_RU.utf8
```
Expand this to the entire system with:
```bash
```sh
export LANG=ru_RU.utf8
```
@@ -34,7 +34,7 @@ You can make this permanent for one user by adding this line to the ~/.profile o
Make it permanent for the entire system by editing:
```bash
```sh
sudo vim /etc/defaults/locale
```

View File

@@ -1,62 +1,33 @@
---
title: "locating"
tags: [ "Basics" ]
tags: [ "basics" ]
---
# Type
`type` shows what kind of thing you're running, be it an alias, function, or binary program.
```bash
type cmus
```sh
type cd
type ls
type -P ls
type -a cat
```
# Whereis the Program
Ask where the `angband` program is, along with all its configuration files:
Where is `grep` and all its configuration files?
`whereis angband`
Also `which` shows where a binary file (the program) is,
```bash
which cmus
```sh
whereis grep
```
# Search Instantly with `plocate`
Which one of these is the binary file which you actually use?
You can search every file on the computer instantly by installing `plocate`.
Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer.
Check how big the database is:
```bash
du -h /var/lib/plocate/plocate.db
```sh
which grep
```
Once you have the database, you can find nearly any file instantly.
# More
- Search for gifs: `locate .gif`
- Search for gifs in the `/usr/` directory: `locate /usr/ .gif`
- 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).
## Search More Places
`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go.
Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`.
By default, the `/mnt` directory is 'pruned' from the database.
So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file.
```bash
cat /etc/updatedb.conf
sudo sed 's#/mnt/##' /etc/updatedb.conf
sudo updatedb
plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'
```
- [Search instantly with `plocate`](data/search_system.md)

View File

@@ -8,13 +8,13 @@ Firstly, your `ls` is probably aliased to something.
Check it with:
```bash
```sh
alias ls
```
If the prompt shows some alias, then start by removing it:
```bash
```sh
unalias ls
```
@@ -23,24 +23,24 @@ Now we can begin.
Check the most recently modified file:
```bash
```sh
ls -t
```
Reverse this with `tac` to see the file which has been unmodified the longest:
```bash
```sh
ls -t | tac
```
Group files by extension:
```bash
```sh
ls -X
```
Sort largest files first:
```bash
```sh
ls -X
```

View File

@@ -1,36 +1,36 @@
---
title: "processes"
tags: [ "Basics" ]
tags: [ "basics" ]
---
# Proccesses
See running items in current terminal with
```bash
```sh
ps
```
or more with
```bash
```sh
ps -a
```
Or the entire system with
```bash
```sh
ps -e
```
Or the entire system with more information, BSD style, with:
```bash
```sh
ps aux
```
And then search for a particular program with
```bash
```sh
ps aux | grep cmus
```
@@ -40,19 +40,19 @@ Pause a job with ^z. Put it in the background with the '&' suffix.
List jobs in the current shell with
```bash
```sh
jobs
```
And then you can pull number 1 up again with
```bash
```sh
fg 1
```
Or continue running a stopped job with:
```bash
```sh
bg 1
```
@@ -62,31 +62,31 @@ This changes how nice a program is, from -20 to 19.
Install a program, but nicely, at nice value '10':
```bash
```sh
nice -10 sudo apt -y install libreoffice
```
Aggressively use Steam, with a nice value of '-13'.
```bash
```sh
nice --13 steam&
```
Find out that Steam's fucking everything up, so you change its nice value with 'renice':
```bash
```sh
renice --5 -p 3781
```
Nerf all of roach-1's processes:
```bash
```sh
renice 10 -u roach-1
```
... or the entire group
```bash
```sh
renice -14 -g hackers
```

View File

@@ -9,7 +9,7 @@ This & That
Refer to 'that last thing', and 'the first thing':
```bash
```sh
fortune -l > file1
cat !$ | tr -d u
diff !^ !$
@@ -17,7 +17,7 @@ diff !^ !$
**NB:** this can go wrong:
```bash
```sh
ls -l file1 file2
cat !^
```
@@ -36,7 +36,7 @@ Input Run-Commands (`~/.inputrc`)
Alias Expansion
---------------
```bash
```sh
echo '"\C- ": shell-expand-line' >> ~/.inputrc
exec bash
```
@@ -47,7 +47,7 @@ Try just `ls`, then 'Control + Space'.
Glob Expansion (`*`)
--------------------
```bash
```sh
echo '"\C-x": glob-expand-word' >> ~/.inputrc
exec bash
ls *<C-x>
@@ -63,13 +63,13 @@ Arbitrary Commands
Use `\n` as a 'newline' character to automatically press `<Return>`.
```bash
```sh
echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
exec bash
ls<C-y>
```
```bash
```sh
Control-l: "\C-u clear -x && ls\n"
exec bash
cd /etc/<C-l>
@@ -78,7 +78,7 @@ cd /etc/<C-l>
Readline as Vi
--------------
```bash
```sh
echo 'set editing-mode vi' >> ~/.inputrc
echo 'set keymap vi-insert' >> ~/.inputrc
exec bash
@@ -100,7 +100,13 @@ Try:
- `<Esc>kcw`
- ls -a<Esc>xxxx
Works with `python` too:
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>
@@ -115,7 +121,7 @@ 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.
```bash
```sh
sed '/ vi/d' ~/.inputrc
sed -i '/ vi/d' ~/.inputrc
@@ -130,14 +136,14 @@ 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:
```bash
```sh
echo 'set show-mode-in-prompt on' >> ~/.inputrc
exec bash
```
Set new symbols for normal and insert mode:
```bash
```sh
echo 'set vi-ins-mode-string " "' >> ~/.inputrc
echo 'set vi-cmd-mode-string " "' >> ~/.inputrc
```
@@ -148,33 +154,33 @@ Fuzzy Sort
Check your repos for `sk-im`, and install.
The program is called `sk`.
```bash
```sh
FUZZY=sk
```
If you don't have it, `fzy` or `fzf` should work the same way.
```bash
```sh
FUZZY=fzy
```
Find some 'read-config' files to check out:
```bash
```sh
find . -maxdepth 2 -name "*rc"
find . -maxdepth 2 -name "*rc" | $FUZZY
```
And read some:
```bash
```sh
PAGER='less -R'
$PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)"
```
Make the change long-term:
```bash
```sh
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"'
alias | grep rrc= >> ~/.bash_aliases
```

View File

@@ -7,7 +7,7 @@ When a program encounters a soft link, it will make a guess at whether it shoul
To make a soft link to a file in the current directory, linking is easy:
```bash
```sh
fortune > $file_1
ln -s $file_1 $link_1
```
@@ -27,14 +27,14 @@ dir_0/
Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file:
```bash
```sh
cd dir_1
ln -s ../file_1 link_1
```
The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file:
```bash
```sh
ln -s ../file_1 dir_2/link_2
```
@@ -54,7 +54,7 @@ dir_0/
Since it's just an address, you can delete the original file, then make another.
```bash
```sh
rm file_1
ls -l dir_1/
fortune > file_1
@@ -65,7 +65,7 @@ cat dir_1/link_1
Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link):
```bash
```sh
ln -s -f ../dir_1/file_1 dir_2/link_2
cat dir_2/link_2
```

View File

@@ -1,12 +1,12 @@
---
title: "time"
tags: [ "Basics" ]
tags: [ "basics", "time" ]
---
# systemd
Set time to synchronize with an ntp server:
```bash
```sh
timedatectl set-ntp true
```
@@ -18,7 +18,7 @@ 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:
```bash
```sh
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
```
@@ -28,41 +28,41 @@ sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
See local time, language and character settings with:
```bash
```sh
locale
```
List available locales with:
```bash
```sh
locale -a
```
To see additional locales which are available (but not necessarily installed):
```bash
```sh
cat /usr/share/i18n/SUPPORTED
```
Set a supported locale with:
```bash
```sh
locale-gen pl_PL.UTF-8
```
Then set that language, with:
```bash
```sh
LANG=pl_PL.UTF-8
```
... then reboot.
...then reboot.
# Network Time Protocol
Glimpse an overview with:
```bash
```sh
ntpq -p
```
@@ -73,6 +73,6 @@ Usually this is run as a service, so just start that service.
If your clock drifts too far from the right time, it will not reset happily.
For it to reset like this:
```bash
```sh
sudo ntpd -q -g -x -n
```

View File

@@ -28,7 +28,7 @@ Each description-line starts with a tab.
To represent a file structure as a nested series of markdown lists, you can try this horrifying `sed` one-liner:
```bash
```sh
tree -tf --dirsfirst --gitignore --noreport --charset ascii | \
sed -e 's/| \+/ /g' \
-e 's/[|`]-\+/ */g' \

View File

@@ -1,28 +1,28 @@
---
title: "users"
tags: [ "Basics" ]
tags: [ "basics" ]
---
# Basic Information
Let's get some entries with 'getent', e.g. passwd or group.
```bash
```sh
getent passwd
```
```bash
```sh
getent group
```
Obviously:
```bash
```sh
getent shadow
```
## Examples
```bash
```sh
sudo adduser maestro
```
@@ -30,71 +30,71 @@ add user 'maestro'
This depends upon the settings in the /etc/default/useradd file and /etc/login.defs
```bash
```sh
sudo useradd -m pinkie
```
add user 'pinkie' with a home directory
```bash
```sh
sudo adduser -m -e 2017-04-25 temp
```
add expiry date to user
```bash
```sh
userdel maestro
```
delete maestro
```bash
```sh
userdel -r maestro
```
delete maestro and hir homefolder
```bash
```sh
groups
```
find which group you are in
```bash
```sh
id
```
same
```bash
```sh
id -Gn maestro
```
Find which groups maestro is in
```bash
```sh
deluser --remove-home maestro
```
delete user maestro
```bash
```sh
usermod -aG sudo maestro
```
Add user maestro to group sudo:
```bash
```sh
cat /etc/passwd
```
list users' passwords (and therefore users)
```bash
```sh
groupadd awesome
```
@@ -104,33 +104,33 @@ Passwords are stored in /etc/shadow.
There are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
```bash
```sh
passwd -l bin
```
Lock the user 'bin'.
```bash
```sh
more /etc/passwd | grep games
```
we find the name, password and user id of the user 'games'. I.e. the password is 'x', and the user id is '5'. The password is an impossible hash, so no input password could match.
```bash
```sh
groupdel learners | delete the group 'learners'
```
```bash
```sh
gpasswd -d pi games | remove user 'pi' from the group 'games'
```
```bash
```sh
id games
```
find the id number of group 'games' (60)
```bash
```sh
usermod -aG sudo maestro
```
@@ -156,7 +156,7 @@ Alternatively, change the shell in /etc/passwd.
Usermod also lets you change a user's username:
```bash
```sh
usermod -l henry mark
```
@@ -170,7 +170,7 @@ usermod -L henry
-G or -groups adds the user to other groups:
```bash
```sh
usermod -G sudo henry
```
@@ -186,13 +186,13 @@ In /etc/group, a group file may look like this:
We can use groupmod, like like usermod, e.g. to change a name:
```bash
```sh
groupmod -n frontoffice backoffice
```
Delte a group:
```bash
```sh
groupdel frontoffice
```
@@ -200,37 +200,37 @@ groupdel frontoffice
See list of logged on users.
```bash
```sh
w
```
See last logons:
```bash
```sh
last
```
or all logon attempts, including bad attempts:
```bash
```sh
lastb
```
List recently accessed files:
```bash
```sh
last -d
```
See files opened by steve
```bash
```sh
lsof -t -u steve
```
See files opened by anyone but steve
```bash
```sh
lsof -u ^steve
```
@@ -240,19 +240,19 @@ Some files can be executed by people as if they had super user permissions, and
Let's start with files executable by user:
```bash
```sh
sudo find / -type f -perm -g=s -ls
```
And then those executable by the group:
```bash
```sh
find / -type f -perm -g=s -ls
```
And finally, worrying files, executable by anyone as if sie were the owner:
```bash
```sh
find / -xdev \( -o -nogroup \) -print
```
@@ -260,7 +260,7 @@ Then have a look at resource usage per user.
# SGID
```bash
```sh
sudo chmod u+s process.sh
```

View File

@@ -11,14 +11,14 @@ This is extremely powerful.
If you ever want to automatically install something which persistently nags you with `do you want to do the thing? [y/N]?`, then you can just pipe `yes` into that program, and it will answer 'yes' to all questions.
```bash
```sh
yes | $INSTALL_SCRIPT_FILE.sh
```
This works best for disposable systems, like VMs or containers.
Try this on a live system, and you might find out that you should have read that message fully.
```bash
```sh
yes | yay
```

View File

@@ -1,57 +0,0 @@
---
title: "profanity"
tags: [ "Chat", "OTR" ]
---
# otr
'Off The Record' encryption seems mostly dead to me.
But this is what I did, back in the day...
Install libotr-dev or libotr5-dev or whatever..
```
sudo apt -y install lib5otr-dev
```
Make your otr keys.
```
/otr gen
```
Then you can start an otr converstation.
```
/otr start bob@jobbies.org
```
Or if you already have a conversation windows open, switch to our using:
```
/otr
```
Finally, verify!
```
/otr question "Who are you?" bob
```
Bob is verified upon the answer, 'bob'.
### OTR Finger Prints
Get yours with
```
/otr myfp
```
```
/otr theirfp
```
```
/otr myfp
```

View File

@@ -1,6 +1,6 @@
---
title: "profanity"
tags: [ "Chat", "omemo" ]
tags: [ "chat", "omemo" ]
---
# Setup (Commands)
@@ -142,4 +142,3 @@ You can ensure omemo automatcally turns on:
```
---
'OTR' encryption is mostly dead, but you can find the old instructions [here](profanity-otr).

View File

@@ -1,29 +1,29 @@
---
title: "wgetpaste"
tags: [ "Chat" ]
tags: [ "chat" ]
---
See available pastebins:
```bash
```sh
wgetpaste -S
```
Upload script.sh to bpaste:
```bash
```sh
wgetpaste -s bpaste script.sh
```
Input clipboard to dpaste with the heading "Title"
```bash
```sh
wgetpaste -s dpaste -d Title -x
```
Paste in the file then load the result to the right-hand clipboard:
```bash
```sh
wgetpaste -s dpaste -X
```

View File

@@ -1,6 +1,6 @@
---
title: "Archives"
tags: [ "tar", "backups" ]
tags: [ "tar", "backups", ".tgz", "tar.gz" ]
---
# `tar`
@@ -8,22 +8,21 @@ tags: [ "tar", "backups" ]
Combine many files and directories into a single t-archive file.
```bash
```sh
tar cf "$ARCHIVE".tar $DIR
```
You can remember this with the mnemonic '*C*reate *F*ile'.
Unfortunately, this stores the full file path, so making a tar archive of `/etc/nginx/` will store `etc/nginx` (without the leading `/`.
Unfortunately, this stores the full file path, so making a tar archive of `/etc/nginx/` will store `etc/nginx` (without the leading `/`).
It's often better to tell tar which path to start from using the `-C` flag.
```bash
```sh
tar cf "$ARCHIVE".tar -C /etc/ nginx
```
Check the contents of your archive with:
```bash
```sh
tar tf "$ARCHIVE".tar
```
@@ -31,7 +30,7 @@ If you want to store 'everything in a directory', then using `*` will not work,
Instead, you can store the target in a variable:
```bash
```sh
files=$(ls /etc/nginx)
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
```
@@ -40,7 +39,9 @@ tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
Extract the tar archive with
> tar xf "$ARCHIVE".tar
```sh
tar xf "$ARCHIVE".tar
```
You can remember this with the mnemonic 'e*X*tract *F*ile'.
@@ -48,7 +49,7 @@ You can remember this with the mnemonic 'e*X*tract *F*ile'.
Create a zip-compressed archive with the `z` flag.
```bash
```sh
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
```
@@ -60,18 +61,16 @@ You can use any file ending you want, but sane people like to use '.tgz' or '.ta
Make archive:
```bash
PASSWORD=my_password
```
```bash
7za a -tzip -p$PASSWORD -mem=AES256 $ARCHIVE.zip $FILE_1 $FILE_2
```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:
```bash
```sh
7za x archive.zip
```

View File

@@ -1,11 +1,11 @@
---
title: "unison"
tags: [ "Backups" ]
tags: [ "backups", "synch" ]
---
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).
```bash
```sh
unison -version
```
@@ -13,14 +13,14 @@ Create the `~/.unison` directory on both machines.
Make a job called `backup`:
```bash
```sh
JOB=backup
```
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
```bash
```sh
echo "
auto = true
root=$HOME
@@ -42,7 +42,7 @@ The last command means it will ignore any file with a name ending in `.flac`.
The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead.
Or you can deleted that line in the `.prf` file and run it with a flag:
```bash
```sh
unison -batch *backup*.prf
```

View File

@@ -1,8 +1,26 @@
---
title: "Base 16"
tags: [ "Data" ]
tags: [ "data" ]
---
```bash
Base 16 numbers often use `0x` at the start, so '10' just means '10', but `0x10` means '10 in base 16' which means '16'.
For small numbers, use `printf`.
```sh
printf "%x" $NUMBER
```
For any number, use `bc`.
```sh
fortune | md5sum | cut -d' ' -f1 | tr [:lower:] [:upper:] | bc
```
- Inputting base 16 uses `ibase=16`.
- Outputting base 10 uses `ibase=10`
```sh
echo 'ibase=16;' $(echo cbb478ac825f0dce7671254be035d0bc | tr [:lower:] [:upper:]) | bc
```

View File

@@ -5,5 +5,10 @@ tags: [ "data", "calendar", "daylight savings" ]
## Setup
The UK government keeps an ics file with clock, [here](https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics).
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
```

View File

@@ -9,10 +9,10 @@ Install `opensmtpd` (or similar), then `ncat` or `nc` or `netcat` (this mysterio
Start the `opensmtpd` service, then use netcat to speak with the mail-daemon:
```
```sh
nc localhost 25
```
The computer should respond with code `220`, which means 'I am listening'.
> 220 hex ESMTP OpenSMTPD
@@ -40,7 +40,7 @@ Tell the mail daemon who you are in this format.
Then tell it who you're sending to.
```
```sh
RCPT TO: <www@dmz.rs>
```
@@ -67,7 +67,7 @@ You will find the email under `/var/spool` or `/var/mail` or similar.
If unsure, just take a part of your email, like `FRAGMENT="turn off server please"`, then `grep` for it:
```bash
```sh
sudo grep -r $FRAGMENT /var/spool/*
```

View File

@@ -1,17 +1,17 @@
---
title: "exiftool"
tags: [ "Metadata" ]
tags: [ "metadata", "exifdata" ]
---
Find metadata.
Find metadata:
```bash
exiftool image.jpg
```sh
exiftool "$file".jpg
```
Find info on all images in current directory.
Find info on all `.png` images in current directory.
```bash
```sh
exiftool -ext .png .
```
@@ -19,22 +19,14 @@ You can make this recurring with the -r switch.
And overwrite all metadata:
```bash
```sh
exiftool -all= -overwrite_original -ext jpg .
```
(NB: This does not work on pdf data. See [here](pdf_erasure.md) for erasing all pdf data)
Or just GPS data:
```bash
```sh
exiftool -gps:all= *.jpg
```
You can also use the imagemagick tool:
```bash
identify -verbose
```

View File

@@ -6,41 +6,40 @@ tags: [ "data" ]
## New Machines
```bash
```sh
git config --global user.email "$YOUR_EMAIL"
```
```bash
```sh
git config --global user.name "$YOUR_NAME"
```
# New Git
Start a git in directory `$DIR`:
Decide on algorithm:
```bash
mkdir $DIR && cd $DIR
- 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}
```
```bash
git init
```
Make a file explaining what the project does, and tell `git` to track it:
Make a file explaining what the project does:
```bash
vim README.md
```
Add this to the git:
```bash
```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:
```bash
```sh
git commit
```
@@ -48,17 +47,17 @@ git commit
Once you make a change to some file, add it and make a commit explaining it.
```bash
```sh
git add $FILE
```
```bash
```sh
git commit -m"change $FILE"
```
Check your history:
```bash
```sh
git log
```
@@ -69,20 +68,20 @@ Give it the same name as the `$DIR` directory, above.
Add this as a remote:
```bash
```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":
```bash
```sh
git push -u master origin
```
If someone makes a change on the remote, pull it down with:
```bash
```sh
git pull
```
@@ -91,31 +90,31 @@ git pull
A branch is a full copy of the project to test additional ideas.
You can make a new branch called 'featurez' like this:
```bash
```sh
git branch $FEATURE_BRANCH
```
Have a look at all your branches:
```bash
```sh
git branch
```
Switch to your new branch:
```bash
```sh
git checkout $FEATURE_BRANCH
```
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
```bash
```sh
git branch -D $FEATURE_BRANCH
```
Or if it's a good branch, push it to the remote:
```bash
```sh
remote=origin
git push $remote $FEATURE_BRANCH
```
@@ -124,13 +123,13 @@ git push $remote $FEATURE_BRANCH
Once you like the feature, merge it into the main branch. Switch to master then merge it:
```bash
```sh
git merge $FEATURE_BRANCH
```
And delete the branch, as you've already merged it:
```bash
```sh
git branch -d $FEATURE_BRANCH
```
@@ -138,7 +137,7 @@ git branch -d $FEATURE_BRANCH
## Pulling another git repo into a subtree
```bash
```sh
git subtree add -P config git@gitlab.com:bindrpg/config.git master
```
@@ -146,27 +145,27 @@ git subtree add -P config git@gitlab.com:bindrpg/config.git master
## Delete All History
```bash
```sh
git checkout --orphan temp
```
```bash
```sh
git add -A
```
```bash
```sh
git commit -am "release the commits!"
```
```bash
```sh
git branch -D master
```
```bash
```sh
git branch -m master
```
```bash
```sh
git push -f origin master
```
@@ -174,21 +173,21 @@ Gitlab requires more changes, such as going to `settings > repository` and switc
## Clean up Bloated Repo
```bash
```sh
git fsck --full
```
```bash
```sh
git gc --prune=now --aggressive
```
```bash
```sh
git repack
```
## Find Binary Blobs
```bash
```sh
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \

View File

@@ -0,0 +1,22 @@
---
title: "Commit for Another"
tags: [ "data", "git" ]
---
You can make Alice the author, while you are still the commiter:
```sh
name="Alice Bobinson"
email="alice@email.com"
git add ${file}
git commit --author="${name} <${email}>"
```
Or, make Alice both the committer and the author:
```sh
git -c user.name="${name}" -c user.email="${email}" commit -m "${message}"
```

View File

@@ -1,24 +1,73 @@
---
title: "git-lfs"
tags: [ "data" ]
tags: [ "data", "git" ]
requires: [ "git" ]
---
Install, and add with
Git Large File Storage ('LFS') needs to change your `~/.gitconfig` to check out those binary files:
```bash
```sh
cat ~/.gitconfig
git lfs install
cat ~/.gitconfig
```
Then track some filetype with:
Then track some filetypes with:
```bash
git lfs track "\*.ttf"
```sh
cd $git_repository
ext=ttf
git lfs track "*.$ext"
```
Or a directory with:
```bash
```sh
git lfs track "images/"
```
All changes require adding `.gitattributes`.
Track the changes to `.gitattributes`:
```sh
git status
git add .gitattributes
git commit -m "add $ext to lfs"
```
## Bash Completion
If bash completion does not work, you'll have to add it:
```sh
git lfs completion bash | sudo tee /usr/share/bash-completion/completions/git-lfs
```
## Trouble Shooting
You have some file "$FILE".png, which has some problem.
Check the filetype:
```sh
file "$FILE".png
```
This should say the type is 'image'.
If it says the type is 'text', then this file is really just a reminder to `git-lfs` to check out that file.
Check `git-lfs` is expecting that file:
```sh
git lfs status
git lfs ls-files
```
...then try these commands, and check the filetype again:
```sh
git lfs fetch --all
git lfs fsck
git lfs checkout
git lfs status
```

69
data/git/git_stash.md Normal file
View File

@@ -0,0 +1,69 @@
---
title: "git stash"
tags: [ "data", "git" ]
requires: [ "git" ]
---
Save file-changes without committing anything.
Change a file:
```sh
file=README.md
fortune >> ${file}
git diff
git stash save
```
List which stashes you have:
```sh
git stash list
stash@{1}: WIP on master: c21f102 init git
```
Make a new file, then stash it:
```sh
otherfile=file.log
fortune > ${otherfile}
git add ${otherfile}
stashname=logfile
git stash save ${stashname}
```
Now you can see two stashed changes, and the most recent has a name:
```sh
git stash list
stash@{0}: On master: logfile
stash@{1}: WIP on master: c21f102 init git
```
You can delete a stash by referring to its index number, or name (if it has one).
```sh
choice=1
git stash drop ${choice}
choice=${stashname}
git stash drop ${choice}
```
Or just run `git stash drop` to remove the most recent (labelled `{0}`).
Return stashed changes with an index number (or the most recent).
```sh
git stash pop ${choice}
```
Delete all stashes:
```sh
git stash clear
```

View File

@@ -5,7 +5,7 @@ tags: [ "data", "git" ]
Check out the sample hooks:
```bash
```sh
cd $GIT_REPO
ls .git/hooks
head .git/hooks/pre-commit.sample
@@ -13,7 +13,7 @@ head .git/hooks/pre-commit.sample
Add a hook to check the shell scripts in `$GIT_REPO` before making a commit:
```bash
```sh
echo '#!/bin/sh
shellcheck *.sh' > .git/hooks/commit-msg
chmod u+x .git/hooks/commit-msg

View File

@@ -1,5 +1,5 @@
---
title: "git"
title: "git subtree"
tags: [ "data", "git", "subtree" ]
---
@@ -10,7 +10,7 @@ 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.
```bash
```sh
git subtree split --prefix=sub-1 -b sub
```
@@ -18,7 +18,7 @@ If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/
Then go and create a new git somewhere else:
```bash
```sh
cd ..;mkdir sub-1;cd sub-1;git init --bare
```
@@ -28,7 +28,7 @@ git push ../subtest sub:master
Finally, you can clone this repo from your original.
```bash
```sh
git clone ../subtest
```

View File

@@ -1,6 +1,6 @@
---
title: "gpg"
tags: [ "data", "GPG" ]
tags: [ "data", "gpg" ]
---
- [Setup](gpg/basics.md)

View File

@@ -6,7 +6,7 @@ tags: [ "data", "GPG" ]
Generate keys:
```bash
```sh
gpg --full-generate-key
```
@@ -14,7 +14,7 @@ Follow the guide.
# Encrypting a file
```bash
```sh
gpg -r malinfreeborn@posteo.net -e file
```
@@ -25,7 +25,7 @@ Check you have an encrypted version of your file.
# Changing Expiration Dates
```bash
```sh
gpg --list-keys
# or...
gpg -k
@@ -37,13 +37,13 @@ gpg -k
Make a password with a password (cypher encryption).
```bash
```sh
gpg -c --output passwords.txt
```
or
```bash
```sh
gpg -c > passwords.txt
```
@@ -53,7 +53,7 @@ Write message then stop with Ctrl+d.
Get the message back out the file with:
```bash
```sh
gpg -d passwords.txt
```
@@ -61,13 +61,13 @@ gpg -d passwords.txt
Search for a key at any key store:
```bash
```sh
gpg --search-keys nestorv
```
Once you've made a decision about someone:
```bash
```sh
gpg --list-keys
```
@@ -86,13 +86,13 @@ This is a fingerprint.
You can now decide the trust level (this stays on your computer).
```bash
```sh
gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
```
Once you're in the interface, type `trust`.
```bash
```sh
gpg --sign-key alice@posteo.net
```
@@ -104,7 +104,7 @@ This system relies on a ring of people swapping key information.
Send those trusted keys up to a server, so people can see you have verified them:
```bash
```sh
gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
```
@@ -125,7 +125,7 @@ keyserver hkps://keys.mailvelope.com
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).
```bash
```sh
gpg --refresh-keys
```
@@ -135,12 +135,12 @@ You can use the [crontab](../../basics/cron.md) to refresh keys, but this will m
Your public key:
```bash
```sh
gpg --output me.gpg --armor --export
```
Alternatively:
```bash
```sh
gpg --export -a person@email.tld > my_key.pub
```

View File

@@ -1,5 +1,5 @@
---
title: "gpg"
title: "gpg with vim"
tags: [ "vim", "data", "GPG" ]
requires: [ "GPG Basics", "vim basics" ]
---

View File

@@ -1,6 +1,6 @@
---
title: "groff"
tags: [ "Data" ]
tags: [ "data", "logic" ]
---
# Basic Documents

View File

@@ -0,0 +1,19 @@
---
title: "Interactive String Substitution"
tags: [ "data", "vim", "substitution" ]
---
Want to find and replace, but also confirm each instance?
```sh
vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file}
```
Notice that double-quotes (`"`) in the first command (`-c`).
Alternatively, check with an example string:
```sh
sed "s/${pattern}/ARGLEBARGLE/g" ${file} | grep 'ARGLEBARGLE'
```

13
data/json.md Normal file
View File

@@ -0,0 +1,13 @@
---
title: "ijq"
tags: [ "data", "json", "TUI" ]
---
Analyse `json` easier with `ijq`.
```sh
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd > host.json
ijq !$
```
If you get stuck, try adding `.[]`.

View File

@@ -1,60 +1,52 @@
---
title: "khard"
tags: [ "Data" ]
tags: [ "data" ]
---
Get the basic config:
```bash
```sh
mkdir ~/.config/khard
```
```bash
```sh
cp /usr/share/doc/khard/examples/khard/khard.conf.example ~/.config/khard.conf
```
Short list
```bash
```sh
khard list
```
Longer list
```bash
```sh
khard show
```
Show from addressbook 'work'
```bash
```sh
khard list -a work
```
Make a new contact in address book 'family'
```bash
```sh
khard new -a family
```
```bash
```sh
khard edit grampa
```
```bash
```sh
khard remove bob
```
Move contact 'nina' from 'work' to 'home' address book.
```bash
```sh
khard move -a home nina -A work
```
## Advanced
Merge:
```bash
khard merge [-a source_abook] [-u uid|search terms [search terms ...]] [-A target_abook] [-U target_uid|-t target_search_terms]
```

View File

@@ -4,11 +4,11 @@ tags: [ "RSS" ]
---
Create the configuration directory before you start, and add at least 1 URL.
```bash
```sh
mkdir ~/.config/newsboat
```
```bash
```sh
echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
```
@@ -28,7 +28,7 @@ You can input a Youtube channel by adding this, with the channel's ID at the end
To get the channel ID without hunting:
```bash
```sh
curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
```

View File

@@ -1,42 +1,42 @@
---
title: "pass"
tags: [ "data" ]
requires: "GPG Basics"
---
[Video instructions](https://www.hooktube.com/watch?v=hlRQTj1D9LA)
Setup [gpg](./gpg.md) keys.
Show your gpg secret it:
```bash
```sh
gpg --list-secret-keys
```
Then use the id number under `sec` to make a pass repo:
```bash
```sh
KEY="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
```
```bash
```sh
pass init $KEY
```
To add a basic password, e.g. for `$WEBSITE`:
```bash
```sh
pass $WEBSITE
```
To insert a multiline password, e.g. with a login name:
```bash
```sh
pass add -m $WEBSITE
```
Remove a password:
```bash
```sh
pass rm $WEBSITE
```

View File

@@ -2,7 +2,8 @@
title: "pdf to txt"
tags: [ "data", "pdf", "ocr" ]
---
How to translate pdf book images to text (results are very poor, and will need lots of corrections).
How to translate pdfs to text (results are very poor, and will need lots of corrections).
## Dependencies
@@ -12,13 +13,13 @@ Arch: tesseract-data-eng and poppler-utils
## Script
```bash
```sh
pdftoppm -png *file*.pdf test
```
```bash
for x in \*png; do
tesseract -l eng "$x" - >> *out*.txt
```sh
for x in *png; do
tesseract -l eng "$x" - >> out.txt
done
```

View File

@@ -1,8 +1,11 @@
---
title: "PDF Metadata Erasure"
tags: [ "Metadata", "Ghost Script" ]
tags: [ "metadata", "ghost script", "gs", ".pdf" ]
---
You cannot erase pdf metadata with `exiftool` (it only *appends* your changes).
To delete pdf metadata, you'll need `gs`.
Make a text file called 'pdfmark.txt'.
@@ -20,6 +23,6 @@ Make a text file called 'pdfmark.txt'.
Then run:
```bash
```sh
gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt
```

View File

@@ -1,6 +1,7 @@
---
title: "radicale and nginx"
tags: [ "data", "calendar" ]
requires: [ "nginx", "certbot" ]
---
Check before you start:
@@ -15,7 +16,7 @@ The standard `radicale` package should come with a nice `systemd` service file.
If the service comes already-started, stop it immediately:
```bash
```sh
sudo systemctl stop radicale
```
@@ -39,7 +40,7 @@ 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`.
```bash
```sh
PASS="$(xkcdpass)"
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users
echo "Your username is $USER"
@@ -92,7 +93,7 @@ sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/
Finally, replace the example `DOMAIN` with your actual domain name.
```bash
```sh
DOMAIN=whatever.com
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
```
@@ -101,18 +102,18 @@ sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
Check nginx is happy:
```bash
```sh
sudo nginx -t
```
You will almost certainly need a new SSL certificate for the site:
```bash
```sh
sudo certbod -d cal.$DOMAIN
```
Start or restart both services:
```bash
```sh
sudo systemctl start radicale
sudo systemctl restart nginx
```

View File

@@ -44,6 +44,9 @@ recset -f "$new_field" --delete $database
- [Extended example](recfiles/extended.md)
- [Playing with board games data](recfiles/Board_Games.md)
- [Playing with IP addresses](recfiles/IP_ASN.md)
- [Manage LaTeX Bibliographies](recfiles/bibliography.md)
- [Fixes](recfiles/recfixes.md)
# Resources

View File

@@ -0,0 +1,121 @@
---
title: "Recfile Bibliography for TeX"
tags: [ "data", "database", "recfiles", "tex" ]
requires: [ "Recfiles", "TeX", "Makefile" ]
---
Store your bibliography in a `recfile` database, then extract any part with `make`.
For example, you could store books like this in `bibliography.rec`:
```recfile
%rec: book
%key: slug
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
```
Run `make book` to extract `book.bib`, ready for LaTeX to use:
```bib
@book{thinkingexperience,
author = {H. H. Price},
title = {Thinking and Experience},
year = {1953},
publisher = {Harvard University Press, Cambridge},
}
@book{inventingrightwrong,
author = {John Leslie Mackie},
title = {Inventing Right and Wrong},
year = {1997},
publisher = {Penguin Books, England},
}
```
The `makefile` syntax is just a few lines (though admittedly employs some garbled shell-crud):
```make
bibs != grep -Po '%rec: \K.*' bibliography.rec
bibfiles = $(patsubst %, %.bib, $(bibs))
$(bibfiles): %.bib: bibliography.rec
recsel $< -t $(basename $@) |\
sed 's/slug: \(.*\)/@$(basename $@){\1,/g' |\
sed 's/^\(\b.*\b\): \(.*\)/ \1 = {\2},/gI' |\
sed 's/^$$/}\n/g' > $@
echo '}' >> $@
```
Here's a longer `bibliography.rec` file, which can also produce `article.bib`:
```recfile
%rec: book
%key: slug
%type: year int
%constraint: year > -2000
%sort: year month
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
slug: metaphysicscontemporaryintro
author: Michael J. Loux
title: Metaphysics: A Contemporary Introduction
year: 1998
publisher: Routledge, London
slug: pluralityworlds
author: David Lewis
title: On the Plurality of Worlds
publisher: Blackwell Publishing, Oxford
year: 2001
%rec: article
%key: slug
%sort: year month
slug: genuinerealisttheory
author: John Divers
title: A Genuine Realist Theory of Advanced Modalizing
year: 1999
pages: 217240
month: april
journaltitle: Mind
uri: https://academic.oup.com/mind/article-abstract/108/430/217/975258?redirectedFrom=fulltext
volume: 108
publisher: Harvard University Press, Cambridge
slug: twokindsmentalrealism
author: Tam\'{a}s Demeter
title: Two Kinds of Mental Realism
year: 2009
pages: 40:59-71
uri: https://www.researchgate.net/profile/Tamas_Demeter2/publication/41554923_Two_Kinds_of_Mental_Realism/links/0deec53247f5a4ae21000000.pdf
month: august
journaltitle: Journal for General Philosophy of Science
volume: 30
publisher: Harvard University Press, Cambridge
```

View File

@@ -7,7 +7,7 @@ tags: [ "data", "database", "recfiles" ]
Make a database for your boardgames, specifying only one field and value:
```bash
```sh
database=games.rec
n=Name
g=Vojvodina
@@ -18,21 +18,21 @@ recsel $database
Insert a few more, with the estimated playtime:
```bash
```sh
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:
```bash
```sh
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`.
```bash
```sh
f=played
v=yes
recset -f $f -a $v $database
@@ -40,7 +40,7 @@ recset -f $f -a $v $database
...but the field is wrong, it should have a capital letter:
```bash
```sh
new_field=Played
recset -f $f --rename $new_field
```
@@ -49,19 +49,19 @@ recset -f $f --rename $new_field
Check how many records the database has:
```bash
```sh
recinf $database
```
Look at just the games you've never played:
```bash
```sh
recsel --expression="Played = 'no'" $database
```
Print how many, then just print the names:
```bash
```sh
recsel -e "Played = 'no'" --count $database
recsel -e "Played = 'no'" --print=Name $database
```
@@ -70,7 +70,7 @@ recsel -e "Played = 'no'" --print=Name $database
To change a game's `Played` field from `no` to `yes`, use `recset` to specify the number, and change that field.
```bash
```sh
num=0
f=Played
value=yes
@@ -80,14 +80,14 @@ recset --number=$num -f $f --set=$value $database
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
```bash
```sh
recset -e "Playtime = 40" -f Max_Players --set 50 games.rec
```
This doesn't work, because that field does not exist.
You can `--set-add` the field, to add it wherever it does not exist.
```bash
```sh
recset -e "Playtime = 40" -f Max_Players --set-add 50 games.rec
```
@@ -95,14 +95,14 @@ recset -e "Playtime = 40" -f Max_Players --set-add 50 games.rec
Remove `Played` record from first game:
```bash
```sh
num=0
recset --number=$num -f Played --delete $database
```
You can comment the line instead of deleting it:
```bash
```sh
num=1
recset --number=$num -f Played --delete $database
recsel $database
@@ -111,7 +111,7 @@ cat $database
Delete an entire record:
```bash
```sh
num=2
recdel --number=$num $database
```

16
data/recfiles/ip_asn.md Normal file
View File

@@ -0,0 +1,16 @@
---
title: "IP Addresses with Recfiles"
tags: [ "data", "recfiles", "games" ]
requires: "Recfiles"
---
## Download the Database
Download the csv data, and separate the ipv4 data from the ipv6.
```sh
curl -Lo ips.zip 'https://www.kaggle.com/api/v1/datasets/download/ipinfo/ipinfo-country-asn'
unzip -p ips.zip country_asn.csv | csv2rec | recsel -e "start_ip ~ '\.'" > ipv4.rec
unzip -p ips.zip country_asn.csv | csv2rec | recsel -e "start_ip ~ '::'" > ipv6.rec
```

33
data/recfiles/recfixes.md Normal file
View File

@@ -0,0 +1,33 @@
---
title: "Recfixes"
tags: [ "data", "recfiles" ]
requires: "Recfiles"
---
Sometimes `recsel` chokes on a large query, and you need to break the query into chunks with a pipe.
This Kickstarter file has 374,853 records.
Here's the chonky query:
```sh
recsel kick.rec -e "Category = 'Games'" -p "Subcategory,Avg(Goal)" -G Subcategory
```
It breaks down like this:
| Chunk | Meaning |
|:-----------------------------:|:---------------------------------------------:|
| `recsel kick.rec` | Select records from `kick.rec` |
| `-e "Category = 'Games'"` | Select only records where Category = 'Games' |
| `-p "Subcategory,Avg(Goal)"` | Print the Subcategory and average goal |
| `-G "Subcategory"` | Group by subcategory |
Two ways to break the query apart:
```sh
recsel kick.rec -e "Category = 'Games'" | recsel -p "Subcategory,Avg(Goal)" -G "Subcategory"
recsel kick.rec -e "Category = 'Games'" > games.rec
recsel games.rec -p "Subcategory" -G "Subcategory"
```

View File

@@ -1,6 +1,7 @@
---
title: "sc-im"
tags: [ "TUI", "data" ]
tags: [ "TUI", "data", "spreadsheet", ".csv" ]
requires: [ "vim basics" ]
---
- [Sample file](sc-im/sample.sc)
@@ -14,7 +15,7 @@ Change this with `:set autowrap`.
Make `sc-im` always autowrap:
```bash
```sh
mkdir .config/sc-im/bash
echo 'set autowrap' >> .config/sc-im/scimrc
```

View File

@@ -0,0 +1,13 @@
---
title: "Convert Spreadsheets"
tags: [ "data", "sc-im" ]
---
Convert between spreadsheet formats with `sc-im`.
```sh
sc-im --quiet --quit_afterload --nocurses --export_csv ${file}.xlsx
sc-im --quiet --quit_afterload --nocurses --export_tab ${file}.sc
sc-im --quiet --quit_afterload --nocurses --export_mkd ${file}.csv
sc-im --quiet --quit_afterload --nocurses --export_txt ${file}.tsv
```

49
data/search_system.md Normal file
View File

@@ -0,0 +1,49 @@
---
title: "Search System"
tags: [ "data", "search", "locate", "plocate" ]
requires: "cron"
---
You can search every file on the computer instantly by installing `plocate`.
Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer.
Check how big the database is:
```sh
du -h /var/lib/plocate/plocate.db
```
Once you have the database, you can find nearly any file instantly.
- Search for gifs: `locate .gif`
- Search for gifs in the `/usr/` directory: `locate /usr/ .gif`
- 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).
## Search More Places
`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go.
Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`.
By default, the `/mnt` directory is 'pruned' from the database.
So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file.
```sh
su root
cat /etc/updatedb.conf
sed -i 's#/mnt/##' /etc/updatedb.conf
updatedb
exit
```
Now you can search in `/mnt` for films:
```sh
plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'
```

View File

@@ -0,0 +1,33 @@
---
title: "Search Video Audio"
tags: [ "data", "video" ]
---
Check subtitles available:
```sh
url='https://videos.domainepublic.net/videos/watch/d9567d5b-1add-477c-bce3-a58cef84c28c'
yt-dlp --list-subs "$url" | grep --max-count=1 '^en'
```
The original language often displays with `-orig`, e.g. `en-orig (Original)`.
```
Language Formats
ar vtt
az vtt
bg vtt
ca vtt
cs vtt
da vtt
de vtt
el vtt
en vtt
```
Search youtube.com for videos on a topic, and download subtitles:
```sh
url="$(ytfzf -I l "$search" )" && \
yt-dlp --write-subs --sub-format 'ass/srt/best/vtt' --sub-langs "en.*" --skip-download "$url"
```

View File

@@ -7,7 +7,7 @@ You can share parts of a secret with multiple people, so only some of them need
Install `ssss`, then decide on the total number of secrets (`N`), and the threshold of people who must share their shard of the secret in order to reveal the secret.
```bash
```sh
N=5
T=3
FILE=secret.txt
@@ -17,7 +17,7 @@ Each shard is a line inside secret.txt.
Check it's working:
```bash
```sh
head -n $T $FILE | ssss-combine -t $T
tail -n $T $FILE | ssss-combine -t $T
```

View File

@@ -0,0 +1,24 @@
---
title: "Soft Serve Maintenance"
tags: [ "data", "git server", "maintenance" ]
requires: [ "git", "nginx" ]
---
Over time git repositories become bloated with old data, but never get cleaned.
I can't find an official way to clean up the crud, so I did this:
```sh
usermod -aG soft-serve $USER
# Log out and back in for this to take effect.
cd /var/lib/soft-serve/data/repos
sudo chmod -R g+w *
git config --global --add safe.directory '*'
du -sh *.git
for repo in *.git; do
git -C "$repo" gc
done
du -sh *.git
$EDITOR ~/.gitconfig
# You should remove having everything marked 'safe'.
```

View File

@@ -1,6 +1,7 @@
---
title: "Soft Serve through https"
tags: [ "data", "git", "lfs" ]
tags: [ "data", "git server", "lfs" ]
requires: [ "git", "nginx" ]
---
## `http` Setup
@@ -29,11 +30,11 @@ http:
Restart the `soft-serve` service, then check it's working by cloning from localhost:
```bash
```sh
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).
@@ -67,3 +68,4 @@ Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard ce
}
```

8
data/soft.md Normal file
View File

@@ -0,0 +1,8 @@
---
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

@@ -5,7 +5,7 @@ tags: [ "data" ]
Work with a database:
```bash
```sh
sqlite3 "$FILE".sqlite3
```
Compress the database:

34
data/task/contexts.md Normal file
View File

@@ -0,0 +1,34 @@
---
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,23 +1,35 @@
---
title: "task"
tags: [ "Organization" ]
title: "Taskwarrior"
tags: [ "data", "organization" ]
---
Set up the configuration file:
```bash
```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:
```bash
```sh
task add update linux
```
See which task is next:
```bash
```sh
task next
```
@@ -25,13 +37,13 @@ Note the id number.
Mark a task as started:
```bash
```sh
task start 1
```
Once finished:
```bash
```sh
task 1 done
```
@@ -39,23 +51,21 @@ task 1 done
Add a project:
```bash
```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
task add pro:house.paint buy red paint
task add pro:house.paint buy black paint
task add pro:house.paint buy brushes
for t in "buy red paint" "buy black paint" "buy brushes" ; do
task add pro:house.paint $t
done
```
## Summary
```bash
```sh
task pro:house sum
```
```bash
task burndown.daily pro:house
```
@@ -63,69 +73,33 @@ The summaries will show how fast a project is being completed, and when you can
# Tags
```bash
```sh
task add +buy toothbrush
```
You can then see only tasks which involve buying something with:
```bash
task +buy
```
# Contexts
Set three contexts by their tags:
```bash
task context define work +sa or +hr
```
```bash
task context define study +ed or +void or +rat
```
```bash
task context define home -sa -hr -ed -void -rat
```
Change to the first context.
```bash
task context work
```
Then stop.
```bash
task context none
```
# Review
View list of tasks completed in the last week:
```bash
```sh
task end.after:today-1wk completed
```
# User Defined Attributes
Make a UDA 'size'.
Define a new attribute for tasks called 'size'.
The 'user defined attribute' (UDA) needs a `type` and `label`.
```bash
```sh
task config uda.size.type string
```
```bash
task config uda.size.label Size
```
You can also ensure task tasks can only be `large`, `medium`, or `small`, then set a default.
```bash
```sh
task config uda.size.values large,medium,small
```
```bash
uda.size.default=medium
```
@@ -133,7 +107,7 @@ uda.size.default=medium
This command shows tasks I'm most interested in:
```bash
```sh
task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
```

View File

@@ -0,0 +1,20 @@
---
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,18 +1,18 @@
---
title: "timew"
tags: [ "Data" ]
title: "timewarrior"
tags: [ "data", "tracking", "time", "timew" ]
---
# Summaries
Try:
```bash
```sh
timew summary :yesterday
```
You can also use :week, :lastweek, :month, :quarter, :year, or a range such as:
```bash
```sh
timew summary today to tomorrow
timew today - tomorrow
2018-10-15T06:00 - 2018-10-17T06:00
@@ -22,7 +22,7 @@ Each of these can gain with the :ids tag.
# Basics
```bash
```sh
timew start
timew stop
timew continue
@@ -32,7 +32,7 @@ timew tags
And add ids with:
```bash
```sh
timew summary :ids
timew track 10am - 1pm timewarrior
timew track 1pm for 2h walk
@@ -42,50 +42,50 @@ timew track 1pm for 2h walk
First get ids.
```bash
```sh
timew summary :ids
```
Then if we're looking at task @2:
```bash
```sh
timew move @2 12:00
timew lengthen @2 3mins
```
```bash
```sh
time shorten @2 40mins
```
# Forgetting
```bash
```sh
timew start 1h ago @4
```
Or if your action actually had a break:
```bash
```sh
timew split @8
```
Or maybe not?
```bash
```sh
timew join @4 @8
timew @8 delete
```
Start at previous time
```bash
```sh
timew start 3pm 'Read chapter 12'
timew start 90mins ago 'Read chapter 12'
```
Cancel currently tracked time.
```bash
```sh
timew cancel
```
@@ -157,11 +157,11 @@ with:
# Fixing Errors
```bash
```sh
curl -O https://taskwarrior.org/download/timew-dbcorrection.py
```
```bash
```sh
python timew-dbcorrections.py
```

11
data/view_torrents.md Normal file
View File

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

View File

@@ -4,7 +4,7 @@ tags: [ "browsers" ]
---
Open a search tab:
```bash
```sh
w3m ddg.gg
```

View File

@@ -8,7 +8,7 @@ tags: [ "networking", "ssh", "android" ]
3. Open fdroid, and run:
```bash
```sh
pkg upgrade
pkg install busybox termux-services openssh openssh-sftp-server
source $PREFIX/etc/profile.d/start-services.sh

View File

@@ -1,13 +1,13 @@
---
title: "autologin"
tags: [ "Distros", "Arch" ]
tags: [ "distros", "arch" ]
---
# Automatic Login
Edit `/etc/systemd/system/getty@tty1.service.d/override.conf` by typing:
```bash
```sh
sudo systemctl edit getty@tty1
```

View File

@@ -5,17 +5,17 @@ requires: [ "partitions", "time" ]
---
Keyboard layout changed.
```bash
```sh
ls /usr/share/kbd/keymaps/**/*.map.gz
```
```bash
```sh
loadkeys uk.map.gz
```
Check if boot mode is UEFI
```bash
```sh
ls /sys/firmware/efi/efivars
```
@@ -23,115 +23,115 @@ Without efivars, the system must boot with BIOS.
# Check network's up
```bash
```sh
ping archlinux.org
```
Set system clock properly
```bash
```sh
timedatectl set-ntp true
```
Check disks
```bash
```sh
lsblk
```
Make partition
```bash
```sh
parted -s /dev/sda mklabel gpt
```
```bash
```sh
parted -s /dev/sda mklabel msdos
```
```bash
```sh
parted -s /dev/sda mkpart primary ext4 512 100%
```
```bash
```sh
parted -s /dev/sda set 1 boot on
```
```bash
```sh
mkfs.ext4 /dev/sda1
```
Use pacstrap to get the base install.
```bash
```sh
mount /dev/sda1 /mnt/
```
```bash
```sh
pacstrap /mnt base base-devel vim linux linux-firmware
```
Make fstab notes for new system.
```bash
```sh
genfstab -U /mnt >> /mnt/etc/fstab
```
```bash
```sh
arch-chroot /mnt
```
```bash
```sh
echo 'en_GB.UTF-8' > /etc/default/locale
```
```bash
```sh
pacman -Sy networkmanager grub
```
For legacy:
```bash
```sh
grub-install --target=i386-pc /dev/sda
```
For EFI:
```bash
```sh
sudo pacman -S efibootmgr
```
```bash
```sh
mkdir /boot/efi
```
```bash
```sh
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --remmovable
```
```bash
```sh
grub-mkconfig -o /boot/grub/grub.cfg
```
set local time
```bash
```sh
ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
```
Find the desired locale's and uncomment them.
```bash
```sh
vi /etc/locale.gen
```
```bash
```sh
locale-gen
```
Make your keyboard changes permenent with:
```bash
```sh
vi /etc/vconsole.conf
```
@@ -140,13 +140,13 @@ unsure about this bit - is this name just for the loadkeys function?
Make a hostname
```bash
```sh
echo pc > /etc/hostname
```
Set hostnames for network, or at least your own.
```bash
```sh
vi /etc/hosts
```
@@ -160,27 +160,27 @@ If the system has a permanent IP address, it should be used instead of localhost
Ping some sites to make sure the network's working
```bash
```sh
passwd
```
```bash
```sh
exit
```
```bash
```sh
umount -R /mnt
```
Remove that awful beep sound:
```bash
```sh
rmmod pcspkr
```
...and make the change permanent:
```bash
```sh
sudo echo "blacklist pcspkr" >> /etc/modprobe.d/nobeep.conf
```

View File

@@ -6,19 +6,20 @@ tags: [ "distros" ]
Update font-cache:
```bash
```sh
su root
fc-cache
```
List fonts:
```bash
```sh
fc-list
```
Grab the part of the font name you need for Xresources:
```bash
```sh
fc-list | cut -d: -f2
```

View File

@@ -1,6 +1,6 @@
---
title: "fonts"
tags: [ "distros" ]
title: "Ach Linux GPU Setup"
tags: [ "arch", "GPU" ]
---
# Step 1: Multilib
@@ -13,7 +13,7 @@ Include = /etc/pacman.d/mirrorlist
And update:
```bash
```sh
sudo pacman -Syu
```
@@ -21,7 +21,7 @@ sudo pacman -Syu
Check your graphics card type:
```bash
```sh
lspci | grep VGA
```
@@ -31,7 +31,7 @@ lspci | grep VGA
If you see `Nvidia`, then install the intel drivers:
```bash
```sh
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
```
@@ -39,7 +39,7 @@ sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-lo
If you see `Intel`, then install the intel drivers:
```bash
```sh
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
```
@@ -47,17 +47,16 @@ sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-lo
If you see `AMD`, then check your card support `vulkan`:
```bash
```sh
yay -S gpu-viewer
```
```bash
```sh
vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
```
You should see 'true' here.
```bash
```sh
sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
```

View File

@@ -7,14 +7,14 @@ tags: [ "arch" ]
Clean the cache of old packages in `/var/cachepacman/pkg/`:
```bash
```sh
ls /var/cache/pacman/pkg/ | wc -l
sudo pacman -Sc
ls /var/cache/pacman/pkg/ | wc -l
```
And the same for `yay` (with `-Yc` to remove old dependencies):
```bash
```sh
ls ~/.cache/yay/ | wc -l
yay -Sc
yay -Yc
@@ -27,7 +27,7 @@ If you chance a configuration file, such as `/etc/environment`, and `pacman` wan
Check the new files, then look at the difference between the `pacman` version, and your version.
```bash
```sh
sudo find /etc/ /var/ /usr/ -name "*.pacnew"
diff /etc/pacman.d/mirrorlist*
```
@@ -36,7 +36,7 @@ Either,
- Update the files manually,
```bash
```sh
sudo -e /etc/pacman.d/mirrorlist
sudo rm /etc/pacman.d/mirrorlist.pacnew
```
@@ -46,7 +46,7 @@ Or,
- use a tool like `pacdiff` to view the changes next to each other, and select them with `vim`.
```bash
```sh
sudo pacman -S pacman-contrib
sudo pacdiff
```

View File

@@ -7,13 +7,13 @@ Packages are kept in /var/cache/pacman/pkg.
Delete unused old packages with:
```bash
```sh
sudo pacman -Sc
```
Signatures are handled by the pacman-key, initially set up with:
```bash
```sh
sudo pacman-key --populate archlinux
```
@@ -23,31 +23,31 @@ sudo pacman-key --refresh-keys
If you have usigned keys, you can refresh with:
```bash
```sh
sudo pacman -Sc
```
or
```bash
```sh
sudo pacman -Scc
```
Reset all keys with:
```bash
```sh
sudo rm -r /etc/pacmand.d/gnupg/ && sudo pacman-key --init
```
If you're constantly getting 'everything corrupted, nothing upgraded', try running:
```bash
```sh
sudo pacman -S archlinux-keyring
```
List all orphaned packages:
```bash
```sh
sudo pacman -Qtdq
```

View File

@@ -8,27 +8,27 @@ tags: [ "distros" ]
Messed up a package's configuration files?
```bash
```sh
sudo apt-get purge [thing]
```
```bash
```sh
sudo apt autoremove
```
Check if you still have related things:
```bash
```sh
apt search [thing]
```
```bash
```sh
sudo apt-get install [ thing ]
```
Still have problems?
```bash
```sh
sudo dpgk --force-confmiss -i /var/cache/apt/archives/[thing]
```

View File

@@ -1,18 +1,24 @@
---
title: "Aeroplane Mode in Void"
tags: [ "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.
> sudo sv stop wpa_supplicant bluetoothd
```sh
su root
sv stop wpa_supplicant bluetoothd
```
Find your device's name with `ip a`.
Find your device's name with `ip -color addr`.
If unsure, try this:
> name=$(ip a | grep -Eo 'wlp\w{3}')
> echo $name
```sh
name=$(ip a | grep -Eo 'wlp\w{3}')
echo $name
```
Then set that device down:
> sudo ip link set $name down
```sh
ip link set $name down
```

View File

@@ -1,11 +1,11 @@
---
title: "Void Autologin"
tags: [ "Void" ]
tags: [ "void" ]
---
Make the autologin service:
```bash
```sh
cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1
```

View File

@@ -7,24 +7,24 @@ To automatically stick the logo onto your background, do these commands in the d
Get the void linux logo from wikipedia
```bash
```sh
wget https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Void_Linux_logo.svg/256px-Void_Linux_logo.svg.png?20170131170632
```
Rename it, and resize it (the standard size is too small for most wallpapers)
```bash
```sh
convert -resize 200% '256px-Void_Linux_logo.svg.png?20170131170632' void-logo.png
```
Download a pretty wallpaper
```bash
```sh
wget http://wallpapercave.com/wp/Wlm9Gv0.jpg
```
Put the void logo on all *jpg and *png images
```bash
```sh
for x in *.jpg
do
composite -compose multiply -gravity Center void-logo.png "$x" "$x"

View File

@@ -1,22 +1,22 @@
---
title: "extrace"
tags: [ "Void" ]
tags: [ "void" ]
---
Monitor all processes:
```bash
```sh
extrace
```
Monitor one process:
```bash
```sh
extrace ls
```
Monitor a script:
```bash
```sh
./script.sh | extrace
```

View File

@@ -9,16 +9,17 @@ Jenkins is janky.
## Start
Start the service file.
```bash
sudo ln -s /etc/sv/jenkins /var/service
sudo sv start jenkins
```sh
su root
ln -s /etc/sv/jenkins /var/service
sv start jenkins
```
Then visit the web interface with `$BROWSER localhost:8080`.
If it's not working, try running the command from the run file the first time:
```bash
```sh
chpst -u jenkins java -jar /opt/jenkins/jenkins.war
```

View File

@@ -6,13 +6,13 @@ tags: [ "void", "locale" ]
Check the current locales:
```bash
```sh
locale -a
```
Add the languages you want by editing `/etc/default/libc-locales`, and uncommenting your choice:
```bash
```sh
#en_DK.UTF-8 UTF-8
#en_DK ISO-8859-1
en_GB.UTF-8 UTF-8
@@ -25,13 +25,14 @@ Now you can generate what you need for those languages.
However, instead of generating what you need, you're going to generate everything which needs updating:
```bash
sudo xbps-reconfigure glibc-locales
```sh
su root
xbps-reconfigure glibc-locales
```
Finally, select your chosen locale by placing it in `/etc/locale.conf`.
```bash
```sh
echo "LC_ALL=en_GB.UTF-8
LANG=en_GB.UTF-8
LANGUAGE=en_GB.UTF-8" > /etc/locale.conf
@@ -48,7 +49,7 @@ en_GB ISO-8859-1
Check your new locales are available:
```bash
```sh
locale -a
```

View File

@@ -1,18 +1,18 @@
---
title: "sv"
tags: [ "Void" ]
tags: [ "void" ]
---
# List Services
All possible services are in:
```bash
```sh
ls /etc/sv
```
The computer only uses those in /var/service, so symbolic links are made to start and stop services.
```bash
```sh
ls /var/service
```
@@ -20,13 +20,13 @@ ls /var/service
Enable the sshd service, so that ssh will work every time you boot up:
```bash
```sh
sudo ln -s /etc/sv/sshd /var/service
```
Then start the service:
```bash
```sh
sudo sv start sshd
```
@@ -34,19 +34,19 @@ sudo sv start sshd
Stop `mpd` with:
```bash
```sh
sudo sv stop mpd
```
And stop it automatically loading at startup with:
```bash
```sh
sudo rm /var/service/mpd
```
You can also just make a file called 'down':
```bash
```sh
sudo touch /var/service/mpd/down
```
@@ -63,7 +63,7 @@ If unsure, use `#!/bin/bash` as the first line. When Void Linux says `sh`, it m
Confirm the shell you'll use:
```bash
```sh
ls -l $(which sh)
```

View File

@@ -1,12 +1,12 @@
---
title: "Void Linux Basics"
tags: [ "Void" ]
tags: [ "void" ]
---
# Updates
Update all packages with
```bash
```sh
sudo xbps-install -Su
```
@@ -17,7 +17,7 @@ See [xbps](xbps.md) for more.
Void keeps *every* version of everything you install, so you can roll back to them.
Remove old packages with:
```bash
```sh
sudo xbps-remove -O
```
@@ -25,19 +25,19 @@ sudo xbps-remove -O
Old Void kernels are left on the boot partition. List them with:
```bash
```sh
vkpurge list
```
Remove one with:
```bash
```sh
vkpurge 2.8.2_4
```
Remove all but the latest with:
```bash
```sh
vkpurge rm all
```
@@ -48,7 +48,7 @@ You can change this number to change the screen brightness.
For an easy utility, install `brightnessctl`.
```bash
```sh
brightnessctl s 10%-
brightnessctl s 10%+
```
@@ -57,5 +57,5 @@ brightnessctl s 10%+
- [autologin](autologin.md)
- [services](sv.md)
- [wifi](wpa_cli.md)
- [wifi](../../networking/wpa_supplicant.md)

View File

@@ -1,55 +1,55 @@
---
title: "xbps"
tags: [ "Void" ]
tags: [ "void" ]
---
## Search
Look for cowsay in the repository:
```bash
```sh
xbps-query --repository --search cowsay
```
Short version:
```bash
```sh
xbps-query -Rs cowsay
```
Search with regex:
```bash
```sh
xbps-query --regex -Rs 'cow(s)?\w'
```
List what's required for cowsay
```bash
```sh
xbps-query -x cowsay
```
What packages are orphaned (i.e. installed as a dependency for another package, which has since been removed)?
```bash
```sh
xbps-query -O
```
Show cowsay's dependencies.
```bash
```sh
xbps-query -x cowsay
```
This shows `perl`.
To see what else depends on perl:
```bash
```sh
xbps-query -X perl
```
List all manually installed software.
```bash
```sh
xbps-query -m
```
@@ -57,14 +57,14 @@ xbps-query -m
Install cowsay
```bash
```sh
xbps-install cowsay
```
Upgrade current packages.
`-R` looks at repositories, `-s` makes a sloppy search (for rough matches).
```bash
```sh
xbps-install -Suv
```
@@ -72,19 +72,19 @@ xbps-install -Suv
Remove cowsay
```bash
```sh
xbps-remove cowsay
```
...and all dependencies
```bash
```sh
xbps-remove -R cowsay
```
Remove all orphaned dependencies.
```bash
```sh
xbps-remove -o
```
@@ -94,19 +94,19 @@ Show information about cowsay
Reinstall cowsay
```bash
```sh
xbps-install -f cowsay
```
Look for broken packages.
```bash
```sh
sudo xbps-pkgdb -a
```
And if you've found any, you might reconfigure all packages forcefully:
```bash
```sh
sudo xbps-reconfigure -af
```

View File

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

View File

@@ -9,8 +9,9 @@ This works everywhere, including in a bare-ass tty.
Select a keymap, and create a new custom map.
```bash
```sh
su root
ls /usr/share/kbd/keymaps/i386/qwerty/
basemap=/usr/share/kbd/keymaps/i386/qwerty/pl1.map.gz
newmap=/usr/share/kbd/keymaps/custom.map.gz
@@ -22,7 +23,7 @@ gunzip -c $basemap | \
Tell the system to use this keymap at startup by naming it in the `rc.conf` file:
```bash
```sh
echo "KEYMAP=$newmap" >> /etc/rc.conf
cat /etc/rc.conf
@@ -33,24 +34,24 @@ reboot
Set layout to British English.
```bash
```sh
setxkbmap -layout gb
```
Or Polish with:
```bash
```sh
setxkbmap -layout pl
```
| Language | short |
|:--------|:------|
| Polish | pl |
| Serbian | rs |
|:---------|:------|
| Polish | `pl` |
| Serbian | `rs` |
Set 'alt + shift', as the command which cycles through the British English, Polish and Serbian keyboard layout.
```bash
```sh
setxkbmap -layout gb,pl,rs -option grp:alt_shift_toggle
```

View File

@@ -4,9 +4,13 @@ tags: [ "hardware" ]
---
See screen size
> xrandr -q
```sh
xrandr -q
```
Automatically configure:
> xrandr --auto
```sh
xrandr --auto
```

20
networking/bad_horse.md Normal file
View File

@@ -0,0 +1,20 @@
---
title: "Mapping the Net"
tags: [ "networking", "graph", "fun" ]
---
Find the path to a domain:
```sh
domain=bad.horse
max_hops=50
tracepath -m $maximum_hops $domain
```
If you're on Debian, you can use `graph-easy` and `dothost` to make an instant diagram:
```sh
domain=dice.camp
dothost $domain | graph-easy --boxart
```

View File

@@ -1,11 +1,11 @@
---
title: "fail2ban"
tags: [ "Networking" ]
tags: [ "networking" ]
requires: [ "ssh" ]
---
# SSH Daemon Jail
```bash
```sh
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.d/ssh.local
```
@@ -17,15 +17,15 @@ ignoreip = 127.0.0.1/8 ::1,192.168.0.0/16 ::1
```
```bash
```sh
sudo systemctl restart fail2ban
```
```bash
```sh
sudo fail2ban-client status
```
```bash
```sh
sudo fail2ban-client status sshd
```

View File

@@ -1,6 +1,6 @@
---
title: "Easy Network Graph"
tags: [ "Networking" ]
tags: [ "networking" ]
---
Set up a file like this, called `troubleshooting.txt`.
@@ -18,7 +18,7 @@ Set up a file like this, called `troubleshooting.txt`.
Then translate it with:
```bash
```sh
graph-easy troubleshooting.txt --as boxart
```

View File

@@ -1,6 +1,6 @@
---
title: "iptables"
tags: [ "Networking" ]
tags: [ "networking" ]
---
# Intro
@@ -8,7 +8,7 @@ This is a basic Linux firewall program.
Look at your firewalls:
```bash
```sh
iptables -L
```
@@ -18,7 +18,7 @@ We see the output of input, output and forwarding rules.
I don't need any forwarding, so I'm going to drop all forwarding:
```bash
```sh
iptables -P FORWARD DROP
```
@@ -26,17 +26,17 @@ iptables -P FORWARD DROP
Let's 'A'dd, or 'A'ppend a rule with -A. Let's drop all input from a nearby IP
```bash
```sh
iptables -A INPUT -s 192.168.0.23 -j DROP
```
Or we can block all input from a particular port on the full Network.
```bash
```sh
iptables -A INPUT -s 192.168.0.0/24 -p tcp --destination-port 25 -j DROP
```
```bash
```sh
iptables -A INPUT --dport 80 -j ACCEPT
```
@@ -47,13 +47,13 @@ However, rules are accepted in order - so a packet cannot be rejected and then a
To delete rule 2 from the INPUT chain:
```bash
```sh
iptables -D INPUT 3
```
Alternatively, you can 'I'nsert a rule at the start, rather than 'A'ppending it.
```bash
```sh
iptables -I INPUT -s 192.168.0.13 DROP
```
@@ -67,7 +67,7 @@ The -j flag accepts ACCEPT/REJECT/DROP. The last two are identical except that
Flush all existing rules with:
```bash
```sh
iptables -F
```

View File

@@ -1,11 +1,11 @@
---
title: "nmap"
tags: [ "Networking" ]
tags: [ "networking" ]
---
Example:
```bash
```sh
nmap 192.168.1.1/24
```
@@ -17,6 +17,6 @@ Flags:
Look for a web server, which has ports 80 and 443 open:
```bash
```sh
nmap 192.168.1.1/24 -p 80,443 --open
```

View File

@@ -1,24 +1,24 @@
---
title: "pi-hole-server"
tags: [ "Distros" ]
tags: [ "distros" ]
---
# Installation
## Arch
```bash
```sh
yay -S pi-hole-server
```
```bash
```sh
sudo systemctl enable --now pihole-FTL
```
```bash
```sh
sudo systemctl disable --now systemd-resolved
```
```bash
```sh
sudo rm -f /dev/shm/FTL-\*
```
@@ -26,32 +26,32 @@ sudo rm -f /dev/shm/FTL-\*
Debian has a long, boring setup.
```bash
```sh
sudo apt-get install wget curl net-tools gamin lighttpd lighttpd-mod-deflate
curl -sSL https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true sudo -E bash
```
# Setup
```bash
```sh
sudo usermod -aG pihole $USER
```
Remove that google dns server.
```bash
```sh
pihole -a setdns 9.9.9.9 1.0.0.1
```
Disable pihole password by setting a blank password.
```bash
```sh
pihole -a -p
```
Get a new list of blocked domains, then reload:
```bash
```sh
pihole -g -r
```
@@ -61,13 +61,13 @@ Every so often, run `pihole -g` again (perhaps put it in crontab).
Observe the pihole's output while you ask it a question:
```bash
```sh
pihole -t
```
Then ask the question from another computer:
```bash
```sh
dig @[ pihole ip ] archlinux.org
```

25
networking/port_scan.md Normal file
View File

@@ -0,0 +1,25 @@
---
title: "Port Scan"
tags: [ "networking" ]
repo: 'https://github.com/mrjackwills/havn/'
---
`havn` scans ports.
It's not in many repos, but if you can `cargo install havn`.
```sh
havn -h
havn -a
domain=splint.rs
havn -p 19-90 ${domain}
```
That last command doesn't work reliably, so increase the number of retries (`-r`), or decrease concurrent requests (`-c`).
```sh
havn -p 19-443 -r 6 ${domain}
havn -p 1-1000 -c 500 -r 5 ${domain}
```

View File

@@ -1,6 +1,6 @@
---
title: "rclone"
tags: [ "Networking" ]
tags: [ "networking", "synch" ]
---
The manpage's 'Synopsis' provides a fast reference.
```
@@ -9,71 +9,71 @@ We'll assume a folder in Google Drive called 'test', and local folder called 'fo
Generate a config file with:
```bash
```sh
rclone config
```
Look at the contents of Google Drive:
```bash
```sh
rclone ls gd:/
```
If rclone loses authorization:
```bash
```sh
rclone authorization
```
List only directories:
```bash
```sh
rclone lsf -dirs-only google:/
```
Mount the remote location on /tmp/google with:
```bash
```sh
rclone mount google /tmp/google
```
Copy the contents of 'foo' to 'test'.
```bash
```sh
rclone copy foo/ google:test
```
Sync contents of foo and test with a progress bar (will delete Google items):
```bash
```sh
rclone sync foo google:test -P
```
Remove all duplicates
```bash
```sh
rclone dedupe google:test
```
Delete contets of a remote file:
```bash
```sh
rclone delete n:test
```
Or delete the folder and contents as well:
```bash
```sh
rclone purge n:test
```
Copy to and from with:
```bash
```sh
rclone copyto google:test foo
```
or
```bash
```sh
rclone copyto foo google:test

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