Compare commits

..

18 Commits

Author SHA1 Message Date
e77d0676cf
fix void locale notes 2023-12-02 03:09:31 +01:00
c6e673f1b0
add cron symlink 2023-10-18 23:25:59 +02:00
772f642679
add keyserver list 2023-10-18 23:25:54 +02:00
69d6c1ab53
syntax 2023-10-18 23:14:09 +02:00
6525ad85ad
add tree 2023-10-17 19:04:59 +02:00
ad9054c212
add void locales 2023-10-15 13:36:47 +02:00
93a48fded8
write basic ssh 2023-09-27 02:18:40 +02:00
c4313277e8
write ls 2023-09-27 02:18:31 +02:00
aac3df9997
add email 2023-09-25 20:20:00 +02:00
c732d7d18d
vim in bash 2023-09-25 00:11:09 +02:00
b24a330f7a
add radicale with nginx 2023-09-21 02:01:24 +02:00
0fc1f58d24
add calcurse holidays 2023-09-21 01:53:32 +02:00
ff3a3d2556
spelling 2023-09-18 23:44:39 +02:00
6557ec6ebe
remove dead link 2023-09-18 23:44:29 +02:00
912eeb478b
place posix shell warnings 2023-09-16 18:10:13 +02:00
aa34b8b6e8
yes yes yes yes 2023-09-14 18:59:50 +02:00
fac575fc59
add void wallpaper nonsense 2023-09-10 18:22:18 +02:00
b7fa4ab8c7
edit bash_tricks 2023-09-08 19:11:08 +02:00
14 changed files with 578 additions and 14 deletions

46
basics/ls.md Normal file
View 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
```

25
basics/tree.md Normal file
View File

@ -0,0 +1,25 @@
---
title: "tree"
tags: [ "basics" ]
---
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.

24
basics/yes.md Normal file
View 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
```

9
data/calcurse.md Normal file
View File

@ -0,0 +1,9 @@
---
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).

73
data/email.md Normal file
View 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:
```
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/*
```

View File

@ -82,7 +82,7 @@ This is a fingerprint.
You can now decide the trust level (this stays on your computer). You can now decide the trust level (this stays on your computer).
```bash ```bash
gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF* gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
``` ```
Once you're in the interface, type `trust`. Once you're in the interface, type `trust`.
@ -91,29 +91,52 @@ Once you're in the interface, type `trust`.
gpg --sign-key alice@posteo.net gpg --sign-key alice@posteo.net
``` ```
Then send those trusted keys up to a server, so people can see you have verified them: # 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 ```bash
gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F* 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 # 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 ```bash
gpg --refresh-keys gpg --refresh-keys
``` ```
You can use the [crontab](../basics/cron.md) to refresh keys.
# Export # Export
Your public key: Your public key:
```bash ```bash
gpg --output *me*.gpg --armor --export gpg --output me.gpg --armor --export
``` ```
or or
```bash ```bash
gpg --export -a *person@email.tld* > *my_key*.pub gpg --export -a person@email.tld > my_key.pub
``` ```

126
data/radicale.md Normal file
View File

@ -0,0 +1,126 @@
---
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
```
If the service is started, restart it to make sure nobody can sign in without a password.
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.

View File

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

54
distros/void/locale.md Normal file
View File

@ -0,0 +1,54 @@
---
title: "locales"
tags: [ "void" ]
---
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
```

89
networking/ssh.md Normal file
View File

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

View File

@ -1,6 +1,6 @@
--- ---
title: "Terminal Tips" title: "bash tips"
tags: [ "Documentation", "System" ] tags: [ "Documentation", "Shell", "POSIX" ]
--- ---
## Track Live Changes ## Track Live Changes
@ -12,6 +12,11 @@ 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:
@ -34,17 +39,19 @@ 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.
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: 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
``` ```
... *However*, this wouldn't work if spaces were included, as rm would take everything literally. Of course if spaces are included in the file, you would have to account for that.
## Numbers ## Numbers
@ -60,6 +67,18 @@ 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
@ -71,3 +90,27 @@ 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
system/cron.md Symbolic link
View File

@ -0,0 +1 @@
../basics/cron.md

19
vim/vim_in_bash.md Normal file
View File

@ -0,0 +1,19 @@
---
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"
```

View File

@ -2,7 +2,6 @@
title: "imagemagick" title: "imagemagick"
tags: [ "Documentation", "Vision" ] tags: [ "Documentation", "Vision" ]
--- ---
[Source](http://lxlinux.com/imagemagick.html)
Convert jpg to png. Convert jpg to png.
@ -41,13 +40,13 @@ convert image.jpg -resize 25% output.jpg
# Trim images to border # Trim images to border
This is generally used for transparrent images. This is generally used for transparent images.
```bash ```bash
convert -trim image.png output.png convert -trim image.png output.png
``` ```
Make the white of an image transparrent. Make the white of an image transparent.
```bash ```bash
convert -transparent white -fuzz 10% input.png output.png convert -transparent white -fuzz 10% input.png output.png
@ -101,7 +100,7 @@ See your installed fonts:
convert -list font convert -list font
``` ```
Make na image showing day of the week: Make an 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