change ``bash headers to
``sh
This commit is contained in:
22
basics/at.md
22
basics/at.md
@@ -4,43 +4,43 @@ tags: [ "basics", "time" ]
|
||||
---
|
||||
Install with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt install at
|
||||
```
|
||||
|
||||
Enable the daemon service with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl enable --now atd
|
||||
```
|
||||
|
||||
Then jobs can be specified with absolute time, such as:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
at 16:20
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
at noon
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
at midnight
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
at teatime
|
||||
```
|
||||
|
||||
Type in your command, e.g.:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
touch /tmp/$FILE.txt
|
||||
```
|
||||
|
||||
The jobs can also be specified relative to the current time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
at now +15 minutes
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ Finally, accept the jobs with ^D.
|
||||
|
||||
Display a list of commands to run with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
atq
|
||||
```
|
||||
|
||||
@@ -58,7 +58,7 @@ atq
|
||||
|
||||
This will print all pending IDs. Remove a job by the ID with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
atrm 2
|
||||
```
|
||||
|
||||
@@ -68,7 +68,7 @@ Check `/var/spool/atd/` to see the jobs.
|
||||
|
||||
Automatically add a job for later, by setting the date, then using echo for the command.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
t="$(date -d "2 minutes" +%R)"
|
||||
echo "fortune > ~/$FILE" | at "$t"
|
||||
watch cat $FILE
|
||||
|
@@ -9,13 +9,13 @@ Don't worry about understanding any of it, just type it in and the habit forms p
|
||||
|
||||
You start in a dark room. You want to know where you are by **p**rinting out your **w**orking '**d**irectory' (i.e. 'location'):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pwd
|
||||
```
|
||||
|
||||
Have a look at what is here:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls
|
||||
```
|
||||
|
||||
@@ -23,11 +23,11 @@ If you get no response, the list of items is "", meaning "nothing here".
|
||||
|
||||
Have a look at **a**ll the files:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -a
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
. ..
|
||||
```
|
||||
|
||||
@@ -35,38 +35,38 @@ So `.` means 'here' and `..` means 'you see stairs leading downwards' (e.g. 'the
|
||||
|
||||
Change directory (`cd`) down one level:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd ..
|
||||
```
|
||||
|
||||
Look where you are again with `pwd`, then go back up. Use `ls`, and if you see `bob`, then:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd bob
|
||||
```
|
||||
|
||||
Move around the directories. The place at the bottom is the 'root', and is known as `/`. Go to the root:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd /
|
||||
```
|
||||
|
||||
Do `ls` again and `cd` into `etc`. Look at how much space those folders are taking up:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
du iptables
|
||||
```
|
||||
That's the number of kilobytes the file is taking up.
|
||||
Do the same again, but in a human-readable format:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
du -h iptables
|
||||
```
|
||||
|
||||
The `du` program has `-h` for 'human', '-s' for 'short', and a bunch of other commands.
|
||||
Have a look at the manual and try another command:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
man du
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ Once you're done, press 'q' to quit the manual page and try the extra `du` flag
|
||||
|
||||
Now you can try to gain super-powers and take over the system:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo -i
|
||||
```
|
||||
|
||||
@@ -82,61 +82,61 @@ At this point, you are 'root'.
|
||||
All your commands will be executed, even if they're unsafe, or even if you ask to delete the entire machine.
|
||||
Best to exit out of the root account:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
exit
|
||||
```
|
||||
|
||||
Go find a file that isn't a directory. You can tell which is which with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -l
|
||||
```
|
||||
|
||||
A directory starts with a 'd', like this:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
drwxr-xr-x 79 root root 4096 Jan 3 05:15 /etc/
|
||||
```
|
||||
|
||||
A standard file starts with '-', like this:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
`-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname`
|
||||
```
|
||||
|
||||
Look inside the file /etc/hostname to find out your computer's name:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /etc/hostname
|
||||
```
|
||||
|
||||
Print out the words "hello world":
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo "hello world"
|
||||
```
|
||||
|
||||
Move back to your home directory:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd
|
||||
```
|
||||
|
||||
Take the words 'hello world', and put them in 'my_file':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'hello world' > my_file
|
||||
```
|
||||
|
||||
Measure the disk usage of that file, then put the results at the bottom of the file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
du $FILE >> $FILE
|
||||
```
|
||||
|
||||
And check the results:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat $FILE
|
||||
```
|
||||
|
||||
@@ -148,7 +148,7 @@ Press tab after typing a few keys and bash will guess what you're trying to typ
|
||||
|
||||
Look at your file's owner:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -l $FILE
|
||||
```
|
||||
|
||||
@@ -156,19 +156,19 @@ If it says `-rw-r--r-- 1 root root 8 Dec 11 17:26 hostname` then the file is own
|
||||
|
||||
Take your file and change the owner to root:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo chown root $FILE
|
||||
```
|
||||
|
||||
Change the same file so it's owned by the group 'audio':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo chown :audio $FILE
|
||||
```
|
||||
|
||||
Check you did that correctly:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -l my_file
|
||||
```
|
||||
|
||||
@@ -176,7 +176,7 @@ ls -l my_file
|
||||
|
||||
Read the start of that line. Root can 'read' and 'write' to or delete the file. Try to remove (delete) it:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rm $FILE
|
||||
```
|
||||
|
||||
@@ -184,32 +184,32 @@ You'll see you're not allowed, because you don't own it.
|
||||
|
||||
Look at which groups you're in:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groups
|
||||
```
|
||||
|
||||
Change the file so that members of the audio group can write to the file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo chmod g+w $FILE
|
||||
```
|
||||
|
||||
Check you got it right with `ls -l`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
-rw-rw-r-- 1 root audio 0 Jan 3 19:20 my_file
|
||||
```
|
||||
|
||||
Try to delete the file again:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rm my_file
|
||||
```
|
||||
|
||||
If you can't, you're not in the audio group. Add yourself. You'll need to *modify* your *user account*, by **a**ppending 'audio' to your list of groups.
|
||||
Use `-a` to **a**ppend, and `-G`, to say you're modifying groups:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo usermod -a -G audio [ your username here ]
|
||||
```
|
||||
|
||||
@@ -219,19 +219,19 @@ Now you should be able to remove (delete) the file. Remember, that using 'rm fi
|
||||
|
||||
Make a directory called 'new test':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir 'new test'
|
||||
```
|
||||
|
||||
Make two directories, called 'A', and 'Z':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir A Z
|
||||
```
|
||||
|
||||
Make a single directory called 'A Z'
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir 'A Z'
|
||||
```
|
||||
|
||||
@@ -239,19 +239,19 @@ mkdir 'A Z'
|
||||
|
||||
Measure the disk usage of everything ('\*' means 'everything'), and put it in a file called 'disk usage.txt':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
du -sch * > A/'disk usage'.txt
|
||||
```
|
||||
|
||||
Look at your file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat A/'disk usage.txt'
|
||||
```
|
||||
|
||||
If you think you have too much information, use `grep` to just get the one line of text you want:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
grep total A/disk\ usage.txt
|
||||
```
|
||||
|
||||
@@ -259,7 +259,7 @@ The `grep` program also has a manual ('man page'). You should find out what tha
|
||||
|
||||
Start the manual:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
man du
|
||||
```
|
||||
|
||||
@@ -267,7 +267,7 @@ Then search for `-c` by pressing `/`. Your final keys should be `man du`, then
|
||||
|
||||
Find out if the `ls` program also has a 'human readable' format by using `grep` to search for the word 'human':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
man ls | grep human
|
||||
```
|
||||
|
||||
@@ -275,25 +275,25 @@ Now use that flag that you've found in combinatin with the `-l` flag to look at
|
||||
|
||||
Remove the directory 'Z':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rmdir Z
|
||||
```
|
||||
|
||||
Remove the directory 'Z':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rmdir Z
|
||||
```
|
||||
|
||||
And then remove all the rest:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rmdir *
|
||||
```
|
||||
|
||||
The 'A' directory will not budge because it's not empty. Remove it recursively, so the computer will remove the things inside the directory as well as the directory itself:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rm -r A
|
||||
```
|
||||
|
||||
@@ -303,11 +303,11 @@ You get a package manager which installs programs, fonts, et c.
|
||||
If you're on something like Debian, you'll have `apt`, or if you're on something like Red Hat, you'll have `yum`.
|
||||
If unsure, ask where a program is:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
whereis yum
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
whereis apt
|
||||
```
|
||||
|
||||
@@ -315,14 +315,14 @@ If you get a hit, you can use whatever program that is to install things.
|
||||
|
||||
Set a reminder of your package manager:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo my package manager is yum | lolcat
|
||||
```
|
||||
|
||||
If that failed it's because you don't have `lolcat` installed.
|
||||
Install lolcat:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt install lolcat
|
||||
```
|
||||
|
||||
@@ -330,13 +330,13 @@ Try the same command again.
|
||||
|
||||
Search for things you want, like `libreoffice`, or `gimp`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
apt search libreoffice
|
||||
```
|
||||
|
||||
... then install one of them with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
apt install $PROGRAM
|
||||
```
|
||||
|
||||
|
@@ -5,37 +5,37 @@ tags: [ "basics", "time" ]
|
||||
|
||||
Show system time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
date
|
||||
```
|
||||
|
||||
Show hardware time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo hwclock -r
|
||||
```
|
||||
|
||||
Change system time to match hardware time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo hwclock --hctosys
|
||||
```
|
||||
|
||||
Change hardware time to match system time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo hwclock --systohc
|
||||
```
|
||||
|
||||
Manually set the hardware time to a specified date:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo hwclock --set --date="8/25/19 13:30:00"
|
||||
```
|
||||
|
||||
## Normal Date
|
||||
|
||||
```bash
|
||||
```sh
|
||||
date +%d/%m/%y
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ Computers started counting time on January 1st, 1970, and added one second-per-s
|
||||
|
||||
Track the time in Unix-time:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
date +%s
|
||||
```
|
||||
|
||||
@@ -55,13 +55,13 @@ Servers which take their time from an observatory we call Stratum 1 servers. Se
|
||||
|
||||
Install ntp with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt-get install -y ntp
|
||||
```
|
||||
|
||||
The shell command for this is `ntpq`. Monitor the service providers using:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ntpq -p
|
||||
```
|
||||
|
||||
|
@@ -5,32 +5,32 @@ tags: [ "basics", "format", "json" ]
|
||||
|
||||
Put output into column.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
du -h /etc/* | column
|
||||
```
|
||||
|
||||
Reformat file with an explicit separator (`-s`):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
column -ts: /etc/passwd
|
||||
```
|
||||
|
||||
Give columns names (`-N`), so you can hide some (`-H`):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID /etc/passwd
|
||||
```
|
||||
|
||||
Reorder with `-O` (unspecified items remain):
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
column -ts: -N User,PW,UID,GID,Description,Home,shell -H PW,GID -O User,Description,shell /etc/passwd
|
||||
```
|
||||
|
||||
Output to json format with `-J`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd
|
||||
```
|
||||
|
||||
|
@@ -46,7 +46,7 @@ esac
|
||||
# While and Until
|
||||
This prints from 1 until 9.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
COUNTER=1
|
||||
while [ $COUNTER -lt 2 ]; do
|
||||
> ((COUNTER++))
|
||||
@@ -58,7 +58,7 @@ There's also 'until', which stops when something is true, rather than keeping go
|
||||
|
||||
# For
|
||||
|
||||
```bash
|
||||
```sh
|
||||
for i in $( ls ); do
|
||||
> du -sh $i
|
||||
> done
|
||||
@@ -70,19 +70,19 @@ The sequences tool counts up from X in jumps of Y to number Z.
|
||||
|
||||
Count from 1 to 10.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
seq 10
|
||||
```
|
||||
|
||||
Count from 4 to 11.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
seq 4 11
|
||||
```
|
||||
|
||||
Count from 1 to 100 in steps of 5.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
seq 1 5 100
|
||||
```
|
||||
|
||||
|
@@ -8,13 +8,13 @@ The `cronie` program is also known as `crond`.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt search -n ^cron
|
||||
```
|
||||
|
||||
Once installed, search for the service name, and start it.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl list-unit-files | grep cron
|
||||
sudo systemctl enable --now $NAME
|
||||
```
|
||||
@@ -23,20 +23,20 @@ sudo systemctl enable --now $NAME
|
||||
|
||||
Show your current crontab:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
crontab -l
|
||||
```
|
||||
|
||||
You can put this in a file and edit it:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
crontab -l > $filename
|
||||
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
|
||||
```
|
||||
|
||||
Then apply that crontab:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
crontab $filename
|
||||
rm $filename
|
||||
```
|
||||
@@ -70,7 +70,7 @@ Doing the same thing, but only in February, would be:
|
||||
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo "HOME=$HOME" > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
@@ -80,7 +80,7 @@ crontab $filename
|
||||
You can give it your usual `$PATH` variable like this:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo $PATH > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
@@ -99,13 +99,13 @@ You can simply do this:
|
||||
You can execute a script as root by putting it into a directory, instead of in the tab.
|
||||
Look at the available cron directories:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -d /etc/cron.*
|
||||
```
|
||||
|
||||
Make a script which runs daily:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
f=apt_update.sh
|
||||
echo '#!/bin/bash' > $f
|
||||
echo 'apt update --yes' >> $f
|
||||
@@ -117,7 +117,7 @@ sudo mv $f /etc/cron.daily/
|
||||
|
||||
Run-parts runs all executable scripts in a directory.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
run-parts /etc/cron.hourly
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "basics" ]
|
||||
|
||||
Compose a statement for execution.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
x='echo $y'
|
||||
echo $x
|
||||
y=dragon
|
||||
@@ -14,7 +14,7 @@ eval "$x"
|
||||
|
||||
The results remain in the current shell, unlike sub-shells.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
b=basilisk
|
||||
sh -c 'echo $b'
|
||||
eval "g=goblin"
|
||||
|
@@ -11,20 +11,20 @@ This ID is called the 'inode'.
|
||||
|
||||
Create a file, and a hard link:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fortune > $file_1
|
||||
mkdir -p x/y/z/
|
||||
ln $file_1 x/y/z/$file_2
|
||||
```
|
||||
Have a long look at the file with the `-l` flag, and check the inode with `-i`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -li $file_1 x/y/z/$file_2
|
||||
```
|
||||
|
||||
Since they are the same file, you can make a change to one, and it changes both:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fortune | tee x/y/z/$file_2
|
||||
cat $file_1
|
||||
cat x/y/z/$file_2
|
||||
|
@@ -7,7 +7,7 @@ If you want to kill a program in a graphical environment, open a terminal and ty
|
||||
|
||||
# Graphical Programs
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xkill
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@ Then click on the application which you want to kill.
|
||||
|
||||
To kill a program, find it with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pgrep discord
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ This will give you the UUID, e.g. `19643`.
|
||||
|
||||
Kill the program with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
kill 19643
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ kill 19643
|
||||
|
||||
To see an ordered list of termination signals:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
kill -l
|
||||
```
|
||||
|
||||
@@ -49,7 +49,7 @@ Higher numbers are roughly equivalent to insistence.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
kill -1 3498
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ This roughly means 'maybe stop the program, if you can, maybe reload'.
|
||||
|
||||
Or the famous:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
kill -9 3298
|
||||
```
|
||||
|
||||
|
@@ -8,25 +8,25 @@ A list of supported locales is available at /usr/share/i18n/SUPPORTED
|
||||
|
||||
See a full list with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /usr/share/i18n/SUPPORTED
|
||||
```
|
||||
|
||||
Take the first portion to generate full locale information for a region:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
locale-gen ru_RU.UTF-8
|
||||
```
|
||||
|
||||
Then use this for the current shell session with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
LANG=ru_RU.utf8
|
||||
```
|
||||
|
||||
Expand this to the entire system with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
export LANG=ru_RU.utf8
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ You can make this permanent for one user by adding this line to the ~/.profile o
|
||||
|
||||
Make it permanent for the entire system by editing:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo vim /etc/defaults/locale
|
||||
```
|
||||
|
||||
|
12
basics/ls.md
12
basics/ls.md
@@ -8,13 +8,13 @@ Firstly, your `ls` is probably aliased to something.
|
||||
Check it with:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
alias ls
|
||||
```
|
||||
If the prompt shows some alias, then start by removing it:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
unalias ls
|
||||
```
|
||||
|
||||
@@ -23,24 +23,24 @@ Now we can begin.
|
||||
Check the most recently modified file:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -t
|
||||
```
|
||||
|
||||
Reverse this with `tac` to see the file which has been unmodified the longest:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -t | tac
|
||||
```
|
||||
Group files by extension:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -X
|
||||
```
|
||||
Sort largest files first:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -X
|
||||
```
|
||||
|
||||
|
@@ -6,31 +6,31 @@ tags: [ "basics" ]
|
||||
|
||||
See running items in current terminal with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ps
|
||||
```
|
||||
|
||||
or more with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ps -a
|
||||
```
|
||||
|
||||
Or the entire system with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ps -e
|
||||
```
|
||||
|
||||
Or the entire system with more information, BSD style, with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ps aux
|
||||
```
|
||||
|
||||
And then search for a particular program with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ps aux | grep cmus
|
||||
```
|
||||
|
||||
@@ -40,19 +40,19 @@ Pause a job with ^z. Put it in the background with the '&' suffix.
|
||||
|
||||
List jobs in the current shell with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
jobs
|
||||
```
|
||||
|
||||
And then you can pull number 1 up again with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fg 1
|
||||
```
|
||||
|
||||
Or continue running a stopped job with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
bg 1
|
||||
```
|
||||
|
||||
@@ -62,31 +62,31 @@ This changes how nice a program is, from -20 to 19.
|
||||
|
||||
Install a program, but nicely, at nice value '10':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nice -10 sudo apt -y install libreoffice
|
||||
```
|
||||
|
||||
Aggressively use Steam, with a nice value of '-13'.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nice --13 steam&
|
||||
```
|
||||
|
||||
Find out that Steam's fucking everything up, so you change its nice value with 'renice':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
renice --5 -p 3781
|
||||
```
|
||||
|
||||
Nerf all of roach-1's processes:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
renice 10 -u roach-1
|
||||
```
|
||||
|
||||
... or the entire group
|
||||
|
||||
```bash
|
||||
```sh
|
||||
renice -14 -g hackers
|
||||
```
|
||||
|
||||
|
@@ -9,7 +9,7 @@ This & That
|
||||
|
||||
Refer to 'that last thing', and 'the first thing':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fortune -l > file1
|
||||
cat !$ | tr -d u
|
||||
diff !^ !$
|
||||
@@ -17,7 +17,7 @@ diff !^ !$
|
||||
|
||||
**NB:** this can go wrong:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -l file1 file2
|
||||
cat !^
|
||||
```
|
||||
@@ -36,7 +36,7 @@ Input Run-Commands (`~/.inputrc`)
|
||||
Alias Expansion
|
||||
---------------
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo '"\C- ": shell-expand-line' >> ~/.inputrc
|
||||
exec bash
|
||||
```
|
||||
@@ -47,7 +47,7 @@ Try just `ls`, then 'Control + Space'.
|
||||
Glob Expansion (`*`)
|
||||
--------------------
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo '"\C-x": glob-expand-word' >> ~/.inputrc
|
||||
exec bash
|
||||
ls *<C-x>
|
||||
@@ -63,13 +63,13 @@ Arbitrary Commands
|
||||
|
||||
Use `\n` as a 'newline' character to automatically press `<Return>`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
|
||||
exec bash
|
||||
ls<C-y>
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
Control-l: "\C-u clear -x && ls\n"
|
||||
exec bash
|
||||
cd /etc/<C-l>
|
||||
@@ -78,7 +78,7 @@ cd /etc/<C-l>
|
||||
Readline as Vi
|
||||
--------------
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'set editing-mode vi' >> ~/.inputrc
|
||||
echo 'set keymap vi-insert' >> ~/.inputrc
|
||||
exec bash
|
||||
@@ -115,7 +115,7 @@ Fix Globs!
|
||||
If you tried the previous commands then they will not work any more, because the `vi`-commands overwrite the other commands.
|
||||
Remove them.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sed '/ vi/d' ~/.inputrc
|
||||
sed -i '/ vi/d' ~/.inputrc
|
||||
|
||||
@@ -130,14 +130,14 @@ Vi-sibility
|
||||
The `readline` prompt becomes confusing if you don't remember if you're in insert or normal mode.
|
||||
But you can show the current mode in the prompt:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'set show-mode-in-prompt on' >> ~/.inputrc
|
||||
exec bash
|
||||
```
|
||||
|
||||
Set new symbols for normal and insert mode:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'set vi-ins-mode-string " "' >> ~/.inputrc
|
||||
echo 'set vi-cmd-mode-string " "' >> ~/.inputrc
|
||||
```
|
||||
@@ -148,33 +148,33 @@ Fuzzy Sort
|
||||
Check your repos for `sk-im`, and install.
|
||||
The program is called `sk`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
FUZZY=sk
|
||||
```
|
||||
|
||||
If you don't have it, `fzy` or `fzf` should work the same way.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
FUZZY=fzy
|
||||
```
|
||||
|
||||
Find some 'read-config' files to check out:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
find . -maxdepth 2 -name "*rc"
|
||||
find . -maxdepth 2 -name "*rc" | $FUZZY
|
||||
```
|
||||
|
||||
And read some:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
PAGER='less -R'
|
||||
$PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)"
|
||||
```
|
||||
|
||||
Make the change long-term:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"'
|
||||
alias | grep rrc= >> ~/.bash_aliases
|
||||
```
|
||||
|
@@ -7,7 +7,7 @@ When a program encounters a soft link, it will make a guess at whether it shoul
|
||||
|
||||
To make a soft link to a file in the current directory, linking is easy:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fortune > $file_1
|
||||
ln -s $file_1 $link_1
|
||||
```
|
||||
@@ -27,14 +27,14 @@ dir_0/
|
||||
|
||||
Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd dir_1
|
||||
ln -s ../file_1 link_1
|
||||
```
|
||||
|
||||
The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ln -s ../file_1 dir_2/link_2
|
||||
```
|
||||
|
||||
@@ -54,7 +54,7 @@ dir_0/
|
||||
|
||||
Since it's just an address, you can delete the original file, then make another.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rm file_1
|
||||
ls -l dir_1/
|
||||
fortune > file_1
|
||||
@@ -65,7 +65,7 @@ cat dir_1/link_1
|
||||
|
||||
Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ln -s -f ../dir_1/file_1 dir_2/link_2
|
||||
cat dir_2/link_2
|
||||
```
|
||||
|
@@ -6,7 +6,7 @@ tags: [ "basics", "time" ]
|
||||
|
||||
Set time to synchronize with an ntp server:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
timedatectl set-ntp true
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ Local time is kept in /etc/localtime.
|
||||
|
||||
According to Dave's LPIC guide, you can set the local time by making asymboling link from your timezone to /etc/localtime, as so:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```
|
||||
|
||||
@@ -28,31 +28,31 @@ sudo ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
|
||||
See local time, language and character settings with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
locale
|
||||
```
|
||||
|
||||
List available locales with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
locale -a
|
||||
```
|
||||
|
||||
To see additional locales which are available (but not necessarily installed):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /usr/share/i18n/SUPPORTED
|
||||
```
|
||||
|
||||
Set a supported locale with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
locale-gen pl_PL.UTF-8
|
||||
```
|
||||
|
||||
Then set that language, with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
LANG=pl_PL.UTF-8
|
||||
```
|
||||
|
||||
@@ -62,7 +62,7 @@ LANG=pl_PL.UTF-8
|
||||
|
||||
Glimpse an overview with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ntpq -p
|
||||
```
|
||||
|
||||
@@ -73,6 +73,6 @@ Usually this is run as a service, so just start that service.
|
||||
If your clock drifts too far from the right time, it will not reset happily.
|
||||
For it to reset like this:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo ntpd -q -g -x -n
|
||||
```
|
||||
|
@@ -28,7 +28,7 @@ Each description-line starts with a tab.
|
||||
|
||||
To represent a file structure as a nested series of markdown lists, you can try this horrifying `sed` one-liner:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
tree -tf --dirsfirst --gitignore --noreport --charset ascii | \
|
||||
sed -e 's/| \+/ /g' \
|
||||
-e 's/[|`]-\+/ */g' \
|
||||
|
@@ -6,23 +6,23 @@ tags: [ "basics" ]
|
||||
|
||||
Let's get some entries with 'getent', e.g. passwd or group.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
getent passwd
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
getent group
|
||||
```
|
||||
|
||||
Obviously:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
getent shadow
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo adduser maestro
|
||||
```
|
||||
|
||||
@@ -30,71 +30,71 @@ add user 'maestro'
|
||||
|
||||
This depends upon the settings in the /etc/default/useradd file and /etc/login.defs
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo useradd -m pinkie
|
||||
```
|
||||
|
||||
add user 'pinkie' with a home directory
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo adduser -m -e 2017-04-25 temp
|
||||
```
|
||||
|
||||
add expiry date to user
|
||||
|
||||
```bash
|
||||
```sh
|
||||
userdel maestro
|
||||
```
|
||||
|
||||
delete maestro
|
||||
|
||||
```bash
|
||||
```sh
|
||||
userdel -r maestro
|
||||
```
|
||||
|
||||
delete maestro and hir homefolder
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groups
|
||||
```
|
||||
|
||||
find which group you are in
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
id
|
||||
```
|
||||
|
||||
same
|
||||
|
||||
```bash
|
||||
```sh
|
||||
id -Gn maestro
|
||||
```
|
||||
|
||||
Find which groups maestro is in
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
deluser --remove-home maestro
|
||||
```
|
||||
|
||||
delete user maestro
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
usermod -aG sudo maestro
|
||||
```
|
||||
|
||||
Add user maestro to group sudo:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /etc/passwd
|
||||
```
|
||||
|
||||
list users' passwords (and therefore users)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groupadd awesome
|
||||
```
|
||||
|
||||
@@ -104,33 +104,33 @@ Passwords are stored in /etc/shadow.
|
||||
|
||||
There are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
passwd -l bin
|
||||
```
|
||||
|
||||
Lock the user 'bin'.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
more /etc/passwd | grep games
|
||||
```
|
||||
|
||||
we find the name, password and user id of the user 'games'. I.e. the password is 'x', and the user id is '5'. The password is an impossible hash, so no input password could match.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groupdel learners | delete the group 'learners'
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpasswd -d pi games | remove user 'pi' from the group 'games'
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
id games
|
||||
```
|
||||
|
||||
find the id number of group 'games' (60)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
usermod -aG sudo maestro
|
||||
```
|
||||
|
||||
@@ -156,7 +156,7 @@ Alternatively, change the shell in /etc/passwd.
|
||||
|
||||
Usermod also lets you change a user's username:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
usermod -l henry mark
|
||||
```
|
||||
|
||||
@@ -170,7 +170,7 @@ usermod -L henry
|
||||
|
||||
-G or -groups adds the user to other groups:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
usermod -G sudo henry
|
||||
```
|
||||
|
||||
@@ -186,13 +186,13 @@ In /etc/group, a group file may look like this:
|
||||
|
||||
We can use groupmod, like like usermod, e.g. to change a name:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groupmod -n frontoffice backoffice
|
||||
```
|
||||
|
||||
Delte a group:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
groupdel frontoffice
|
||||
```
|
||||
|
||||
@@ -200,37 +200,37 @@ groupdel frontoffice
|
||||
|
||||
See list of logged on users.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
w
|
||||
```
|
||||
|
||||
See last logons:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
last
|
||||
```
|
||||
|
||||
or all logon attempts, including bad attempts:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
lastb
|
||||
```
|
||||
|
||||
List recently accessed files:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
last -d
|
||||
```
|
||||
|
||||
See files opened by steve
|
||||
|
||||
```bash
|
||||
```sh
|
||||
lsof -t -u steve
|
||||
```
|
||||
|
||||
See files opened by anyone but steve
|
||||
|
||||
```bash
|
||||
```sh
|
||||
lsof -u ^steve
|
||||
```
|
||||
|
||||
@@ -240,19 +240,19 @@ Some files can be executed by people as if they had super user permissions, and
|
||||
|
||||
Let's start with files executable by user:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo find / -type f -perm -g=s -ls
|
||||
```
|
||||
|
||||
And then those executable by the group:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
find / -type f -perm -g=s -ls
|
||||
```
|
||||
|
||||
And finally, worrying files, executable by anyone as if sie were the owner:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
find / -xdev \( -o -nogroup \) -print
|
||||
```
|
||||
|
||||
@@ -260,7 +260,7 @@ Then have a look at resource usage per user.
|
||||
|
||||
# SGID
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo chmod u+s process.sh
|
||||
```
|
||||
|
||||
|
@@ -11,14 +11,14 @@ This is extremely powerful.
|
||||
|
||||
If you ever want to automatically install something which persistently nags you with `do you want to do the thing? [y/N]?`, then you can just pipe `yes` into that program, and it will answer 'yes' to all questions.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yes | $INSTALL_SCRIPT_FILE.sh
|
||||
```
|
||||
|
||||
This works best for disposable systems, like VMs or containers.
|
||||
Try this on a live system, and you might find out that you should have read that message fully.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yes | yay
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "data", "git" ]
|
||||
|
||||
Check out the sample hooks:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd $GIT_REPO
|
||||
ls .git/hooks
|
||||
head .git/hooks/pre-commit.sample
|
||||
@@ -13,7 +13,7 @@ head .git/hooks/pre-commit.sample
|
||||
|
||||
Add a hook to check the shell scripts in `$GIT_REPO` before making a commit:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo '#!/bin/sh
|
||||
shellcheck *.sh' > .git/hooks/commit-msg
|
||||
chmod u+x .git/hooks/commit-msg
|
||||
|
@@ -10,7 +10,7 @@ The first should be its own repository, but should also retain its own history.
|
||||
|
||||
First, we extract its history as an independent item, and make that into a seprate branch.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git subtree split --prefix=sub-1 -b sub
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/
|
||||
|
||||
Then go and create a new git somewhere else:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd ..;mkdir sub-1;cd sub-1;git init --bare
|
||||
```
|
||||
|
||||
@@ -28,7 +28,7 @@ git push ../subtest sub:master
|
||||
|
||||
Finally, you can clone this repo from your original.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git clone ../subtest
|
||||
```
|
||||
|
||||
|
@@ -6,7 +6,7 @@ tags: [ "data", "GPG" ]
|
||||
|
||||
Generate keys:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --full-generate-key
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@ Follow the guide.
|
||||
|
||||
# Encrypting a file
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg -r malinfreeborn@posteo.net -e file
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ Check you have an encrypted version of your file.
|
||||
# Changing Expiration Dates
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --list-keys
|
||||
# or...
|
||||
gpg -k
|
||||
@@ -37,13 +37,13 @@ gpg -k
|
||||
|
||||
Make a password with a password (cypher encryption).
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg -c --output passwords.txt
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg -c > passwords.txt
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ Write message then stop with Ctrl+d.
|
||||
|
||||
Get the message back out the file with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg -d passwords.txt
|
||||
```
|
||||
|
||||
@@ -61,13 +61,13 @@ gpg -d passwords.txt
|
||||
|
||||
Search for a key at any key store:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --search-keys nestorv
|
||||
```
|
||||
|
||||
Once you've made a decision about someone:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --list-keys
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ This is a fingerprint.
|
||||
|
||||
You can now decide the trust level (this stays on your computer).
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF
|
||||
```
|
||||
|
||||
Once you're in the interface, type `trust`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --sign-key alice@posteo.net
|
||||
```
|
||||
|
||||
@@ -104,7 +104,7 @@ This system relies on a ring of people swapping key information.
|
||||
|
||||
Send those trusted keys up to a server, so people can see you have verified them:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F
|
||||
```
|
||||
|
||||
@@ -125,7 +125,7 @@ keyserver hkps://keys.mailvelope.com
|
||||
|
||||
Refreshing keys will tell you if some key you have contains a signature from someone you already trust, or if someone has published a revocation certificate (meaning their key should not be trusted any more).
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --refresh-keys
|
||||
```
|
||||
|
||||
@@ -135,12 +135,12 @@ You can use the [crontab](../../basics/cron.md) to refresh keys, but this will m
|
||||
|
||||
Your public key:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --output me.gpg --armor --export
|
||||
```
|
||||
Alternatively:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gpg --export -a person@email.tld > my_key.pub
|
||||
```
|
||||
|
||||
|
@@ -4,11 +4,11 @@ tags: [ "RSS" ]
|
||||
---
|
||||
Create the configuration directory before you start, and add at least 1 URL.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir ~/.config/newsboat
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'https://voidlinux.org/atom.xml foss tech' >> ~/.config/newsboat/urls
|
||||
```
|
||||
|
||||
@@ -28,7 +28,7 @@ You can input a Youtube channel by adding this, with the channel's ID at the end
|
||||
|
||||
To get the channel ID without hunting:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
curl *'https://www.youtube.com/@1minfilms'* | grep -oE 'browseId":"U\w+"' | tail | cut -d'"' -f3
|
||||
```
|
||||
|
||||
|
@@ -13,11 +13,11 @@ Arch: tesseract-data-eng and poppler-utils
|
||||
|
||||
## Script
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pdftoppm -png *file*.pdf test
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
for x in *png; do
|
||||
tesseract -l eng "$x" - >> out.txt
|
||||
done
|
||||
|
@@ -23,6 +23,6 @@ Make a text file called 'pdfmark.txt'.
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt
|
||||
```
|
||||
|
@@ -16,7 +16,7 @@ The standard `radicale` package should come with a nice `systemd` service file.
|
||||
|
||||
If the service comes already-started, stop it immediately:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl stop radicale
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ You might get it in the `apache` package or similar.
|
||||
|
||||
`htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
PASS="$(xkcdpass)"
|
||||
htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users
|
||||
echo "Your username is $USER"
|
||||
@@ -93,7 +93,7 @@ sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/
|
||||
|
||||
Finally, replace the example `DOMAIN` with your actual domain name.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
DOMAIN=whatever.com
|
||||
sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
|
||||
```
|
||||
@@ -102,18 +102,18 @@ sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale
|
||||
|
||||
Check nginx is happy:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo nginx -t
|
||||
```
|
||||
You will almost certainly need a new SSL certificate for the site:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo certbod -d cal.$DOMAIN
|
||||
```
|
||||
|
||||
Start or restart both services:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl start radicale
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
|
@@ -7,7 +7,7 @@ tags: [ "data", "database", "recfiles" ]
|
||||
|
||||
Make a database for your boardgames, specifying only one field and value:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
database=games.rec
|
||||
n=Name
|
||||
g=Vojvodina
|
||||
@@ -18,21 +18,21 @@ recsel $database
|
||||
|
||||
Insert a few more, with the estimated playtime:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recins -f Name -v Saboter -f Playtime -v 30 $database
|
||||
recins -f Name -v Chess -f Playtime -v 30 $database
|
||||
```
|
||||
|
||||
View all games, or select one by number:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recsel $database
|
||||
recsel -n 0 $database
|
||||
```
|
||||
|
||||
Each game should note whether or not you have played it yet, so you can add that field and set the default to `yes`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
f=played
|
||||
v=yes
|
||||
recset -f $f -a $v $database
|
||||
@@ -40,7 +40,7 @@ recset -f $f -a $v $database
|
||||
|
||||
...but the field is wrong, it should have a capital letter:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
new_field=Played
|
||||
recset -f $f --rename $new_field
|
||||
```
|
||||
@@ -49,19 +49,19 @@ recset -f $f --rename $new_field
|
||||
|
||||
Check how many records the database has:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recinf $database
|
||||
```
|
||||
|
||||
Look at just the games you've never played:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recsel --expression="Played = 'no'" $database
|
||||
```
|
||||
|
||||
Print how many, then just print the names:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recsel -e "Played = 'no'" --count $database
|
||||
recsel -e "Played = 'no'" --print=Name $database
|
||||
```
|
||||
@@ -70,7 +70,7 @@ recsel -e "Played = 'no'" --print=Name $database
|
||||
|
||||
To change a game's `Played` field from `no` to `yes`, use `recset` to specify the number, and change that field.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
num=0
|
||||
f=Played
|
||||
value=yes
|
||||
@@ -80,14 +80,14 @@ recset --number=$num -f $f --set=$value $database
|
||||
|
||||
Find all games with a playtime of `30`, and set the field `Max_Players` to `4`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recset -e "Playtime = 40" -f Max_Players --set 50 games.rec
|
||||
```
|
||||
|
||||
This doesn't work, because that field does not exist.
|
||||
You can `--set-add` the field, to add it wherever it does not exist.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
recset -e "Playtime = 40" -f Max_Players --set-add 50 games.rec
|
||||
```
|
||||
|
||||
@@ -95,14 +95,14 @@ recset -e "Playtime = 40" -f Max_Players --set-add 50 games.rec
|
||||
|
||||
Remove `Played` record from first game:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
num=0
|
||||
recset --number=$num -f Played --delete $database
|
||||
```
|
||||
|
||||
You can comment the line instead of deleting it:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
num=1
|
||||
recset --number=$num -f Played --delete $database
|
||||
recsel $database
|
||||
@@ -111,7 +111,7 @@ cat $database
|
||||
|
||||
Delete an entire record:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
num=2
|
||||
recdel --number=$num $database
|
||||
```
|
||||
|
@@ -15,7 +15,7 @@ Change this with `:set autowrap`.
|
||||
|
||||
Make `sc-im` always autowrap:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir .config/sc-im/bash
|
||||
echo 'set autowrap' >> .config/sc-im/scimrc
|
||||
```
|
||||
|
@@ -33,7 +33,7 @@ By default, the `/mnt` directory is 'pruned' from the database.
|
||||
So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file.
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
su root
|
||||
cat /etc/updatedb.conf
|
||||
sed -i 's#/mnt/##' /etc/updatedb.conf
|
||||
|
@@ -7,7 +7,7 @@ You can share parts of a secret with multiple people, so only some of them need
|
||||
|
||||
Install `ssss`, then decide on the total number of secrets (`N`), and the threshold of people who must share their shard of the secret in order to reveal the secret.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
N=5
|
||||
T=3
|
||||
FILE=secret.txt
|
||||
@@ -17,7 +17,7 @@ Each shard is a line inside secret.txt.
|
||||
|
||||
Check it's working:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
head -n $T $FILE | ssss-combine -t $T
|
||||
tail -n $T $FILE | ssss-combine -t $T
|
||||
```
|
||||
|
@@ -30,7 +30,7 @@ http:
|
||||
|
||||
Restart the `soft-serve` service, then check it's working by cloning from localhost:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git clone http://localhost:23232/${some_repo}.git
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "data" ]
|
||||
|
||||
Work with a database:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sqlite3 "$FILE".sqlite3
|
||||
```
|
||||
Compress the database:
|
||||
|
@@ -16,7 +16,7 @@ All listed providers run proprietary software and actively support genocide.
|
||||
|
||||
To ignore the synchronization, tell the configuration file to use a local synchronization file.
|
||||
|
||||
```
|
||||
```sh
|
||||
task config sync.local.server_dir
|
||||
task config data.location ~/.local/state/
|
||||
```
|
||||
|
@@ -4,7 +4,7 @@ tags: [ "browsers" ]
|
||||
---
|
||||
Open a search tab:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
w3m ddg.gg
|
||||
```
|
||||
|
||||
|
@@ -7,7 +7,7 @@ tags: [ "distros", "arch" ]
|
||||
|
||||
Edit `/etc/systemd/system/getty@tty1.service.d/override.conf` by typing:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl edit getty@tty1
|
||||
```
|
||||
|
||||
|
@@ -5,17 +5,17 @@ requires: [ "partitions", "time" ]
|
||||
---
|
||||
Keyboard layout changed.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls /usr/share/kbd/keymaps/**/*.map.gz
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
loadkeys uk.map.gz
|
||||
```
|
||||
|
||||
Check if boot mode is UEFI
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls /sys/firmware/efi/efivars
|
||||
```
|
||||
|
||||
@@ -23,115 +23,115 @@ Without efivars, the system must boot with BIOS.
|
||||
|
||||
# Check network's up
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ping archlinux.org
|
||||
```
|
||||
|
||||
Set system clock properly
|
||||
|
||||
```bash
|
||||
```sh
|
||||
timedatectl set-ntp true
|
||||
```
|
||||
|
||||
Check disks
|
||||
|
||||
```bash
|
||||
```sh
|
||||
lsblk
|
||||
```
|
||||
|
||||
Make partition
|
||||
|
||||
```bash
|
||||
```sh
|
||||
parted -s /dev/sda mklabel gpt
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
parted -s /dev/sda mklabel msdos
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
parted -s /dev/sda mkpart primary ext4 512 100%
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
parted -s /dev/sda set 1 boot on
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkfs.ext4 /dev/sda1
|
||||
```
|
||||
|
||||
Use pacstrap to get the base install.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mount /dev/sda1 /mnt/
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pacstrap /mnt base base-devel vim linux linux-firmware
|
||||
```
|
||||
|
||||
Make fstab notes for new system.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
arch-chroot /mnt
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo 'en_GB.UTF-8' > /etc/default/locale
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pacman -Sy networkmanager grub
|
||||
```
|
||||
|
||||
For legacy:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
grub-install --target=i386-pc /dev/sda
|
||||
```
|
||||
|
||||
For EFI:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S efibootmgr
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir /boot/efi
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --remmovable
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
```
|
||||
|
||||
set local time
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
|
||||
```
|
||||
|
||||
Find the desired locale's and uncomment them.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vi /etc/locale.gen
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
locale-gen
|
||||
```
|
||||
|
||||
Make your keyboard changes permenent with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vi /etc/vconsole.conf
|
||||
```
|
||||
|
||||
@@ -140,13 +140,13 @@ unsure about this bit - is this name just for the loadkeys function?
|
||||
|
||||
Make a hostname
|
||||
|
||||
```bash
|
||||
```sh
|
||||
echo pc > /etc/hostname
|
||||
```
|
||||
|
||||
Set hostnames for network, or at least your own.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vi /etc/hosts
|
||||
```
|
||||
|
||||
@@ -160,27 +160,27 @@ If the system has a permanent IP address, it should be used instead of localhost
|
||||
|
||||
Ping some sites to make sure the network's working
|
||||
|
||||
```bash
|
||||
```sh
|
||||
passwd
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
exit
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
umount -R /mnt
|
||||
```
|
||||
|
||||
Remove that awful beep sound:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rmmod pcspkr
|
||||
```
|
||||
|
||||
...and make the change permanent:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo echo "blacklist pcspkr" >> /etc/modprobe.d/nobeep.conf
|
||||
```
|
||||
|
||||
|
@@ -13,7 +13,7 @@ Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
And update:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -Syu
|
||||
```
|
||||
|
||||
@@ -21,7 +21,7 @@ sudo pacman -Syu
|
||||
|
||||
Check your graphics card type:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
lspci | grep VGA
|
||||
```
|
||||
|
||||
@@ -31,7 +31,7 @@ lspci | grep VGA
|
||||
|
||||
If you see `Nvidia`, then install the intel drivers:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader
|
||||
```
|
||||
|
||||
@@ -39,7 +39,7 @@ sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-lo
|
||||
|
||||
If you see `Intel`, then install the intel drivers:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-intel
|
||||
```
|
||||
|
||||
@@ -47,16 +47,16 @@ sudo pacman -S --needed lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-lo
|
||||
|
||||
If you see `AMD`, then check your card support `vulkan`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yay -S gpu-viewer
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vulkaninfo | grep 'VkPhysicalDeviceVulkanMemoryModelFeatures' -A 3
|
||||
```
|
||||
|
||||
You should see 'true' here.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S --needed lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu
|
||||
```
|
||||
|
@@ -7,14 +7,14 @@ tags: [ "arch" ]
|
||||
|
||||
Clean the cache of old packages in `/var/cachepacman/pkg/`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls /var/cache/pacman/pkg/ | wc -l
|
||||
sudo pacman -Sc
|
||||
ls /var/cache/pacman/pkg/ | wc -l
|
||||
```
|
||||
And the same for `yay` (with `-Yc` to remove old dependencies):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls ~/.cache/yay/ | wc -l
|
||||
yay -Sc
|
||||
yay -Yc
|
||||
@@ -27,7 +27,7 @@ If you chance a configuration file, such as `/etc/environment`, and `pacman` wan
|
||||
|
||||
Check the new files, then look at the difference between the `pacman` version, and your version.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo find /etc/ /var/ /usr/ -name "*.pacnew"
|
||||
diff /etc/pacman.d/mirrorlist*
|
||||
```
|
||||
@@ -36,7 +36,7 @@ Either,
|
||||
|
||||
- Update the files manually,
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo -e /etc/pacman.d/mirrorlist
|
||||
sudo rm /etc/pacman.d/mirrorlist.pacnew
|
||||
```
|
||||
@@ -46,7 +46,7 @@ Or,
|
||||
- use a tool like `pacdiff` to view the changes next to each other, and select them with `vim`.
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S pacman-contrib
|
||||
sudo pacdiff
|
||||
```
|
||||
|
@@ -7,13 +7,13 @@ Packages are kept in /var/cache/pacman/pkg.
|
||||
|
||||
Delete unused old packages with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -Sc
|
||||
```
|
||||
|
||||
Signatures are handled by the pacman-key, initially set up with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman-key --populate archlinux
|
||||
```
|
||||
|
||||
@@ -23,31 +23,31 @@ sudo pacman-key --refresh-keys
|
||||
|
||||
If you have usigned keys, you can refresh with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -Sc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -Scc
|
||||
```
|
||||
|
||||
Reset all keys with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo rm -r /etc/pacmand.d/gnupg/ && sudo pacman-key --init
|
||||
```
|
||||
|
||||
If you're constantly getting 'everything corrupted, nothing upgraded', try running:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -S archlinux-keyring
|
||||
```
|
||||
|
||||
List all orphaned packages:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo pacman -Qtdq
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "void" ]
|
||||
|
||||
Make the autologin service:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1
|
||||
```
|
||||
|
||||
|
@@ -7,24 +7,24 @@ To automatically stick the logo onto your background, do these commands in the d
|
||||
|
||||
Get the void linux logo from wikipedia
|
||||
|
||||
```bash
|
||||
```sh
|
||||
wget https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Void_Linux_logo.svg/256px-Void_Linux_logo.svg.png?20170131170632
|
||||
```
|
||||
|
||||
Rename it, and resize it (the standard size is too small for most wallpapers)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
convert -resize 200% '256px-Void_Linux_logo.svg.png?20170131170632' void-logo.png
|
||||
```
|
||||
Download a pretty wallpaper
|
||||
|
||||
```bash
|
||||
```sh
|
||||
wget http://wallpapercave.com/wp/Wlm9Gv0.jpg
|
||||
```
|
||||
|
||||
Put the void logo on all *jpg and *png images
|
||||
|
||||
```bash
|
||||
```sh
|
||||
for x in *.jpg
|
||||
do
|
||||
composite -compose multiply -gravity Center void-logo.png "$x" "$x"
|
||||
|
@@ -6,13 +6,13 @@ tags: [ "void" ]
|
||||
|
||||
All possible services are in:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls /etc/sv
|
||||
```
|
||||
|
||||
The computer only uses those in /var/service, so symbolic links are made to start and stop services.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls /var/service
|
||||
```
|
||||
|
||||
@@ -20,13 +20,13 @@ ls /var/service
|
||||
|
||||
Enable the sshd service, so that ssh will work every time you boot up:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo ln -s /etc/sv/sshd /var/service
|
||||
```
|
||||
|
||||
Then start the service:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo sv start sshd
|
||||
```
|
||||
|
||||
@@ -34,19 +34,19 @@ sudo sv start sshd
|
||||
|
||||
Stop `mpd` with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo sv stop mpd
|
||||
```
|
||||
|
||||
And stop it automatically loading at startup with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo rm /var/service/mpd
|
||||
```
|
||||
|
||||
You can also just make a file called 'down':
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo touch /var/service/mpd/down
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ If unsure, use `#!/bin/bash` as the first line. When Void Linux says `sh`, it m
|
||||
|
||||
Confirm the shell you'll use:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -l $(which sh)
|
||||
```
|
||||
|
||||
|
@@ -6,7 +6,7 @@ tags: [ "void" ]
|
||||
|
||||
Update all packages with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo xbps-install -Su
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@ See [xbps](xbps.md) for more.
|
||||
Void keeps *every* version of everything you install, so you can roll back to them.
|
||||
Remove old packages with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo xbps-remove -O
|
||||
```
|
||||
|
||||
@@ -25,19 +25,19 @@ sudo xbps-remove -O
|
||||
|
||||
Old Void kernels are left on the boot partition. List them with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vkpurge list
|
||||
```
|
||||
|
||||
Remove one with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vkpurge 2.8.2_4
|
||||
```
|
||||
|
||||
Remove all but the latest with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vkpurge rm all
|
||||
```
|
||||
|
||||
@@ -48,7 +48,7 @@ You can change this number to change the screen brightness.
|
||||
|
||||
For an easy utility, install `brightnessctl`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
brightnessctl s 10%-
|
||||
brightnessctl s 10%+
|
||||
```
|
||||
|
@@ -6,50 +6,50 @@ tags: [ "void" ]
|
||||
|
||||
Look for cowsay in the repository:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query --repository --search cowsay
|
||||
```
|
||||
|
||||
Short version:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -Rs cowsay
|
||||
```
|
||||
|
||||
Search with regex:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query --regex -Rs 'cow(s)?\w'
|
||||
```
|
||||
|
||||
List what's required for cowsay
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -x cowsay
|
||||
```
|
||||
|
||||
What packages are orphaned (i.e. installed as a dependency for another package, which has since been removed)?
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -O
|
||||
```
|
||||
|
||||
Show cowsay's dependencies.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -x cowsay
|
||||
```
|
||||
|
||||
This shows `perl`.
|
||||
To see what else depends on perl:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -X perl
|
||||
```
|
||||
|
||||
List all manually installed software.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-query -m
|
||||
```
|
||||
|
||||
@@ -57,14 +57,14 @@ xbps-query -m
|
||||
|
||||
Install cowsay
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-install cowsay
|
||||
```
|
||||
|
||||
Upgrade current packages.
|
||||
`-R` looks at repositories, `-s` makes a sloppy search (for rough matches).
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-install -Suv
|
||||
```
|
||||
|
||||
@@ -72,19 +72,19 @@ xbps-install -Suv
|
||||
|
||||
Remove cowsay
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-remove cowsay
|
||||
```
|
||||
|
||||
...and all dependencies
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-remove -R cowsay
|
||||
```
|
||||
|
||||
Remove all orphaned dependencies.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-remove -o
|
||||
```
|
||||
|
||||
@@ -94,19 +94,19 @@ Show information about cowsay
|
||||
|
||||
Reinstall cowsay
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xbps-install -f cowsay
|
||||
```
|
||||
|
||||
Look for broken packages.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo xbps-pkgdb -a
|
||||
```
|
||||
|
||||
And if you've found any, you might reconfigure all packages forcefully:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo xbps-reconfigure -af
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ requires: [ "ssh" ]
|
||||
---
|
||||
# SSH Daemon Jail
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.d/ssh.local
|
||||
```
|
||||
|
||||
@@ -17,15 +17,15 @@ ignoreip = 127.0.0.1/8 ::1,192.168.0.0/16 ::1
|
||||
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl restart fail2ban
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo fail2ban-client status
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo fail2ban-client status sshd
|
||||
```
|
||||
|
||||
|
@@ -18,7 +18,7 @@ Set up a file like this, called `troubleshooting.txt`.
|
||||
|
||||
Then translate it with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
graph-easy troubleshooting.txt --as boxart
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ This is a basic Linux firewall program.
|
||||
|
||||
Look at your firewalls:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -L
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ We see the output of input, output and forwarding rules.
|
||||
|
||||
I don't need any forwarding, so I'm going to drop all forwarding:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -P FORWARD DROP
|
||||
```
|
||||
|
||||
@@ -26,17 +26,17 @@ iptables -P FORWARD DROP
|
||||
|
||||
Let's 'A'dd, or 'A'ppend a rule with -A. Let's drop all input from a nearby IP
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -A INPUT -s 192.168.0.23 -j DROP
|
||||
```
|
||||
|
||||
Or we can block all input from a particular port on the full Network.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -A INPUT -s 192.168.0.0/24 -p tcp --destination-port 25 -j DROP
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -A INPUT --dport 80 -j ACCEPT
|
||||
```
|
||||
|
||||
@@ -47,13 +47,13 @@ However, rules are accepted in order - so a packet cannot be rejected and then a
|
||||
|
||||
To delete rule 2 from the INPUT chain:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -D INPUT 3
|
||||
```
|
||||
|
||||
Alternatively, you can 'I'nsert a rule at the start, rather than 'A'ppending it.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -I INPUT -s 192.168.0.13 DROP
|
||||
```
|
||||
|
||||
@@ -67,7 +67,7 @@ The -j flag accepts ACCEPT/REJECT/DROP. The last two are identical except that
|
||||
|
||||
Flush all existing rules with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iptables -F
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "networking" ]
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmap 192.168.1.1/24
|
||||
```
|
||||
|
||||
@@ -17,6 +17,6 @@ Flags:
|
||||
|
||||
Look for a web server, which has ports 80 and 443 open:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmap 192.168.1.1/24 -p 80,443 --open
|
||||
```
|
||||
|
@@ -6,19 +6,19 @@ tags: [ "distros" ]
|
||||
|
||||
## Arch
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yay -S pi-hole-server
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl enable --now pihole-FTL
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl disable --now systemd-resolved
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo rm -f /dev/shm/FTL-\*
|
||||
```
|
||||
|
||||
@@ -26,32 +26,32 @@ sudo rm -f /dev/shm/FTL-\*
|
||||
|
||||
Debian has a long, boring setup.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt-get install wget curl net-tools gamin lighttpd lighttpd-mod-deflate
|
||||
curl -sSL https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true sudo -E bash
|
||||
```
|
||||
|
||||
# Setup
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo usermod -aG pihole $USER
|
||||
```
|
||||
|
||||
Remove that google dns server.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pihole -a setdns 9.9.9.9 1.0.0.1
|
||||
```
|
||||
|
||||
Disable pihole password by setting a blank password.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pihole -a -p
|
||||
```
|
||||
|
||||
Get a new list of blocked domains, then reload:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pihole -g -r
|
||||
```
|
||||
|
||||
@@ -61,13 +61,13 @@ Every so often, run `pihole -g` again (perhaps put it in crontab).
|
||||
|
||||
Observe the pihole's output while you ask it a question:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pihole -t
|
||||
```
|
||||
|
||||
Then ask the question from another computer:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
dig @[ pihole ip ] archlinux.org
|
||||
```
|
||||
|
||||
|
@@ -9,71 +9,71 @@ We'll assume a folder in Google Drive called 'test', and local folder called 'fo
|
||||
|
||||
Generate a config file with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone config
|
||||
```
|
||||
|
||||
Look at the contents of Google Drive:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone ls gd:/
|
||||
```
|
||||
|
||||
If rclone loses authorization:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone authorization
|
||||
```
|
||||
|
||||
List only directories:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone lsf -dirs-only google:/
|
||||
```
|
||||
|
||||
Mount the remote location on /tmp/google with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone mount google /tmp/google
|
||||
```
|
||||
|
||||
Copy the contents of 'foo' to 'test'.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone copy foo/ google:test
|
||||
```
|
||||
|
||||
Sync contents of foo and test with a progress bar (will delete Google items):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone sync foo google:test -P
|
||||
```
|
||||
|
||||
Remove all duplicates
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone dedupe google:test
|
||||
```
|
||||
|
||||
Delete contets of a remote file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone delete n:test
|
||||
```
|
||||
|
||||
Or delete the folder and contents as well:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone purge n:test
|
||||
```
|
||||
|
||||
Copy to and from with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone copyto google:test foo
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rclone copyto foo google:test
|
||||
|
@@ -3,7 +3,7 @@ title: "Download Website"
|
||||
tags: [ "networking", "scraping" ]
|
||||
---
|
||||
|
||||
```bash
|
||||
```sh
|
||||
domain=splint.rs
|
||||
mkdir $domain
|
||||
cd $domain
|
||||
|
@@ -4,25 +4,25 @@ tags: [ "scraping" ]
|
||||
---
|
||||
Install `yt-dlp`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yt-dlp --write-auto-sub *<URL>*
|
||||
```
|
||||
|
||||
It will default to English, but you can specify another language with the flag --sub-lang:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
youtube-dl --sub-lang sv --write-auto-sub *<URL>*
|
||||
```
|
||||
|
||||
You can list all available subtitles with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
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:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yt-dlp --sub-lang sv --write-auto-sub --skip-download *<URL>*
|
||||
```
|
||||
|
||||
|
@@ -15,12 +15,12 @@ tags: [ "networking", "host" ]
|
||||
|
||||
Query a host with the `host` command.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
host $domain.$tld
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
host $domain.$tld 9.9.9.9
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ You can also add a specific nameserver:
|
||||
|
||||
Request a specific record type (`CNAME`, `TXT`, et c.):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
torsocks host -T -t $RECORD_TYPE $domain
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ requires: [ "ssh" ]
|
||||
---
|
||||
# Mount
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sshfs $USER@$IP_ADDRESS:$DIR
|
||||
```
|
||||
|
||||
@@ -16,7 +16,7 @@ Various flags:
|
||||
|
||||
# Unmount
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fusermount3 -u $DIR
|
||||
```
|
||||
|
||||
|
@@ -6,25 +6,25 @@ requires: [ "ssh" ]
|
||||
|
||||
Mount a remote filesystem locally with fuse-sshfs:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sshfs *user*@192.168.0.10:/home/*user* /tmp/mnt
|
||||
```
|
||||
|
||||
Unmount with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fusermount -u /tmp/mnt
|
||||
```
|
||||
|
||||
Set it up on /etc/fstab with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
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.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
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
|
||||
```
|
||||
|
||||
|
@@ -5,7 +5,7 @@ tags: [ "networking" ]
|
||||
|
||||
# Get a Hostname
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo vim /etc/tor/torrc
|
||||
```
|
||||
|
||||
|
@@ -22,29 +22,29 @@ Install it then start the service.
|
||||
|
||||
Arch Linux:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl start transmission
|
||||
```
|
||||
|
||||
Debian:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl start transmission-daemon
|
||||
```
|
||||
|
||||
Add a torrent by the .torrent file, or a magnet link, like this:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
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
|
||||
```sh
|
||||
transmission-remote -a sita.torrent
|
||||
```
|
||||
|
||||
Now let's check that the torrent's been added successfully.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -l
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ 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.
|
||||
E.g.:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo usermod -aG transmission $USER
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ 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:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -t 4 -r
|
||||
```
|
||||
|
||||
@@ -71,7 +71,7 @@ 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`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -t 4 -rad
|
||||
```
|
||||
|
||||
@@ -82,7 +82,7 @@ If the file is in your home - `~` - but `transmission` is not allowed in your ho
|
||||
|
||||
Next, find the torrent's number. You can use multiple numbers, separated with a comma:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -t 3,5,8 --move $HOME/music
|
||||
```
|
||||
|
||||
@@ -90,7 +90,7 @@ transmission-remote -t 3,5,8 --move $HOME/music
|
||||
|
||||
The `transmission` user has a home configuration file, like any other user, with all the transmission settings.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cd /var/lib/transmission/.config/transmission-daemon/
|
||||
|
||||
$EDITOR settings.json
|
||||
@@ -105,14 +105,14 @@ When it doubt, just place the files in `transmission`'s home directory.
|
||||
|
||||
Create a torrent of file or directory `Memes` with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo chown -R :transmission Memes
|
||||
transmission-create $(pwd)/Memes
|
||||
```
|
||||
|
||||
Add a tracker to the torrent, to make sure others can find you easily:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-create --comment 'My Memes collection' -t 'udp://tracker.publicbt.com:80' -t 'udp://tracker.openbittorrent.com:80' --anonymize Memes
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ Without the `--anonymize` flag, the torrent file output will have a 'created by'
|
||||
|
||||
Add your torrent and notes its number:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -a "$file".torrent
|
||||
transmission-remote -l
|
||||
transmission-remote -t "$number" -i
|
||||
@@ -149,19 +149,19 @@ transmission-remote -t "$number" -i
|
||||
|
||||
The information in the last command shows that it's not verified, so you can verify with `-v`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -t "$number" -v
|
||||
```
|
||||
|
||||
If transmission cannot find it, then tell it where to find the torrent:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
transmission-remote -t "$number" --find "$(pwd)"
|
||||
```
|
||||
...and of course, make sure the permissions allow transmission to see the target.
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ls -ld "$file"
|
||||
```
|
||||
|
||||
|
@@ -7,19 +7,19 @@ tags: [ "networking" ]
|
||||
|
||||
If not, try checking out what your local networking interfaces are, then check if they have been picked up:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
dmesg | grep eth0
|
||||
```
|
||||
|
||||
# Display Active Ports
|
||||
|
||||
```bash
|
||||
```sh
|
||||
netstat -l
|
||||
```
|
||||
|
||||
...or maybe narrow it down to http:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
netstat -l | grep http
|
||||
```
|
||||
|
||||
|
@@ -4,35 +4,35 @@ tags: [ "networking", "web" ]
|
||||
---
|
||||
Install nginx:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt-get install nginx
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo apt-get enable --now nginx
|
||||
```
|
||||
|
||||
Put a website somewhere:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir /var/www/html/mysite/
|
||||
```
|
||||
|
||||
Put an index file there:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vim /var/www/html/mysite/index.html
|
||||
```
|
||||
|
||||
Make the owner `www-data`
|
||||
|
||||
```bash
|
||||
```sh
|
||||
chown -R www-data:www-data /var/www/html/mysite/
|
||||
```
|
||||
|
||||
Make a configuration file for nginx:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
vim /etc/nginx/sites-available/mysite.conf
|
||||
```
|
||||
|
||||
@@ -54,13 +54,13 @@ server {
|
||||
|
||||
Make the site available:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/
|
||||
```
|
||||
|
||||
Test it's working:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nginx -t
|
||||
```
|
||||
|
||||
@@ -82,17 +82,17 @@ Buy some DNS online, then check it's working.
|
||||
|
||||
*Once it's working*, use certbot:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
apt install certbot
|
||||
```
|
||||
|
||||
You may need to install an nginx python module:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
apt install python3-certbot-nginx
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
domain=example.com
|
||||
my_email=me@posteo.uk
|
||||
certbot --nginx -d "$domain" --non-interactive --agree-tos -m "$my_email"
|
||||
|
@@ -7,27 +7,27 @@ tags: [ "networking" ]
|
||||
|
||||
Stats on local net usage within domain.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
iftop -p -n
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
whois domain.com
|
||||
```
|
||||
|
||||
Info on domain, whether it's taken, et c.:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
dig domain.com
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ifconfig
|
||||
```
|
||||
|
||||
Versatile wifi tool:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli
|
||||
```
|
||||
|
||||
@@ -35,7 +35,7 @@ nmcli
|
||||
|
||||
You want to connect to the internet.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo iwconfig
|
||||
```
|
||||
|
||||
@@ -61,7 +61,7 @@ Get knowledge of wireless state. The output might be:
|
||||
|
||||
This tells you that your ESSID is 'Gandalf WajFaj', and the access point name is 10:05:......
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli radio
|
||||
```
|
||||
|
||||
@@ -69,23 +69,23 @@ You get an overview of your radio devices.
|
||||
You're told that eth0 deals with your ethernet and `wlan0` deals with wifi.
|
||||
`wlan0` is a file which represents your wifi device.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli wlan0 wifi rescan
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli device wifi list
|
||||
```
|
||||
|
||||
Now to connect.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli device wifi connect [SSID] [your password] [wifi password]
|
||||
```
|
||||
|
||||
Alternatively, you can use
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli -ask device wifi connect [SSID]
|
||||
```
|
||||
|
||||
|
@@ -9,13 +9,13 @@ Check with `which pulseaudio`. No output means you need to use alsa (below).
|
||||
|
||||
# Volume Control
|
||||
|
||||
```bash
|
||||
```sh
|
||||
pactl set sink @DEFAULT_SINK@ +5%
|
||||
```
|
||||
|
||||
Find working outputs:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
aplay -l
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ amixer scontrols
|
||||
|
||||
# Change a Sound setting
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer set Master 5%-
|
||||
```
|
||||
|
||||
@@ -42,19 +42,19 @@ pulseaudio -k && sudo alsa force-reload
|
||||
|
||||
Toggle, mute, increase or decrase audio:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer sset Master toggle
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer sset Master mute
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer sset Master 5%+
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer sset Master 5%-
|
||||
```
|
||||
|
||||
@@ -62,14 +62,14 @@ amixer sset Master 5%-
|
||||
|
||||
Start with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
alsamixer
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
amixer -c PinePhone set 'Headphone' 50%
|
||||
```
|
||||
|
||||
|
@@ -40,13 +40,13 @@ 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.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo usermod -aG pulse-access mpd
|
||||
```
|
||||
|
||||
Working with mpd will be easier if you have access to its files, so maybe:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo usermod -aG mpd $USER
|
||||
```
|
||||
|
||||
@@ -56,7 +56,7 @@ sudo usermod -aG mpd $USER
|
||||
|
||||
Install `mpd-notification` and then start the service:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
systemctl --user enable mpd-notification
|
||||
```
|
||||
|
||||
|
@@ -17,7 +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:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo adduser mpd pulse
|
||||
```
|
||||
|
||||
|
@@ -8,31 +8,31 @@ tags: [ "system", "phone" ]
|
||||
|
||||
Install:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
yay -S simple-mtpfs
|
||||
```
|
||||
|
||||
List available phones:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
simple-mtpfs -l
|
||||
```
|
||||
|
||||
Make a mount point:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir phone
|
||||
```
|
||||
|
||||
Check your phone, and tell it to allow access to the USB.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
simple-mtpfs --device 1 phone
|
||||
```
|
||||
|
||||
## Stop
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fusermount -u phone
|
||||
rmdir phone
|
||||
```
|
||||
|
90
system/ansible/ansible_basics.md
Normal file
90
system/ansible/ansible_basics.md
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: "Ansible Basics"
|
||||
tags: [ "system", "ansible", "orchestration" ]
|
||||
requires: [ "ssh" ]
|
||||
---
|
||||
|
||||
# Start Locally
|
||||
|
||||
Start by doing normal actions on the computer.
|
||||
|
||||
Say 'hello' to yourself:
|
||||
|
||||
```sh
|
||||
ansible --module-name=ping localhost
|
||||
```
|
||||
|
||||
Upgrade through the package manager.
|
||||
|
||||
`packager=apt` (or `pacman` or `xbps`,...)
|
||||
|
||||
```sh
|
||||
packager=apt
|
||||
ansible --module-name=${packager} --args "upgrade=yes" localhost
|
||||
```
|
||||
|
||||
This fails because you have not 'become root'.
|
||||
So, '*become*'!
|
||||
|
||||
```sh
|
||||
ansible --become -m ${packager} -a "upgrade=true" localhost
|
||||
```
|
||||
|
||||
# Passwords
|
||||
|
||||
Typing the password is dull.
|
||||
You might shift it to the command line:
|
||||
|
||||
ansible-playbook t.yaml -i hosts.yaml -e "ansible_become_password=${password}"
|
||||
|
||||
...this is also dull.
|
||||
|
||||
|
||||
If you have a password store, like `pass`, you can put that in a script:
|
||||
|
||||
|
||||
```sh
|
||||
echo "#!/bin/sh
|
||||
pass $HOSTNAME" > pass.sh
|
||||
|
||||
chmod u+x !$
|
||||
|
||||
ansible --become --module-name=pacman --args "upgrade=true" localhost
|
||||
```
|
||||
|
||||
# Other Hosts
|
||||
|
||||
Find something you can `ssh` into.
|
||||
Ansible will use your `/etc/hosts` file, and `~/.ssh/config`.
|
||||
|
||||
## Make a Hosts File
|
||||
|
||||
You can use the `.ini` format:
|
||||
|
||||
```sh
|
||||
echo '[phones]
|
||||
192.168.0.20' > hosts
|
||||
```
|
||||
But everything uses `yaml` nowadays, so may as well be consistent:
|
||||
|
||||
```yaml
|
||||
all:
|
||||
children:
|
||||
phones:
|
||||
children:
|
||||
pine:
|
||||
ansible_host: 192.168.0.20
|
||||
|
||||
```
|
||||
|
||||
Check the inventory in yaml format:
|
||||
|
||||
```sh
|
||||
ansible-inventory --list -y -i
|
||||
```
|
||||
|
||||
```sh
|
||||
ansible-vault view sec.yml --vault-pass-file pass.sh
|
||||
```
|
||||
|
||||
community.general.say voice=en_GB msg="Testing 123"
|
@@ -8,25 +8,25 @@ See a file's contents:
|
||||
|
||||
Return full contents of a string:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '{ print }' file
|
||||
```
|
||||
|
||||
Print the first and second column:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '{print$1$2}'
|
||||
```
|
||||
|
||||
Return every line with the word 'the' (like grep):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '/the/{print}' file
|
||||
```
|
||||
|
||||
Print everything containing a lowercase letter:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '/[a-z]/{print}' file
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ Same with numbers [0-9], or using a caret we can show lines starting with a numb
|
||||
|
||||
# Conditionals
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '{ if($1 ~ /123/) print }' file
|
||||
```
|
||||
|
||||
@@ -42,19 +42,19 @@ Check if the first column is equal to 1 or 2 or 3, and if so then print that lin
|
||||
|
||||
Grep for 'hawk' in a story:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '/hawk/' story.txt
|
||||
```
|
||||
|
||||
Return any line with one or more "&" sequences:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '/&+/' script.sh
|
||||
```
|
||||
|
||||
The pipe is used for 'or', so 'Orcs or drums' would be:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
awk '/Orcs|Drums/' story.txt
|
||||
```
|
||||
|
||||
|
@@ -47,7 +47,7 @@ The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore
|
||||
To fix this, use `xargs` to turn the stdin into an argument.
|
||||
For example, if we have a list of files called `list.txt' then we could use cat as so:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat list.txt | xargs rm
|
||||
```
|
||||
|
||||
@@ -81,13 +81,13 @@ x=$(( x*x ))
|
||||
|
||||
## Finding Duplicate Files
|
||||
|
||||
```bash
|
||||
```sh
|
||||
find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
|
||||
```
|
||||
|
||||
## Output random characters
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
||||
```
|
||||
|
||||
@@ -95,13 +95,13 @@ cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
||||
|
||||
Try something out in a random directory in `/tmp` so the files will be deleted when you next shut down.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mktemp -d
|
||||
```
|
||||
|
||||
That gives you a random directory to mess about in.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
dir=$(mktemp -d)
|
||||
for x in {A..Z}; do
|
||||
fortune > "$dir"/chimpan-$x
|
||||
|
@@ -1 +0,0 @@
|
||||
../basics/cron.md
|
129
system/cron.md
Normal file
129
system/cron.md
Normal file
@@ -0,0 +1,129 @@
|
||||
---
|
||||
title: "cron"
|
||||
tags: [ "basics", "time" ]
|
||||
---
|
||||
# Cronie
|
||||
|
||||
The `cronie` program is also known as `crond`.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
sudo apt search -n ^cron
|
||||
```
|
||||
|
||||
Once installed, search for the service name, and start it.
|
||||
|
||||
```sh
|
||||
sudo systemctl list-unit-files | grep cron
|
||||
sudo systemctl enable --now $NAME
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Show your current crontab:
|
||||
|
||||
```sh
|
||||
crontab -l
|
||||
```
|
||||
|
||||
You can put this in a file and edit it:
|
||||
|
||||
```sh
|
||||
crontab -l > $filename
|
||||
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
|
||||
```
|
||||
|
||||
Then apply that crontab:
|
||||
|
||||
```sh
|
||||
crontab $filename
|
||||
rm $filename
|
||||
```
|
||||
|
||||
The `cron` program will check your syntax before adding the tab.
|
||||
|
||||
Your crontab file sits somewhere in `/var/spool/`.
|
||||
Probably in `/var/spool/cron`.
|
||||
|
||||
## Syntax
|
||||
|
||||
`* * * * *`
|
||||
|
||||
These five points refer to:
|
||||
|
||||
`minute hour day month weekday`
|
||||
|
||||
So '3pm every Sunday' would be:
|
||||
|
||||
`0 15 * * 7`
|
||||
|
||||
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
|
||||
The minute is '0' (i.e. '0 minutes past three pm').
|
||||
|
||||
Doing the same thing, but only in February, would be:
|
||||
|
||||
`0 15 * 2 7`
|
||||
|
||||
### Variables
|
||||
|
||||
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
|
||||
|
||||
|
||||
```sh
|
||||
echo "HOME=$HOME" > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
```
|
||||
|
||||
`cronie` doesn't know where anything lives, including programs.
|
||||
You can give it your usual `$PATH` variable like this:
|
||||
|
||||
|
||||
```sh
|
||||
echo $PATH > $filename
|
||||
crontab -l >> $filename
|
||||
crontab $filename
|
||||
```
|
||||
|
||||
Now instead of doing this
|
||||
|
||||
`40 */3 * * * /usr/bin/du -sh $HOME/* | sort -h > $HOME/sum.txt`
|
||||
|
||||
You can simply do this:
|
||||
|
||||
`40 */3 * * * du -sh $HOME/* | sort -h > $HOME/sum.txt`
|
||||
|
||||
## Run as Root
|
||||
|
||||
You can execute a script as root by putting it into a directory, instead of in the tab.
|
||||
Look at the available cron directories:
|
||||
|
||||
```sh
|
||||
ls -d /etc/cron.*
|
||||
```
|
||||
|
||||
Make a script which runs daily:
|
||||
|
||||
```sh
|
||||
f=apt_update.sh
|
||||
echo '#!/bin/bash' > $f
|
||||
echo 'apt update --yes' >> $f
|
||||
chmod +x $f
|
||||
sudo mv $f /etc/cron.daily/
|
||||
```
|
||||
|
||||
### Testing with runparts
|
||||
|
||||
Run-parts runs all executable scripts in a directory.
|
||||
|
||||
```sh
|
||||
run-parts /etc/cron.hourly
|
||||
```
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
### `date` Commands
|
||||
|
||||
Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`.
|
||||
|
@@ -7,13 +7,13 @@ tags: [ "system", "deduplicate", "maintenance", "storage" ]
|
||||
|
||||
Ask if a directory has duplicates (`rdfind` will not delete anything):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rdfind $dir
|
||||
$EDITOR results.txt
|
||||
```
|
||||
|
||||
Replace the duplicated files with [hard links](../basics/hard_links.md).
|
||||
|
||||
```bash
|
||||
```sh
|
||||
rdfind -makehardlinks true $dir
|
||||
```
|
||||
|
@@ -9,19 +9,19 @@ Install the package `xdg-utils`, then make very liberal use of the tab button.
|
||||
|
||||
Ask what type of application opens an mkv file:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xdg-mime query default video/mkv
|
||||
```
|
||||
|
||||
Same with pdf:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xdg-mime query default application/pdf
|
||||
```
|
||||
|
||||
Ask what file-type `book.pdf` uses.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xdg-mime query filetype *book.pdf*
|
||||
```
|
||||
|
||||
@@ -29,7 +29,7 @@ xdg-mime query filetype *book.pdf*
|
||||
|
||||
Set the mime type of mp4 videos to mpv.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xdg-mime default mpv.desktop video/mp4
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ You'll need to use the tab key a lot here, and remember many items start with `o
|
||||
|
||||
You can use an asterisk for everything in a category.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xdg-mime default org.gnome.font-viewer.desktop font/\*
|
||||
```
|
||||
|
||||
|
12
system/lf.md
12
system/lf.md
@@ -7,25 +7,25 @@ tags: [ "file browser", "TUI" ]
|
||||
|
||||
If you don't have a `~/.config/lf/lfrc` file, you can probably find an example in `/usr/share/examples/lf`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cp -r /usr/share/examples/lf ~/.config/
|
||||
```
|
||||
|
||||
Go straight to root with two keys.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
map g/ cd /
|
||||
```
|
||||
|
||||
Have lf open a file with the default program when you press 'o', using the program `mimeo`.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
map o &mimeo $f
|
||||
```
|
||||
|
||||
Change that default text editor to look at the extension first.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cmd open ${{
|
||||
case $(file --mime-type $f -b) in
|
||||
application/x-sc) sc-im $fx;;
|
||||
@@ -52,7 +52,7 @@ That leaves it as a small initial pane, a medium pane, and a large pane for file
|
||||
The standard renaming is bad, because you have to re-type the file extension.
|
||||
Use this instead:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 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>
|
||||
@@ -65,7 +65,7 @@ If you try to rename `image_1.png` with this command, you can type in `cats`, an
|
||||
First, install `ueberzug` (to show images).
|
||||
Then clone the lfrun repo.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git clone https://github.com/cirala/lfimg.git
|
||||
|
||||
cd lfimg
|
||||
|
@@ -7,7 +7,7 @@ If you have `graph-easy` (often in the package `perl-graph-easy` or similar), yo
|
||||
|
||||
Start with the command to 'make all targets' (`-B`), and 'do a dummy run' (`-n`) with debug into (`-d`):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
make -Bnd
|
||||
make -Bnd | make2graph
|
||||
make -Bnd | make2graph | graph-easy --boxart
|
||||
|
@@ -7,7 +7,7 @@ tags: [ "RAID", "disk" ]
|
||||
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.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo mdadm --create --verbose /dev/*md127* --level=5 --raid-devices=*4* */dev/sdb /dev/sdc /dev/sdd /dev/sde*
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ Note the variable parts:
|
||||
|
||||
Now look at how the raid status:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cat /proc/mdstat
|
||||
```
|
||||
|
||||
@@ -27,7 +27,7 @@ This will increase until the entire thing is fine.
|
||||
|
||||
Check the health of your `mdadm` array:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo mdadm --detail /dev/md127
|
||||
```
|
||||
|
||||
@@ -35,7 +35,7 @@ You should see `State : clean`. If you see it is `degraded`, then a disk has bro
|
||||
|
||||
## Replacing a Disk
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo mdadm --add /dev/md127 /dev/sdb1
|
||||
```
|
||||
|
||||
|
@@ -5,26 +5,26 @@ tags: [ "system", "CPU", "memory" ]
|
||||
|
||||
Print the average CPU load over 1 minute, 5 minutes, and 15 minutes:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
watch -d cat /proc/loadavg
|
||||
stress="$(cat /proc/loadavg | awk '{print "Usage:" $2"%"}')"
|
||||
```
|
||||
|
||||
Show memory usage in Gibitytes.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
free -g
|
||||
```
|
||||
|
||||
Show low and high gigibtye usage on a *l*ine, and repeat the measurement every 5 seconds:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
REP=5
|
||||
free --lohi -g -s $REP | lolcat
|
||||
```
|
||||
|
||||
Check the next thing cron will do:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
cronnext /var/spool/cron/$USER -l
|
||||
```
|
||||
|
@@ -6,38 +6,38 @@ tags: [ "systemd" ]
|
||||
See a running log of all system messages:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
journalctl -f
|
||||
```
|
||||
|
||||
Or just one user:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
journalctl --user -f
|
||||
```
|
||||
|
||||
Or just one unit (`sshd`):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
journalctl -f -u sshd
|
||||
```
|
||||
|
||||
Find errors since November
|
||||
|
||||
```bash
|
||||
```sh
|
||||
journalctl --since=2018-11-01 --grep="EXT4-fs error"
|
||||
```
|
||||
|
||||
Limit size to 2G.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
journalctl --vacuum-size=2G
|
||||
```
|
||||
|
||||
Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can notice why your system's broken:
|
||||
|
||||
|
||||
```bash
|
||||
```sh
|
||||
logger "Installed new dnsmasq"
|
||||
sudo journalctl -f
|
||||
```
|
||||
|
@@ -26,7 +26,7 @@ WantedBy=multi-user.target
|
||||
|
||||
After making the new service, systemd requires reloading:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
|
@@ -2,33 +2,33 @@
|
||||
title: "systemd"
|
||||
tags: [ "systemd" ]
|
||||
---
|
||||
```bash
|
||||
```sh
|
||||
systemctl list-units
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl status mpd
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl taskd.service start
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemctl status taskd.service
|
||||
```
|
||||
|
||||
# Startup
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemd-analyze
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
sudo systemd-analyze blame
|
||||
```
|
||||
|
||||
|
@@ -4,23 +4,23 @@ tags: [ "documentation", "virtualization", "xen" ]
|
||||
---
|
||||
# Basic VM Management
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-list
|
||||
```
|
||||
|
||||
Start, stop, et c. with `xe`:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-start vm=$TARGET_VM
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-shutdown vm=$TARGET_VM
|
||||
```
|
||||
|
||||
Destruction requires the uuid.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-destroy uuid=$TARGET_UUID
|
||||
```
|
||||
|
||||
@@ -30,33 +30,33 @@ Autocompletion works well with all of these commands.
|
||||
|
||||
List VMs.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe host-list
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-list resident-on=$HOST_UUID
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-shutdown uuid=TARGET_VM force=true
|
||||
```
|
||||
|
||||
If this doesn't work, try:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-reset-powerstate uuid=TARGET_VM force=true
|
||||
```
|
||||
|
||||
Get the id:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
list_domains
|
||||
```
|
||||
|
||||
And destroy the domain:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
/opt/xensource/debug/xenops destroy_domain -domid $DOM_ID
|
||||
```
|
||||
|
||||
@@ -72,7 +72,7 @@ To resolve this error, complete the following procedure:
|
||||
|
||||
Open the Console to the XenServer that is hosting the VM and run the following command:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
list_domains
|
||||
```
|
||||
|
||||
@@ -84,23 +84,23 @@ This is the UUID of the Control Domain. The Control Domain is a privileged Virtu
|
||||
|
||||
Run the following command to obtain the UUID of the VBD (Virtual Block Device) object linking the Control Domain:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vbd-list vm-uuid=$CONTROL_DOMAIN_UUID
|
||||
```
|
||||
|
||||
Run the following commands to unplug and destroy the VBD:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vbd-unplug uuid=$VBD_UUID
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vbd-destroy uuid=$VBD_UUID
|
||||
```
|
||||
|
||||
# Make a local iso repository
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe sr-create name-label=LocalISO type=iso device-config:location=/var/opt/xen/ISO_Store device-config:legacy_mode=true content-type=iso
|
||||
```
|
||||
|
||||
@@ -110,7 +110,7 @@ This creates a UUID for the new directory, e.g.:
|
||||
|
||||
# Import
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-import filename="$FILENAME".xva
|
||||
```
|
||||
|
||||
@@ -122,19 +122,19 @@ Put in the USB.
|
||||
|
||||
Get the USB's uuid.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe pusb-list
|
||||
```
|
||||
|
||||
Make the USB recognised as a device.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe pusb-param-set uuid=*<uuid>*
|
||||
```
|
||||
|
||||
For passthrough, use this:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe pusb-param-set uuid=*<uuid>* passthrough-enabled=true
|
||||
```
|
||||
|
||||
@@ -146,17 +146,17 @@ xe pusb-param-set uuid=*<uuid>* passthrough-enabled=true
|
||||
|
||||
# Storage Spaces - "SR"
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe sr-list
|
||||
```
|
||||
|
||||
# Exporting and Exporting VMs
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-export vm=$VM_NAME filename="$FULL_PATH".xva
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xe vm-import vm=*<Name>* filename="$FULL_PATH".xva
|
||||
```
|
||||
|
||||
|
@@ -14,25 +14,25 @@ The input file might be a device, such as a camera.
|
||||
|
||||
Take the format as 'grab the x11 screen'.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -f x11grab -s [screensize] -i :0.0 out.mkv
|
||||
```
|
||||
|
||||
Get screensize with
|
||||
|
||||
```bash
|
||||
```sh
|
||||
xrandr -q
|
||||
```
|
||||
|
||||
or maybe just...
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -f x11grab -s "$(xdpyinfo | grep dimensions | awk '{print $2}')" -i :1.0 out.mkv
|
||||
```
|
||||
|
||||
# Add default pulse audio
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -f x11grab -s [screensize] -i :0.0 -f alsa -i default out.mkv
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ For problems, see pavucontrol.
|
||||
|
||||
# Rotate
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i in.mov -vf "transpose=1" out.mov
|
||||
```
|
||||
|
||||
@@ -62,71 +62,71 @@ ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4
|
||||
|
||||
Check for supported formats:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -formats
|
||||
```
|
||||
|
||||
To convert from mkv to mp4 we can use a codec rather than proper conversion. Both are wrappers around other formats, so this conversion loses less quality than other conversion types.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i LostInTranslation.mkv -codec copy LostInTranslation.mp4
|
||||
```
|
||||
|
||||
Opus to mp3
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i song.opus song.mp3
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i video.flv video.mpeg
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.webm -qscale 0 output.mp4
|
||||
```
|
||||
|
||||
# Video to Audio
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -vn output.mp3
|
||||
```
|
||||
|
||||
|
||||
# Convert all mkv files to mp4
|
||||
|
||||
```bash
|
||||
```sh
|
||||
for i in *.mkv; do
|
||||
```
|
||||
|
||||
> ffmpeg -i "$i" -codec copy "${i%.*}.mp4"
|
||||
|
||||
```bash
|
||||
```sh
|
||||
done
|
||||
```
|
||||
|
||||
|
||||
# Change resolution
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -filter:v scale=1280:720 -c:a copy output.mp4
|
||||
```
|
||||
|
||||
Or just crop:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -filter:v "crop=w:h:x:y" output.mp4
|
||||
```
|
||||
|
||||
Or aspect ratio:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -aspect 16:9 output.mp4
|
||||
```
|
||||
|
||||
Or trim to start and stop times:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -ss 00:00:50 -codec copy -t 50 output.mp4
|
||||
```
|
||||
|
||||
@@ -134,14 +134,14 @@ Indicate start times with -ss and time with -t in seconds.
|
||||
|
||||
Or split a video into parts:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -t 00:00:30 -c copy part1.mp4 -ss 00:00:30 -codec copy part2.mp4
|
||||
```
|
||||
|
||||
|
||||
# Compress Video
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 output.mp4
|
||||
```
|
||||
|
||||
@@ -149,19 +149,19 @@ ffmpeg -i input.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 outp
|
||||
|
||||
-r sets the frame rate, and -f selects the format.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
ffmpeg -i input.mp4 -r 1 -f image2 image-%2d.png
|
||||
```
|
||||
|
||||
# Add Images to Audio
|
||||
|
||||
```bash
|
||||
```sh
|
||||
$ ffmpeg -loop 1 -i inputimage.jpg -i inputaudio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4
|
||||
```
|
||||
|
||||
# Add Subtitles
|
||||
|
||||
```bash
|
||||
```sh
|
||||
fmpeg -i input.mp4 -i subtitle.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mp4
|
||||
```
|
||||
|
||||
|
@@ -5,35 +5,35 @@ tags: [ "vision" ]
|
||||
|
||||
Convert jpg to png.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick image.jpg image.png
|
||||
```
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick image.jpg -quality 50 image.jpg
|
||||
```
|
||||
|
||||
'Quality' must be from 1 to 100.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick -resize 50% image.jpg image2.jpg
|
||||
```
|
||||
|
||||
Resizing only changes jpegs. Change a png with:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick input.png png8:out.png
|
||||
```
|
||||
|
||||
# Invert Colours
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick input.jpg output.jpg -negate
|
||||
```
|
||||
|
||||
# Make Images Smaller
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick image.jpg -resize 25% output.jpg
|
||||
```
|
||||
|
||||
@@ -42,13 +42,13 @@ magick image.jpg -resize 25% output.jpg
|
||||
|
||||
This is generally used for transparent images.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick -trim image.png output.png
|
||||
```
|
||||
|
||||
Make the white of an image transparent.
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick -transparent white -fuzz 10% input.png output.png
|
||||
```
|
||||
|
||||
@@ -57,14 +57,14 @@ The 'fuzz' option tells the computer that 'close to white' is fine. You might w
|
||||
|
||||
## Dropshadow
|
||||
|
||||
```bash
|
||||
```sh
|
||||
`magick <input file> \( +clone -background black -shadow 50x8+0+5 \) +swap -background none -layers merge +repage <output file>`
|
||||
```
|
||||
|
||||
|
||||
# Convert every jpg in directory to png
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mogrify -format png *.jpg
|
||||
```
|
||||
|
||||
@@ -96,20 +96,20 @@ $potrace -s output.ppm -o svgout.svg
|
||||
|
||||
See your installed fonts:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick -list font
|
||||
```
|
||||
|
||||
Make an image showing day of the week:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png
|
||||
```
|
||||
|
||||
|
||||
Make a meme:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
magick inputmemeimage.png -font impact -fill white -pointsize 84 -stroke black -strokewidth 3 -gravity north -annotate +0+20 'TOP MEME TEXT' -gravity south -annotate +0+20 'BOTTOM MEME TEXT' outputmemeimage.png
|
||||
```
|
||||
|
||||
|
@@ -5,24 +5,24 @@ tags: [ "qrencode", "zbar" ]
|
||||
|
||||
Make a QR Code image:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png
|
||||
```
|
||||
|
||||
Make a QR Coded message in the terminal:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
qrencode -t ansi "Hello World"
|
||||
```
|
||||
|
||||
Read a QR Code image:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
zbarimg $FILE
|
||||
```
|
||||
|
||||
Show wifi QR code (only with Network Manager):
|
||||
|
||||
```bash
|
||||
```sh
|
||||
nmcli device wifi show-password
|
||||
```
|
||||
|
Reference in New Issue
Block a user