Compare commits
No commits in common. "bbaee4983107a2fa23ee4c3d605f3c40a47ec3a9" and "0da2b4c7e89c1a4e76fc453686d9cdd1af1d6911" have entirely different histories.
bbaee49831
...
0da2b4c7e8
10
README.md
10
README.md
@ -26,8 +26,6 @@ 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.
|
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.
|
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.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Closing
|
### Closing
|
||||||
|
|
||||||
Introductory documents should show anything required to cleanly uninstall a program, without leaving bulky configuration files behind.
|
Introductory documents should show anything required to cleanly uninstall a program, without leaving bulky configuration files behind.
|
||||||
@ -54,8 +52,6 @@ Non-commands (e.g. output) should be shown as quoted text:
|
|||||||
> Mail kn
|
> Mail kn
|
||||||
> Projects music
|
> Projects music
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -65,9 +61,9 @@ How to see which websites you're actively accessing:
|
|||||||
ss -tr dst :$PORT
|
ss -tr dst :$PORT
|
||||||
` ` `
|
` ` `
|
||||||
|
|
||||||
> State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
|
> State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
|
||||||
> ESTAB 0 0 192.168.0.14:42476 149.154.167.91:https
|
> ESTAB 0 0 192.168.0.14:42476 149.154.167.91:https
|
||||||
> ESTAB 0 0 192.168.0.14:43644 104.17.90.199:https
|
> ESTAB 0 0 192.168.0.14:43644 104.17.90.199:https
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Joyous ASCII"
|
|
||||||
tags: [ "fun" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
- `asciiquarium`
|
|
||||||
- `cbonsai -lim "$(fortune)"`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cow=$(cowsay -l | sort -R | head -1)
|
|
||||||
fortune -s | figlet | cowsay -nf $cow | lolcat
|
|
||||||
```
|
|
116
basics/cron.md
116
basics/cron.md
@ -2,11 +2,9 @@
|
|||||||
title: "cron"
|
title: "cron"
|
||||||
tags: [ "Documentation", "Basics" ]
|
tags: [ "Documentation", "Basics" ]
|
||||||
---
|
---
|
||||||
# Cronie
|
# Cron
|
||||||
|
|
||||||
The `cronie` program is also known as `crond`.
|
The crontab program might have various names, like `cronie` or `crond`.
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt search -n ^cron
|
sudo apt search -n ^cron
|
||||||
@ -16,35 +14,20 @@ Once installed, search for the service name, and start it.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl list-unit-files | grep cron
|
sudo systemctl list-unit-files | grep cron
|
||||||
sudo systemctl enable --now $NAME
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Show your current crontab:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crontab -l
|
sudo systemctl enable --now cron
|
||||||
```
|
```
|
||||||
|
|
||||||
You can put this in a file and edit it:
|
You can *e*dit your crontab with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crontab -l > $filename
|
crontab -e
|
||||||
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then apply that crontab:
|
|
||||||
|
|
||||||
```bash
|
> 39 */3 * * * /usr/bin/updatedb
|
||||||
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
|
## Syntax
|
||||||
|
|
||||||
@ -56,61 +39,43 @@ These five points refer to:
|
|||||||
|
|
||||||
So '3pm every Sunday' would be:
|
So '3pm every Sunday' would be:
|
||||||
|
|
||||||
`0 15 * * 7`
|
> 0 15 * * 7
|
||||||
|
|
||||||
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
|
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
|
||||||
The minute is '0' (i.e. '0 minutes past three pm').
|
The minute is '0' (i.e. '0 minutes past three pm').
|
||||||
|
|
||||||
Doing the same thing, but only in February, would be:
|
Doing the same thing, but only in February, would be:
|
||||||
|
|
||||||
`0 15 * 2 7`
|
> 0 15 * 2 7
|
||||||
|
|
||||||
### Variables
|
### Full Paths
|
||||||
|
|
||||||
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "HOME=$HOME" > $filename
|
type -P apt
|
||||||
crontab -l >> $filename
|
|
||||||
crontab $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`cronie` doesn't know where anything lives, including programs.
|
`/usr/bin/apt`
|
||||||
You can give it your usual `$PATH` variable like this:
|
|
||||||
|
|
||||||
|
Then put that into the crontab:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo $PATH > $filename
|
sudo crontab -e
|
||||||
crontab -l >> $filename
|
|
||||||
crontab $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now instead of doing this
|
> 40 */3 * * * /usr/bin/apt update -y
|
||||||
|
|
||||||
`40 */3 * * * /usr/bin/du -sh $HOME/* | sort -h > $HOME/sum.txt`
|
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.
|
||||||
|
|
||||||
You can simply do this:
|
## Directories
|
||||||
|
|
||||||
`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.
|
You can execute a script as root by putting it into a directory, instead of in the tab.
|
||||||
Look at the available cron directories:
|
Look at the available cron directories:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ls -d /etc/cron.*
|
ls /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
|
### Testing with runparts
|
||||||
@ -121,9 +86,50 @@ Run-parts runs all executable scripts in a directory.
|
|||||||
run-parts /etc/cron.hourly
|
run-parts /etc/cron.hourly
|
||||||
```
|
```
|
||||||
|
|
||||||
# Troubleshooting
|
## 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*:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
:r!echo PATH=$PATH
|
||||||
|
```
|
||||||
|
|
||||||
### `date` Commands
|
### `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`.
|
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
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
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
|
|
||||||
```
|
|
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
title: "bash games"
|
|
||||||
tags: [ "Documentation", "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`.
|
|
@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
title: "hard links"
|
|
||||||
tags: [ "basics", "links" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
A hard link is one file which exists in multiple locations.
|
|
||||||
|
|
||||||
Each file has an ID, which is kept on the hard disk's partition.
|
|
||||||
Each hard link has the same ID, because they are the same file.
|
|
||||||
This ID is called the 'inode'.
|
|
||||||
|
|
||||||
Create a file, and a hard link:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
fortune > $file_1
|
|
||||||
mkdir -p x/y/z/
|
|
||||||
ln $file_1 x/y/z/$file_2
|
|
||||||
```
|
|
||||||
Have a long look at the file with the `-l` flag, and check the inode with `-i`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ls -li $file_1 x/y/z/$file_2
|
|
||||||
```
|
|
||||||
|
|
||||||
Since they are the same file, you can make a change to one, and it changes both:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
fortune | tee x/y/z/$file_2
|
|
||||||
cat $file_1
|
|
||||||
cat x/y/z/$file_2
|
|
||||||
```
|
|
||||||
|
|
||||||
# Danger Zone
|
|
||||||
|
|
||||||
- hard links will not work on directories, only standard files and fifos.
|
|
||||||
- `git` will destroy and remake files, so it will not respect hard links.
|
|
||||||
- Files cannot have a hard link on another disk partition, because the inode is stored on each partition.
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
|||||||
---
|
---
|
||||||
title: "links"
|
title: "links"
|
||||||
tags: [ "basics", "links" ]
|
tags: [ "Documentation", "Basics" ]
|
||||||
---
|
---
|
||||||
|
Link from X to Y.
|
||||||
|
|
||||||
There are two types:
|
```bash
|
||||||
|
ln -s X ../otherdir/Y
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want a hard link, this will make a single file exist in two locations.
|
||||||
|
If it is deleted in one location, it continues to exist in the other.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ln *X* *Y*
|
||||||
|
```
|
||||||
|
|
||||||
|
Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`).
|
||||||
|
|
||||||
- [Soft links](soft_links.md)
|
|
||||||
- [Hard links](hard_links.md)
|
|
||||||
|
46
basics/ls.md
46
basics/ls.md
@ -1,46 +0,0 @@
|
|||||||
---
|
|
||||||
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,180 +0,0 @@
|
|||||||
---
|
|
||||||
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
|
|
||||||
```
|
|
@ -1,72 +0,0 @@
|
|||||||
---
|
|
||||||
title: "soft links"
|
|
||||||
tags: [ "basics", "links" ]
|
|
||||||
---
|
|
||||||
A soft link is a file which says how to go to another file.
|
|
||||||
When a program encounters a soft link, it will make a guess at whether it should ignore it, or try to get to that file.
|
|
||||||
|
|
||||||
To make a soft link to a file in the current directory, linking is easy:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
fortune > $file_1
|
|
||||||
ln -s $file_1 $link_1
|
|
||||||
```
|
|
||||||
|
|
||||||
Now imagine your directory looks like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
dir_0/
|
|
||||||
├── dir_1
|
|
||||||
│ └── file_1
|
|
||||||
├── dir_2
|
|
||||||
│ └── file_1
|
|
||||||
├── file_1
|
|
||||||
└── link_1
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd dir_1
|
|
||||||
ln -s ../file_1 link_1
|
|
||||||
```
|
|
||||||
|
|
||||||
The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ln -s ../file_1 dir_2/link_2
|
|
||||||
```
|
|
||||||
|
|
||||||
Both symlinks are identical, except for the name.
|
|
||||||
|
|
||||||
```
|
|
||||||
dir_0/
|
|
||||||
├── dir_1
|
|
||||||
│ ├── file_1
|
|
||||||
│ └── link_1 <-- This one points to ../file_1
|
|
||||||
├── dir_2
|
|
||||||
│ ├── file_1
|
|
||||||
│ └── link_2 <-- This one points to ../file_1 as well.
|
|
||||||
└── file_2
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Since it's just an address, you can delete the original file, then make another.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
rm file_1
|
|
||||||
ls -l dir_1/
|
|
||||||
fortune > file_1
|
|
||||||
cat dir_2/link_2
|
|
||||||
fortune | tee -a file_1
|
|
||||||
cat dir_1/link_1
|
|
||||||
```
|
|
||||||
|
|
||||||
Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ln -s -f ../dir_1/file_1 dir_2/link_2
|
|
||||||
cat dir_2/link_2
|
|
||||||
```
|
|
||||||
|
|
@ -68,11 +68,3 @@ ntpq -p
|
|||||||
|
|
||||||
Usually this is run as a service, so just start that service.
|
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
|
|
||||||
```
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
---
|
|
||||||
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'
|
|
||||||
```
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
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,57 +0,0 @@
|
|||||||
---
|
|
||||||
title: "profanity"
|
|
||||||
tags: [ "Documentation", "Chat", "OTR" ]
|
|
||||||
---
|
|
||||||
# otr
|
|
||||||
|
|
||||||
'Off The Record' encryption seems mostly dead to me.
|
|
||||||
But this is what I did, back in the day...
|
|
||||||
|
|
||||||
Install libotr-dev or libotr5-dev or whatever..
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt -y install lib5otr-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Make your otr keys.
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr gen
|
|
||||||
```
|
|
||||||
|
|
||||||
Then you can start an otr converstation.
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr start bob@jobbies.org
|
|
||||||
```
|
|
||||||
|
|
||||||
Or if you already have a conversation windows open, switch to our using:
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally, verify!
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr question "Who are you?" bob
|
|
||||||
```
|
|
||||||
|
|
||||||
Bob is verified upon the answer, 'bob'.
|
|
||||||
|
|
||||||
### OTR Finger Prints
|
|
||||||
|
|
||||||
Get yours with
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr myfp
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr theirfp
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
/otr myfp
|
|
||||||
```
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: "profanity"
|
title: "profanity"
|
||||||
tags: [ "Documentation", "Chat", "omemo" ]
|
tags: [ "Documentation", "Chat" ]
|
||||||
---
|
---
|
||||||
# Setup (Commands)
|
# Setup (Commands)
|
||||||
|
|
||||||
@ -140,6 +140,54 @@ You can ensure omemo automatcally turns on:
|
|||||||
```
|
```
|
||||||
/omemo policy automatic
|
/omemo policy automatic
|
||||||
```
|
```
|
||||||
---
|
|
||||||
|
|
||||||
'OTR' encryption is mostly dead, but you can find the old instructions [here](profanity-otr).
|
## 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
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
title: "calcurse"
|
|
||||||
tags: [ "data", "calendar", "daylight savings" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
The UK government keeps an ics file with clock, [here](https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics).
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
|||||||
---
|
|
||||||
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:
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
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.
|
|
||||||
|
|
||||||
```
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo grep -r $FRAGMENT /var/spool/*
|
|
||||||
```
|
|
||||||
|
|
@ -92,7 +92,7 @@ A branch is a full copy of the project to test additional ideas.
|
|||||||
You can make a new branch called 'featurez' like this:
|
You can make a new branch called 'featurez' like this:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git branch $FEATURE_BRANCH
|
git branch *featurez*
|
||||||
```
|
```
|
||||||
|
|
||||||
Have a look at all your branches:
|
Have a look at all your branches:
|
||||||
@ -104,20 +104,19 @@ git branch
|
|||||||
Switch to your new branch:
|
Switch to your new branch:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git checkout $FEATURE_BRANCH
|
git checkout *featurez*
|
||||||
```
|
```
|
||||||
|
|
||||||
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git branch -D $FEATURE_BRANCH
|
git branch -D *featurez*
|
||||||
```
|
```
|
||||||
|
|
||||||
Or if it's a good branch, push it to the remote:
|
Or if it's a good branch, push it to the remote:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
remote=origin
|
git push *origin* *featurez*
|
||||||
git push $remote $FEATURE_BRANCH
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Merging
|
## Merging
|
||||||
@ -125,13 +124,13 @@ git push $remote $FEATURE_BRANCH
|
|||||||
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git merge $FEATURE_BRANCH
|
git merge *featurez*
|
||||||
```
|
```
|
||||||
|
|
||||||
And delete the branch, as you've already merged it:
|
and delete `featurez` as you've already merged it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git branch -d $FEATURE_BRANCH
|
git branch -d featurez
|
||||||
```
|
```
|
||||||
|
|
||||||
# Subtree
|
# Subtree
|
||||||
@ -142,6 +141,34 @@ git branch -d $FEATURE_BRANCH
|
|||||||
git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
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.
|
||||||
|
|
||||||
|
```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
|
||||||
|
```
|
||||||
|
|
||||||
# Tricks
|
# Tricks
|
||||||
|
|
||||||
## Delete All History
|
## Delete All History
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
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.
|
|
@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
title: "git hooks"
|
|
||||||
tags: [ "Documentation", "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`.
|
|
||||||
```
|
|
@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
title: "git"
|
|
||||||
tags: [ "Documentation", "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
|
|
||||||
```
|
|
||||||
|
|
118
data/gpg.md
118
data/gpg.md
@ -1,7 +1,119 @@
|
|||||||
---
|
---
|
||||||
title: "gpg"
|
title: "gpg"
|
||||||
tags: [ "Documentation", "data", "GPG" ]
|
tags: [ "Documentation", "data" ]
|
||||||
---
|
---
|
||||||
|
# Making keys
|
||||||
|
|
||||||
|
Generate keys:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --gen-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
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
```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: 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).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF*
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you're in the interface, type `trust`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --sign-key alice@posteo.net
|
||||||
|
```
|
||||||
|
|
||||||
|
Then send those trusted keys up to a server, so people can see you have verified them:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F*
|
||||||
|
```
|
||||||
|
|
||||||
|
# Refresh Keys
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --refresh-keys
|
||||||
|
```
|
||||||
|
|
||||||
|
# Export
|
||||||
|
|
||||||
|
Your public key:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --output *me*.gpg --armor --export
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpg --export -a *person@email.tld* > *my_key*.pub
|
||||||
|
```
|
||||||
|
|
||||||
- [Setup](gpg/basics.md)
|
|
||||||
- [Extras](gpg/extras.md)
|
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
---
|
|
||||||
title: "GPG Basics"
|
|
||||||
tags: [ "Documentation", "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
|
|
||||||
```
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
title: "gpg"
|
|
||||||
tags: [ "Documentation", "vim", "data", "GPG" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
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,25 +0,0 @@
|
|||||||
---
|
|
||||||
title: "PDF Metadata Erasure"
|
|
||||||
tags: [ "Documentation", "Metadata", "Ghost Script" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Make a text file called 'pdfmark.txt'.
|
|
||||||
|
|
||||||
|
|
||||||
```text
|
|
||||||
[ /Title ()
|
|
||||||
/Author ()
|
|
||||||
/Subject ()
|
|
||||||
/Creator ()
|
|
||||||
/ModDate ()
|
|
||||||
/Producer ()
|
|
||||||
/Keywords ()
|
|
||||||
/CreationDate ()
|
|
||||||
/DOCINFO pdfmark
|
|
||||||
```
|
|
||||||
|
|
||||||
Then run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt
|
|
||||||
```
|
|
122
data/radicale.md
122
data/radicale.md
@ -1,122 +0,0 @@
|
|||||||
---
|
|
||||||
title: "radicale and nginx"
|
|
||||||
tags: [ "data", "calendar" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
@ -1,47 +1,33 @@
|
|||||||
---
|
---
|
||||||
title: "sc-im"
|
title: "sc-im"
|
||||||
tags: [ "Documentation", "TUI", "data" ]
|
tags: [ "Documentation", "data" ]
|
||||||
---
|
---
|
||||||
|
|
||||||
- [Sample file](sc-im/sample.sc)
|
|
||||||
|
|
||||||
# Basic Commands
|
# Basic Commands
|
||||||
|
|
||||||
## See Cells
|
> H = highest part
|
||||||
|
> L = lowest part
|
||||||
|
> gg = top
|
||||||
|
|
||||||
Cells are hard to see.
|
> g$ = most right.
|
||||||
Change this with `:set autowrap`.
|
> g0 = most left.
|
||||||
|
|
||||||
Make `sc-im` always autowrap:
|
> \ = insert middle
|
||||||
|
> \> = insert left
|
||||||
|
> < = insert right
|
||||||
|
|
||||||
```bash
|
gb4 = to to cell b4
|
||||||
mkdir .config/sc-im/bash
|
|
||||||
echo 'set autowrap' >> .config/sc-im/scimrc
|
|
||||||
```
|
|
||||||
|
|
||||||
## Movement
|
> aa = see all text in cells
|
||||||
|
> f = format cells so you can see it.
|
||||||
|
> fl = format wider right
|
||||||
|
> fh = format smaller left
|
||||||
|
|
||||||
| Command | Key |
|
> fj = format wider down
|
||||||
|:------------------------------------|:---:|
|
> fk = format smaller down
|
||||||
| 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 |
|
| Action | Key |
|
||||||
|:----------------------|:---:|
|
|:----------------------|:---:|
|
||||||
@ -49,7 +35,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| text (right align) | > |
|
| text (right align) | > |
|
||||||
| Edit existing text | E |
|
| Edit existing text | E |
|
||||||
|
|
||||||
### Meta Actions
|
## Meta Actions
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:----------------------|:---:|
|
|:----------------------|:---:|
|
||||||
@ -62,7 +48,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| delete a cell | x |
|
| delete a cell | x |
|
||||||
|
|
||||||
|
|
||||||
### Functions
|
## Functions
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:--------------------------------|:------------:|
|
|:--------------------------------|:------------:|
|
||||||
@ -72,7 +58,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| minimumof those numbers | =@min(B1:B8) |
|
| minimumof those numbers | =@min(B1:B8) |
|
||||||
| multiply C1 to C8 | =@prod(C1:C8)|
|
| multiply C1 to C8 | =@prod(C1:C8)|
|
||||||
|
|
||||||
### Visual
|
## Visual
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:--------------------------------|:------------:|
|
|:--------------------------------|:------------:|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
|
|
||||||
# You almost certainly shouldn't edit it.
|
|
||||||
|
|
||||||
newsheet "Sheet1"
|
|
||||||
movetosheet "Sheet1"
|
|
||||||
offscr_sc_cols 0
|
|
||||||
offscr_sc_rows 0
|
|
||||||
nb_frozen_rows 1
|
|
||||||
nb_frozen_cols 0
|
|
||||||
nb_frozen_screenrows 2
|
|
||||||
nb_frozen_screencols 0
|
|
||||||
format A 14 1 0
|
|
||||||
format B 18 2 0
|
|
||||||
format 0 2
|
|
||||||
freeze 0
|
|
||||||
label A0 = "Food by Weight"
|
|
||||||
leftstring B0 = "No. Meals"
|
|
||||||
leftstring A1 = "Ajvar"
|
|
||||||
let A1 = 5
|
|
||||||
let B1 = A1*$A$10
|
|
||||||
leftstring A2 = "Apples"
|
|
||||||
let A2 = 3
|
|
||||||
let B2 = A2*$A$10
|
|
||||||
leftstring A3 = "Rocket"
|
|
||||||
let A3 = 0.2
|
|
||||||
let B3 = A3*$A$10
|
|
||||||
leftstring A4 = "Beli Cheese"
|
|
||||||
let A4 = 1
|
|
||||||
let B4 = A4*$A$10
|
|
||||||
leftstring A6 = "Total"
|
|
||||||
let A6 = @sum(A1:A4)
|
|
||||||
leftstring B6 = "Total"
|
|
||||||
let B6 = @sum(B1:B4)
|
|
||||||
leftstring A7 = "Average"
|
|
||||||
let A7 = @avg(A1:A4)
|
|
||||||
leftstring A10 = "Weight of Meal"
|
|
||||||
let A10 = 0.3
|
|
||||||
goto A0
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
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
|
|
||||||
```
|
|
@ -1,69 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Soft Serve through https"
|
|
||||||
tags: [ "data", "git" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
## `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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
title: "sqlite"
|
|
||||||
tags: [ "Documentation", "data" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Work with a database:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sqlite3 "$FILE".sqlite3
|
|
||||||
```
|
|
||||||
Compress the database:
|
|
||||||
|
|
||||||
```sqlite
|
|
||||||
pragma vacuum;
|
|
||||||
```
|
|
||||||
Optimize the database:
|
|
||||||
|
|
||||||
```sqlite
|
|
||||||
pragma optimize;
|
|
||||||
```
|
|
||||||
|
|
57
distros/arch/scripts/archpi.sh
Normal file
57
distros/arch/scripts/archpi.sh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/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
|
9
distros/arch/scripts/gitea_install.sh
Normal file
9
distros/arch/scripts/gitea_install.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/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
|
79
distros/arch/scripts/pihole.sh
Normal file
79
distros/arch/scripts/pihole.sh
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#!/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
|
||||||
|
|
8
distros/arch/scripts/steam.sh
Normal file
8
distros/arch/scripts/steam.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/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
|
||||||
|
|
10
distros/arch/scripts/yay.sh
Normal file
10
distros/arch/scripts/yay.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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,33 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Brand Name Wallpaper"
|
|
||||||
tags: [ "void" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
To automatically stick the logo onto your background, do these commands in the directory.
|
|
||||||
|
|
||||||
Get the void linux logo from wikipedia
|
|
||||||
|
|
||||||
```bash
|
|
||||||
wget https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Void_Linux_logo.svg/256px-Void_Linux_logo.svg.png?20170131170632
|
|
||||||
```
|
|
||||||
|
|
||||||
Rename it, and resize it (the standard size is too small for most wallpapers)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
convert -resize 200% '256px-Void_Linux_logo.svg.png?20170131170632' void-logo.png
|
|
||||||
```
|
|
||||||
Download a pretty wallpaper
|
|
||||||
|
|
||||||
```bash
|
|
||||||
wget http://wallpapercave.com/wp/Wlm9Gv0.jpg
|
|
||||||
```
|
|
||||||
|
|
||||||
Put the void logo on all *jpg and *png images
|
|
||||||
|
|
||||||
```bash
|
|
||||||
for x in *.jpg
|
|
||||||
do
|
|
||||||
composite -compose multiply -gravity Center void-logo.png "$x" "$x"
|
|
||||||
done
|
|
||||||
```
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Void locale"
|
|
||||||
tags: [ "void", "locale" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Check the current locales:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
locale -a
|
|
||||||
```
|
|
||||||
|
|
||||||
Add the languages you want by editing `/etc/default/libc-locales`, and uncommenting your choice:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#en_DK.UTF-8 UTF-8
|
|
||||||
#en_DK ISO-8859-1
|
|
||||||
en_GB.UTF-8 UTF-8
|
|
||||||
en_GB ISO-8859-1
|
|
||||||
#en_HK.UTF-8 UTF-8
|
|
||||||
#en_HK ISO-8859-1
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can generate what you need for those languages.
|
|
||||||
However, instead of generating what you need, you're going to generate everything which needs updating:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo xbps-reconfigure glibc-locales
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally, select your chosen locale by placing it in `/etc/locale.conf`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
echo "LC_ALL=en_GB.UTF-8
|
|
||||||
LANG=en_GB.UTF-8
|
|
||||||
LANGUAGE=en_GB.UTF-8" > /etc/locale.conf
|
|
||||||
|
|
||||||
|
|
||||||
#en_DK.UTF-8 UTF-8
|
|
||||||
#en_DK ISO-8859-1
|
|
||||||
en_GB.UTF-8 UTF-8
|
|
||||||
en_GB ISO-8859-1
|
|
||||||
#en_HK.UTF-8 UTF-8
|
|
||||||
#en_HK ISO-8859-1
|
|
||||||
```
|
|
||||||
|
|
||||||
Check your new locales are available:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
locale -a
|
|
||||||
```
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: "Easy Network Graph"
|
title: "graph-easy"
|
||||||
tags: [ "Documentation", "Networking" ]
|
tags: [ "Documentation" ]
|
||||||
---
|
---
|
||||||
Set up a file like this, called `troubleshooting.txt`.
|
Set up a file like this, called `troubleshooting.txt`.
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ Try placing this in a file:
|
|||||||
|
|
||||||
> [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; }
|
> [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; }
|
||||||
>
|
>
|
||||||
> [ One ] => { arrow-style: closed; } [ Three ] { border-style: none; }
|
> [ One ] => { arrow-style: closed; } [ Three ]
|
||||||
>
|
>
|
||||||
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ]
|
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ]
|
||||||
>
|
>
|
||||||
@ -54,15 +54,3 @@ Try placing this in a file:
|
|||||||
> [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
|
> [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
|
||||||
>
|
>
|
||||||
> [ no Network ] --> [ Is there an IP address? ]
|
> [ no Network ] --> [ Is there an IP address? ]
|
||||||
|
|
||||||
> [ Little Group: o]
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
echo "( EU [ Madrid ] <---> [ K ] {label: Karlsruhe;}
|
|
||||||
<== ...O\n ..o\n .O\no \nchoo choo ==> [ Cern ] [ Cern ] <== ...O\n ..o\n .O\no \nchoo choo ==> [ Paris ] <...> [ B ] {label: Budapest} )
|
|
||||||
[ B ] <---> [ Belgrade ] [ G ] {label: Glasgow; }
|
|
||||||
<==> [ M ] {label: Manchester },
|
|
||||||
[ Madrid ] <---> [ Belgrade ] [ M ] <--> [ London ] <--> [ B ],
|
|
||||||
[ Belgrade ]" | graph-easy --boxart
|
|
||||||
```
|
|
||||||
|
27
networking/pip.md
Normal file
27
networking/pip.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
title: "pip"
|
||||||
|
tags: [ "Documentation", "Networking" ]
|
||||||
|
---
|
||||||
|
```
|
||||||
|
|
||||||
|
Searching does not work.
|
||||||
|
|
||||||
|
Install with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install [ package ]
|
||||||
|
```
|
||||||
|
|
||||||
|
Upgrade all packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
|
||||||
|
```
|
||||||
|
|
||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
You may need a python3 package.
|
||||||
|
In this case, try:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install [ package ]
|
@ -1,89 +0,0 @@
|
|||||||
---
|
|
||||||
title: "ssh"
|
|
||||||
tags: [ "networking" ]
|
|
||||||
---
|
|
||||||
# Basic `ssh`
|
|
||||||
|
|
||||||
Try out basic ssh by accessing `git.charm.sh`, without needing authentication:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ssh git.charm.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Start an ssh server to try it out.
|
|
||||||
The ssh server is sometimes in a package called `openssh`, and sometimes only in `openssh-server`.
|
|
||||||
|
|
||||||
Once it's installed, check it's working:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl status ssh
|
|
||||||
```
|
|
||||||
|
|
||||||
If that doesn't work, the service may be called `sshd`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl status sshd
|
|
||||||
```
|
|
||||||
|
|
||||||
Then start that service:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl start sshd
|
|
||||||
```
|
|
||||||
Test it works by using ssh into your own system, from inside:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ssh $USER@localhost
|
|
||||||
```
|
|
||||||
|
|
||||||
Access the computer from another computer on the same local network by finding your computer's IP address.
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ip address | grep inet
|
|
||||||
```
|
|
||||||
|
|
||||||
Here is mine:
|
|
||||||
|
|
||||||
|
|
||||||
> inet 127.0.0.1/8 scope host lo
|
|
||||||
>
|
|
||||||
> inet6 ::1/128 scope host noprefixroute
|
|
||||||
>
|
|
||||||
> inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic noprefixroute en
|
|
||||||
|
|
||||||
|
|
||||||
The first one starts `127`, which means it returns back to that computer (like `localhost`).
|
|
||||||
The second is an ipv6 address, which is too angelic for this world, and has yet to ascend.
|
|
||||||
The third will work from a remote computer.
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ssh $USERNAME@IP_ADDRESS
|
|
||||||
```
|
|
||||||
|
|
||||||
Once you have that, generate some ssh keys:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ssh-keygen
|
|
||||||
```
|
|
||||||
|
|
||||||
Look at your keys:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ls ~/.ssh
|
|
||||||
```
|
|
||||||
|
|
||||||
You can share the one ending in `.pub` freely.
|
|
||||||
The other is secret.
|
|
||||||
|
|
||||||
Now send those keys to a remote computer:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ssh-copy-id $USERNAME@IP_ADDRESS
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can log in without a password.
|
|
@ -83,7 +83,7 @@ If the file is in your home - `~` - but `transmission` is not allowed in your ho
|
|||||||
Next, find the torrent's number. You can use multiple numbers, separated with a comma:
|
Next, find the torrent's number. You can use multiple numbers, separated with a comma:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
transmission-remote -t 3,5,8 --move $HOME/music
|
transmission-remote -t 3,5,8 --move /home/alice/music
|
||||||
```
|
```
|
||||||
|
|
||||||
## Change Default Location
|
## Change Default Location
|
||||||
@ -136,32 +136,3 @@ Without the `--anonymize` flag, the torrent file output will have a 'created by'
|
|||||||
- udp://explodie.org:6969/announce
|
- udp://explodie.org:6969/announce
|
||||||
- https://tracker.gbitt.info:443/announce
|
- https://tracker.gbitt.info:443/announce
|
||||||
- http://tracker.gbitt.info:80/announce
|
- http://tracker.gbitt.info:80/announce
|
||||||
|
|
||||||
## Verify
|
|
||||||
|
|
||||||
Add your torrent and notes its number:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
transmission-remote -a "$file".torrent
|
|
||||||
transmission-remote -l
|
|
||||||
transmission-remote -t "$number" -i
|
|
||||||
```
|
|
||||||
|
|
||||||
The information in the last command shows that it's not verified, so you can verify with `-v`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
transmission-remote -t "$number" -v
|
|
||||||
```
|
|
||||||
|
|
||||||
If transmission cannot find it, then tell it where to find the torrent:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
transmission-remote -t "$number" --find "$(pwd)"
|
|
||||||
```
|
|
||||||
...and of course, make sure the permissions allow transmission to see the target.
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ls -ld "$file"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
@ -93,9 +93,7 @@ apt install python3-certbot-nginx
|
|||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
domain=example.com
|
certbot --nginx -d *mysite.tk* --non-interactive --agree-tos -m *webmaster@email.tld*
|
||||||
my_email=me@posteo.uk
|
|
||||||
certbot --nginx -d "$domain" --non-interactive --agree-tos -m "$my_email"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
When you are asked about redirecting from HTTP to HTTPS, say yes (option "2").
|
When you are asked about redirecting from HTTP to HTTPS, say yes (option "2").
|
||||||
|
2
new.sh
2
new.sh
@ -14,7 +14,7 @@ filePath="$category/$(echo $name | sed 's/ /_/g').md"
|
|||||||
|
|
||||||
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
|
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
|
||||||
|
|
||||||
[ -e "$filePath" ] && $EDITOR "$filePath" && exit 0
|
[ -e "$filePath" ] && $EDITOR $filePath && exit 0
|
||||||
|
|
||||||
echo "---
|
echo "---
|
||||||
title: \"$name\"
|
title: \"$name\"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: "bash tips"
|
title: "Terminal Tips"
|
||||||
tags: [ "Documentation", "Shell", "POSIX" ]
|
tags: [ "Documentation", "System" ]
|
||||||
---
|
---
|
||||||
## Track Live Changes
|
## Track Live Changes
|
||||||
|
|
||||||
@ -12,11 +12,6 @@ See changes in a directory, as it changes:
|
|||||||
|
|
||||||
`watch -d ls *directory*`
|
`watch -d ls *directory*`
|
||||||
|
|
||||||
Or use the `-g` flag to exit once the output changes.
|
|
||||||
This command will look at whether you're connected to the internet, and turn into a rainbow once the connection hits.
|
|
||||||
|
|
||||||
> watch -g ip address && clear && ip address | lolcat
|
|
||||||
|
|
||||||
## Automatic Renaming
|
## Automatic Renaming
|
||||||
|
|
||||||
There are a bunch of files:
|
There are a bunch of files:
|
||||||
@ -39,19 +34,17 @@ done
|
|||||||
|
|
||||||
IFS is the field separator. This is required to denote the different files as marked by a new line, and not the spaces.
|
IFS is the field separator. This is required to denote the different files as marked by a new line, and not the spaces.
|
||||||
|
|
||||||
(Alternatively, just install `renameutils` and do `rename Column Alice *`)
|
|
||||||
|
|
||||||
## Arguments and Input
|
## Arguments and Input
|
||||||
|
|
||||||
The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm.
|
The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm.
|
||||||
To fix this, use `xargs` to turn the stdin into an argument.
|
|
||||||
For example, if we have a list of files called `list.txt' then we could use cat as so:
|
That said, we can sometimes pipe into rm with `xargs rm' to turn the stdin into an argument. For example, if we have a list of files called `list.txt' then we could use cat as so:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cat list.txt | xargs rm
|
cat list.txt | xargs rm
|
||||||
```
|
```
|
||||||
|
|
||||||
Of course if spaces are included in the file, you would have to account for that.
|
... *However*, this wouldn't work if spaces were included, as rm would take everything literally.
|
||||||
|
|
||||||
## Numbers
|
## Numbers
|
||||||
|
|
||||||
@ -67,18 +60,6 @@ Add number to variables with:
|
|||||||
|
|
||||||
`((n--))` works identically.
|
`((n--))` works identically.
|
||||||
|
|
||||||
### POSIX WARNING
|
|
||||||
|
|
||||||
The number commands above work in `bash`, but not in bare-ass POSIX shells, such as `dash`.
|
|
||||||
|
|
||||||
Instead, you might do:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
x=2
|
|
||||||
x=$(( x +1 ))
|
|
||||||
x=$(( x*x ))
|
|
||||||
```
|
|
||||||
|
|
||||||
## Finding Duplicate Files
|
## Finding Duplicate Files
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -90,27 +71,3 @@ find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15
|
|||||||
```bash
|
```bash
|
||||||
cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
||||||
```
|
```
|
||||||
|
|
||||||
## Temporary Working Directory
|
|
||||||
|
|
||||||
Try something out in a random directory in `/tmp` so the files will be deleted when you next shut down.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mktemp -d
|
|
||||||
```
|
|
||||||
|
|
||||||
That gives you a random directory to mess about in.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
dir=$(mktemp -d)
|
|
||||||
for x in {A..Z}; do
|
|
||||||
fortune > "$dir"/chimpan-$x
|
|
||||||
done
|
|
||||||
cd $dir
|
|
||||||
```
|
|
||||||
|
|
||||||
### POSIX WARNING
|
|
||||||
|
|
||||||
These smart-brackets are a bash feature.
|
|
||||||
If you try to use `{A..Z}` in dash, it will think of this as a single item.
|
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
../basics/cron.md
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
title: "deduplicate"
|
|
||||||
tags: [ "system", "deduplicate", "duplicates", "maintenance" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
`rdfind`: find duplicate files, then delete them, or turn them into links.
|
|
||||||
|
|
||||||
Ask if a directory has duplicates (`rdfind` will not delete anything):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
rdfind $dir
|
|
||||||
$EDITOR results.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace the duplicated files with [hard links](../basics/hard_links.md).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
rdfind -makehardlinks true $dir
|
|
||||||
```
|
|
@ -22,7 +22,6 @@ And overwrite all metadata:
|
|||||||
```bash
|
```bash
|
||||||
exiftool -all= -overwrite_original -ext jpg .
|
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:
|
Or just GPS data:
|
||||||
|
|
||||||
@ -37,4 +36,3 @@ identify -verbose
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,14 +13,11 @@ The ordering of `/etc/fstab` is
|
|||||||
5. dump
|
5. dump
|
||||||
6. pass
|
6. pass
|
||||||
|
|
||||||
|
E.g.:
|
||||||
|
|
||||||
*Example:*
|
> UUID=877f14e8-4738-46b0-884f-ba330dad1a7d /mnt/biggie ext4 nofail,rw,relatime 0 2
|
||||||
|
>
|
||||||
```
|
> UUID=B21648C416488AF5 /mnt/share ntfs nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0
|
||||||
UUID=877f14e8-4738-46b0-884f-ba330dad1a7d /mnt/biggie ext4 nofail,rw,relatime 0 2
|
|
||||||
|
|
||||||
UUID=B21648C416488AF5 /mnt/share ntfs nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5: Dump
|
## 5: Dump
|
||||||
|
|
||||||
|
75
system/lf.md
75
system/lf.md
@ -1,75 +0,0 @@
|
|||||||
---
|
|
||||||
title: "lf - The Light File Manager"
|
|
||||||
tags: [ "Documentation", "File Browser" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
## Config File
|
|
||||||
|
|
||||||
If you don't have a `~/.config/lf/lfrc` file, you can probably find an example in `/usr/share/examples/lf`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp -r /usr/share/examples/lf ~/.config/
|
|
||||||
```
|
|
||||||
|
|
||||||
Go straight to root with two keys.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
map g/ cd /
|
|
||||||
```
|
|
||||||
|
|
||||||
Have lf open a file with the default program when you press 'o', using the program `mimeo`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
map o &mimeo $f
|
|
||||||
```
|
|
||||||
|
|
||||||
Change that default text editor to look at the extension first.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cmd open ${{
|
|
||||||
case $(file --mime-type $f -b) in
|
|
||||||
application/x-sc) sc-im $fx;;
|
|
||||||
text/html) w3m $fx;;
|
|
||||||
text/*) $EDITOR $fx;;
|
|
||||||
video/*) nohup mpv $fx --really-quiet >/dev/null &;;
|
|
||||||
*) nohup $OPENER $fx >/dev/null &;;
|
|
||||||
esac
|
|
||||||
}}
|
|
||||||
```
|
|
||||||
|
|
||||||
The idea here is to use the default `$OPENER` for lf, but first check extensions.
|
|
||||||
Note the extra `mpv` commands to leave the video to play, without blocking the terminal.
|
|
||||||
|
|
||||||
### Interesting Options
|
|
||||||
|
|
||||||
You can set the screen ratio with
|
|
||||||
`set ratios 1:2:3`
|
|
||||||
|
|
||||||
That leaves it as a small initial pane, a medium pane, and a large pane for file previews.
|
|
||||||
|
|
||||||
### Rename
|
|
||||||
|
|
||||||
The standard renaming is bad, because you have to re-type the file extension.
|
|
||||||
Use this instead:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# rename current file without overwrite
|
|
||||||
cmd rename %echo 'name: ' ; read name ; extension="${f##*.}" && newname="$name.$extension"; [ "$f" = "$extension" ] && newname="$name"; [ ! -e "$newname" ] && mv "$f" "$newname" || echo file exists
|
|
||||||
map r push :rename<enter>
|
|
||||||
```
|
|
||||||
|
|
||||||
If you try to rename `image_1.png` with this command, you can type in `cats`, and the result will be `cats.png`.
|
|
||||||
|
|
||||||
## Image Previews
|
|
||||||
|
|
||||||
First, install `ueberzug` (to show images).
|
|
||||||
Then clone the lfrun repo.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/cirala/lfimg.git
|
|
||||||
|
|
||||||
cd lfimg
|
|
||||||
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Monitoring"
|
|
||||||
tags: [ "Documentation", "System", "CPU", "Memory" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Print the average CPU load over 1 minute, 5 minutes, and 15 minutes:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
watch -d cat /proc/loadavg
|
|
||||||
stress="$(cat /proc/loadavg | awk '{print "Usage:" $2"%"}')"
|
|
||||||
```
|
|
||||||
|
|
||||||
Show memory usage in Gibitytes.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
free -g
|
|
||||||
```
|
|
||||||
Show low and high gigibtye usage on a *l*ine, and repeat the measurement every 5 seconds:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
REP=5
|
|
||||||
free --lohi -g -s $REP | lolcat
|
|
||||||
```
|
|
||||||
|
|
||||||
Check the next thing cron will do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cronnext /var/spool/cron/$USER -l
|
|
||||||
```
|
|
@ -2,24 +2,6 @@
|
|||||||
title: "journal"
|
title: "journal"
|
||||||
tags: [ "Documentation", "systemd" ]
|
tags: [ "Documentation", "systemd" ]
|
||||||
---
|
---
|
||||||
|
|
||||||
See a running log of all system messages:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
journalctl -f
|
|
||||||
```
|
|
||||||
|
|
||||||
Or just one user:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
journalctl --user -f
|
|
||||||
```
|
|
||||||
|
|
||||||
Or just one unit (`sshd`):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
journalctl -f -u sshd
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Find errors since November
|
Find errors since November
|
||||||
@ -32,13 +14,3 @@ Limit size to 2G.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
journalctl --vacuum-size=2G
|
journalctl --vacuum-size=2G
|
||||||
```
|
|
||||||
|
|
||||||
Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can notice why your system's broken:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
logger "Installed new dnsmasq"
|
|
||||||
sudo journalctl -f
|
|
||||||
```
|
|
||||||
|
|
||||||
|
77
system/vncserver
Normal file
77
system/vncserver
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# Ubuntu
|
||||||
|
https://linuxconfig.org/vnc-server-on-ubuntu-18-04-bionic-beaver-linux
|
||||||
|
|
||||||
|
|
||||||
|
# On server
|
||||||
|
|
||||||
|
Enable remote desktop access.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install vnc4server xfce4 xfce4-goodies
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable the vncserver desktop:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vncserver -kill :1
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the config in ~/.vnc/xstartup with:
|
||||||
|
|
||||||
|
`#!/bin/bash`
|
||||||
|
|
||||||
|
`startxfce4 &`
|
||||||
|
|
||||||
|
# Arch
|
||||||
|
|
||||||
|
Install tigervnc, then run it to set a password:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vncserver
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll get a session number.
|
||||||
|
|
||||||
|
Shut it down with the 'kill' command and the session's number:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vncserver -kill :1
|
||||||
|
```
|
||||||
|
|
||||||
|
This will forward over port 5900+x where x is the session number. For the first server, that's port 5901.
|
||||||
|
|
||||||
|
# Create a systemd service
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/systemd/system/vncserver@:1.service
|
||||||
|
```
|
||||||
|
|
||||||
|
Then enter:
|
||||||
|
|
||||||
|
> [Unit]
|
||||||
|
> Description=Remote desktop service (VNC)
|
||||||
|
> After=syslog.target network.target
|
||||||
|
>
|
||||||
|
> [Service]
|
||||||
|
> Type=simple
|
||||||
|
> User=foo
|
||||||
|
> PAMName=login
|
||||||
|
> PIDFile=/home/%u/.vnc/%H%i.pid
|
||||||
|
> ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
|
||||||
|
> ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg
|
||||||
|
> ExecStop=/usr/bin/vncserver -kill %i
|
||||||
|
>
|
||||||
|
> [Install]
|
||||||
|
> WantedBy=multi-user.target
|
||||||
|
|
||||||
|
Then enable that service:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl start vncserver@:1.service
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
title: "vim in bash"
|
|
||||||
tags: [ "vim", "bash", "inputrc" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Put bash in vim mode!
|
|
||||||
|
|
||||||
Place the following in your `~/.inputrc`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
set editing-mode vi
|
|
||||||
set show-mode-in-prompt on
|
|
||||||
set vi-ins-mode-string \1\e[33;32m\2[>]=\1\e[0m\2
|
|
||||||
set vi-cmd-mode-string \1\e[33;1m\2[?]=\1\e[0m\2
|
|
||||||
|
|
||||||
set keymap vi-insert
|
|
||||||
RETURN: "\e\n"
|
|
||||||
```
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
title: "QR Codes"
|
|
||||||
tags: [ "Documentation", "qrencode", "zbar" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Make a QR Code image:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png
|
|
||||||
```
|
|
||||||
|
|
||||||
Make a QR Coded message in the terminal:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
qrencode -t ansi "Hello World"
|
|
||||||
```
|
|
||||||
|
|
||||||
Read a QR Code image:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
zbarimg $FILE
|
|
||||||
```
|
|
||||||
|
|
||||||
Show wifi QR code (only with Network Manager):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nmcli device wifi show-password
|
|
||||||
```
|
|
@ -2,6 +2,7 @@
|
|||||||
title: "imagemagick"
|
title: "imagemagick"
|
||||||
tags: [ "Documentation", "Vision" ]
|
tags: [ "Documentation", "Vision" ]
|
||||||
---
|
---
|
||||||
|
[Source](http://lxlinux.com/imagemagick.html)
|
||||||
|
|
||||||
Convert jpg to png.
|
Convert jpg to png.
|
||||||
|
|
||||||
@ -40,13 +41,13 @@ convert image.jpg -resize 25% output.jpg
|
|||||||
|
|
||||||
# Trim images to border
|
# Trim images to border
|
||||||
|
|
||||||
This is generally used for transparent images.
|
This is generally used for transparrent images.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
convert -trim image.png output.png
|
convert -trim image.png output.png
|
||||||
```
|
```
|
||||||
|
|
||||||
Make the white of an image transparent.
|
Make the white of an image transparrent.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
convert -transparent white -fuzz 10% input.png output.png
|
convert -transparent white -fuzz 10% input.png output.png
|
||||||
@ -100,7 +101,7 @@ See your installed fonts:
|
|||||||
convert -list font
|
convert -list font
|
||||||
```
|
```
|
||||||
|
|
||||||
Make an image showing day of the week:
|
Make na image showing day of the week:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
convert -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png
|
convert -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Markdown to PDF"
|
|
||||||
tags: [ "Documentation", "Markdown", "PDF", "Vision" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
Turn a markdown file into a pdf:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf
|
|
||||||
```
|
|
||||||
|
|
||||||
*Example:* put [this Makefile](lowdown/example.txt) in a directory, rename it `Makefile`, then do:
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make example
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
To give the document a title, put that title in the metadata:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sed -i "1 i---" "$FILE".md
|
|
||||||
sed -i "1 ititle: $TITLE" "$FILE".md
|
|
||||||
sed -i "1 i---" "$FILE".md
|
|
||||||
lowdown -L "$FILE".md
|
|
||||||
lowdown -X title "$FILE".md
|
|
||||||
lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf
|
|
||||||
```
|
|
@ -1,36 +0,0 @@
|
|||||||
output: all
|
|
||||||
|
|
||||||
.PHONY: example
|
|
||||||
example: html/foot.html html/head.html
|
|
||||||
mkdir -p articles/
|
|
||||||
fortune > articles/fort_1.md
|
|
||||||
fortune > articles/fort_2.md
|
|
||||||
|
|
||||||
HTML = $(patsubst articles/%.md,public/%.html,$(wildcard articles/*.md))
|
|
||||||
|
|
||||||
$(HTML): public/ articles/ $(wildcard html/*)
|
|
||||||
|
|
||||||
html/head.html:
|
|
||||||
@mkdir $(@D)
|
|
||||||
echo '<head> Something about CSS probably </head>' > $@
|
|
||||||
echo '<body>' >> $@
|
|
||||||
|
|
||||||
html/foot.html: html/head.html
|
|
||||||
echo '</body>' >> $@
|
|
||||||
|
|
||||||
public/%.html : articles/%.md
|
|
||||||
cat html/head.html > $@
|
|
||||||
lowdown $< >> $@
|
|
||||||
cat html/foot.html >> $@
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all : $(HTML)
|
|
||||||
|
|
||||||
articles/:
|
|
||||||
mkdir $@
|
|
||||||
|
|
||||||
public/:
|
|
||||||
mkdir $@
|
|
||||||
|
|
||||||
clean :
|
|
||||||
rm -rf public
|
|
17
vision/qrencode.md
Normal file
17
vision/qrencode.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: "qrencode"
|
||||||
|
tags: [ "Documentation", "vision" ]
|
||||||
|
---
|
||||||
|
|
||||||
|
Make a QR Code image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o qr_briar.png
|
||||||
|
```
|
||||||
|
|
||||||
|
Make a QR Coded message in the terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qrencode -t ansi "Hello World"
|
||||||
|
```
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user