Migrated notes from mdnotes
This commit is contained in:
124
BASH Challenges.md
Normal file
124
BASH Challenges.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# BASH Challenges
|
||||
|
||||
These are examples of scripting challenges I was given and helped create for interviewees
|
||||
---
|
||||
|
||||
1. Check for the presence of a directory and create it if it doesn't exist
|
||||
|
||||
Example Solution
|
||||
|
||||
```bash
|
||||
devdir="/mnt/sqlback1/LSQLSHARE01DEV"
|
||||
if [[ ! -d "${devdir}" ]]; then
|
||||
echo "${devdir} not found."
|
||||
# Create Directory
|
||||
mkdir -p "${devdir}"
|
||||
fi
|
||||
```
|
||||
2. Given a threshold, determine if a given directory size is over the threshold.
|
||||
|
||||
Example Solution
|
||||
|
||||
```bash
|
||||
dir="/mnt/data2/backups"
|
||||
threshold="100000000" # 100GB
|
||||
|
||||
dirsize=$(/usr/bin/du -s ${dir} | awk '{print $1}')
|
||||
|
||||
if [[ $dirsize -gt $threshold ]]; then
|
||||
echo "Threshold Exceeded"
|
||||
/usr/bin/du -hs "${dir}"
|
||||
fi
|
||||
```
|
||||
3. Create and loop over an associative array. Ex. create an array of services and ports then print them
|
||||
|
||||
Example Solution
|
||||
|
||||
```bash
|
||||
# Declare service names and ports in an array
|
||||
declare -A services=( [apache_http]=80 [apache_https]=443 [ssh]=22 [telnet]=23 )
|
||||
|
||||
# Iterate over services and ports
|
||||
for p in "${!services[@]}"; do
|
||||
echo -e "Service: ${p} \t Port ${services[$p]}"
|
||||
done
|
||||
```
|
||||
|
||||
Example Output:
|
||||
|
||||
```
|
||||
Service: apache_https Port 443
|
||||
Service: telnet Port 23
|
||||
Service: ssh Port 22
|
||||
Service: apache_http Port 80
|
||||
```
|
||||
4. Write a short script that displays the numbers 2 through 128 in brackets (even numbers only, as seen below).
|
||||
|
||||
```
|
||||
[2]
|
||||
[4]
|
||||
[8]
|
||||
[16]
|
||||
[32]
|
||||
[64]
|
||||
[128]
|
||||
```
|
||||
|
||||
Example Solution
|
||||
|
||||
```bash
|
||||
i=1; while [ $i -lt 65 ]; do let i=$((i+i)); print "[$i]"; done```
|
||||
|
||||
```
|
||||
|
||||
Example Output
|
||||
|
||||
```
|
||||
[2]
|
||||
[4]
|
||||
[8]
|
||||
[16]
|
||||
[32]
|
||||
[64]
|
||||
[128]
|
||||
```
|
||||
5. Write a script that, for each number from 1 to 100, prints a comma-delimited list of numbers in descending order from the current number to 1. Each list should be shown on a separate line as seen below.
|
||||
|
||||
```
|
||||
1
|
||||
2,1
|
||||
3,2,1
|
||||
4,3,2,1
|
||||
...
|
||||
100,99,...,1
|
||||
```
|
||||
|
||||
Example Solution (from 10 to save space). (OK, I cheated shaving off the trailing comma.)
|
||||
|
||||
```bash
|
||||
echo "1"; for x in {2..10}; do for i in {$x..2}; do echo -n $i,; done; echo -n "1"; echo ""; done
|
||||
```
|
||||
|
||||
Best Solution:
|
||||
|
||||
```bash
|
||||
for (( i=1;i<=10;i++ )); do eval printf -- '%d\\n' "{${i}..1}" | paste -sd ',' -;done
|
||||
```
|
||||
|
||||
Example Output
|
||||
|
||||
```
|
||||
1
|
||||
2,1
|
||||
3,2,1
|
||||
4,3,2,1
|
||||
5,4,3,2,1
|
||||
6,5,4,3,2,1
|
||||
7,6,5,4,3,2,1
|
||||
8,7,6,5,4,3,2,1
|
||||
9,8,7,6,5,4,3,2,1
|
||||
10,9,8,7,6,5,4,3,2,1
|
||||
```
|
||||
|
||||
Tags:
|
||||
howto
|
||||
34
Calibre Content Server style sheet.md
Normal file
34
Calibre Content Server style sheet.md
Normal file
@@ -0,0 +1,34 @@
|
||||
This is the one I've used the most and I want to try others, so I need to save this one someplace.
|
||||
|
||||
```css
|
||||
@import url(https://fonts.googleapis.com/css?family=Goudy+Bookletter+1911);
|
||||
html {
|
||||
font-family: "Goudy Bookletter 1911", serif;
|
||||
font-size: 1.05em;
|
||||
color: #92979f;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
text-align: justify;
|
||||
text-indent: 2em;
|
||||
line-height: 150%;
|
||||
background-color: #27323c;
|
||||
margin: 0 auto;
|
||||
max-width: 23cm;
|
||||
border: 2pt dashed #27323c;
|
||||
box-shadow: 0 0 20px #000;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: "Goudy Bookletter 1911", serif;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
color: #d39151;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #fdfd96;
|
||||
}```
|
||||
12
Clean up old snaps.md
Normal file
12
Clean up old snaps.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Clean up old snaps
|
||||
|
||||
```shell
|
||||
#!/bin/bash
|
||||
#Removes old revisions of snaps
|
||||
#CLOSE ALL SNAPS BEFORE RUNNING THIS
|
||||
set -eu
|
||||
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
|
||||
while read snapname revision; do
|
||||
snap remove "$snapname" --revision="$revision"
|
||||
done
|
||||
```
|
||||
53
Fun with Find.md
Normal file
53
Fun with Find.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Fun with Find
|
||||
|
||||
## Find the total size of certain files within a directory branch
|
||||
|
||||
```bash
|
||||
find <path> -type f -iname '*-bin*' -exec du -ch {} +
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Find files larger than...
|
||||
|
||||
|
||||
### 100M:
|
||||
|
||||
|
||||
```bash
|
||||
find . -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
|
||||
```
|
||||
|
||||
### 1G:
|
||||
|
||||
|
||||
```bash
|
||||
find . -type f -size +1000000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
|
||||
```
|
||||
|
||||
...and so on...
|
||||
|
||||
---
|
||||
|
||||
## Find, archive and purge old files
|
||||
|
||||
```bash
|
||||
# Find disk space used by logfiles older that 360 days
|
||||
find /var/log/hbase -type f -iname "*log*" -mtime +360 -exec du -ch {} +
|
||||
|
||||
# Archive those files to another location
|
||||
find /var/log/hbase -type f -iname "*log*" -mtime +360 -print0 | xargs -0 tar cfz /tmp/hbase-logs.tgz
|
||||
|
||||
# Delete the original files
|
||||
find /var/log/hbase -type f -iname "*log*" -mtime +360 -delete
|
||||
```
|
||||
|
||||
Replace `hbase` with the log directory you want to search. If you don't need to save the archives anywhere, skip step two.
|
||||
|
||||
[Reference](https://www.cyberciti.biz/faq/linux-unix-find-tar-files-into-tarball-command/)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Tags:
|
||||
howto
|
||||
76
Fun with ISOs.md
Normal file
76
Fun with ISOs.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# All About ISO's
|
||||
|
||||
## Create ISO from DVD
|
||||
|
||||
Get the info of the cd/dvd you're copying.
|
||||
|
||||
```shell
|
||||
isoinfo -d -i /dev/sr0 | grep -i -E 'block size|volume size'
|
||||
```
|
||||
|
||||
Sample Output:
|
||||
|
||||
```shell
|
||||
Logical block size is: 2048
|
||||
Volume size is: 2264834
|
||||
```
|
||||
|
||||
We use the Logical block size for the `bs=` variable and Volume size for the COUNT=
|
||||
|
||||
use DD to copy the DVD to an iso:
|
||||
|
||||
```shell
|
||||
dd if=/dev/sr0 of=/mnt/incoming/test.iso bs=2048 count=2264834
|
||||
```
|
||||
|
||||
Sample Output:
|
||||
|
||||
```shell
|
||||
2264834+0 records in
|
||||
2264834+0 records out
|
||||
4638380032 bytes (4.6 GB, 4.3 GiB) copied, 373.405 s, 12.4 MB/s
|
||||
```
|
||||
|
||||
### Test the image against the actual DVD
|
||||
|
||||
Get checksum of DVD and newly created image
|
||||
|
||||
Image
|
||||
|
||||
```shell
|
||||
md5sum /mnt/incoming/test.iso
|
||||
```
|
||||
|
||||
Sample Output:
|
||||
|
||||
```shell
|
||||
d3a2cdd58b8c9ade05786526a4a8eae2 /mnt/incoming/test.iso
|
||||
```
|
||||
|
||||
DVD
|
||||
|
||||
```shell
|
||||
md5sum /dev/sr0
|
||||
```
|
||||
|
||||
Sample Output:
|
||||
|
||||
```shell
|
||||
d3a2cdd58b8c9ade05786526a4a8eae2 /dev/sr0
|
||||
```
|
||||
|
||||
## Create ISO from files/directories
|
||||
|
||||
Examples
|
||||
|
||||
```shell
|
||||
mkisofs -J -l -R -V "eBooks" -iso-level 4 -o /tmp/eBooks.iso ~/ownCloud/calibre-library/
|
||||
|
||||
mkisofs -allow-lowercase -R -V "eBooks" -iso-level 4 -o /tmp/eBooks.iso /mnt/calibre-library
|
||||
```
|
||||
|
||||
## Mount ISO Image
|
||||
|
||||
```shell
|
||||
mount -o loop -t iso9660 /tmp/CalibreLibrary2018.iso /tmp/OldLibrary
|
||||
```
|
||||
94
Fun with netplan.md
Normal file
94
Fun with netplan.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# Fun with netplan
|
||||
|
||||
## static IP and bridge
|
||||
|
||||
```yaml
|
||||
## systemd-networkd config
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
enp4s0:
|
||||
dhcp4: no
|
||||
dhcp6: no
|
||||
optional: true
|
||||
enp5s0:
|
||||
dhcp4: no
|
||||
dhcp6: no
|
||||
optional: true
|
||||
bridges:
|
||||
br0:
|
||||
interfaces:
|
||||
- enp4s0
|
||||
- enp5s0
|
||||
optional: true
|
||||
dhcp4: no
|
||||
dhcp6: no
|
||||
addresses:
|
||||
- 192.168.0.208/24
|
||||
gateway4: 192.168.0.1
|
||||
nameservers:
|
||||
addresses:
|
||||
- 1.1.1.1
|
||||
- 8.8.8.8
|
||||
```
|
||||
|
||||
## static IP with bonded interfaces
|
||||
|
||||
```yaml
|
||||
## systemd-networkd config
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
enp4s0:
|
||||
optional: true
|
||||
enp5s0:
|
||||
optional: true
|
||||
bonds:
|
||||
bond0:
|
||||
addresses:
|
||||
- 192.168.0.208/24
|
||||
gateway4: 192.168.0.1
|
||||
interfaces:
|
||||
- enp4s0
|
||||
- enp5s0
|
||||
nameservers:
|
||||
addresses:
|
||||
- 1.1.1.1
|
||||
- 8.8.8.8
|
||||
dhcp4: false
|
||||
dhcp6: false
|
||||
optional: true
|
||||
parameters:
|
||||
mode: balance-rr
|
||||
bridges:
|
||||
br0:
|
||||
interfaces: [bond0]
|
||||
```
|
||||
|
||||
## DHCP
|
||||
|
||||
```yaml
|
||||
## systemd-networkd config
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
enp4s0:
|
||||
dhcp4: true
|
||||
dhcp6: false
|
||||
optional: true
|
||||
enp5s0:
|
||||
dhcp4: true
|
||||
dhcp6: false
|
||||
optional: true
|
||||
```
|
||||
|
||||
## Basic NetworkManager config
|
||||
|
||||
```yaml
|
||||
network:
|
||||
version: 2
|
||||
renderer: NetworkManager
|
||||
```
|
||||
43
Fun with wget.md
Normal file
43
Fun with wget.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Fun with wget
|
||||
|
||||
## wget multiple files
|
||||
|
||||
```bash
|
||||
wget -r -l1 -A.mp3 http://aaa.com/directory
|
||||
```
|
||||
|
||||
In the above example, `-r` and `-l1` options together enable 1-level deep recursive retrieval, and `-A` option specifies lists of file name suffixes to accept during recursive download (`.mp3` in this case).
|
||||
|
||||
## ways to wget entire webpage
|
||||
This one works well, I've created an alias for it:
|
||||
```bash
|
||||
wgetMirror='/usr/bin/wget -o wget.log -mkEpnp –wait=9 –user-agent='\''Mozilla/5.0 (compatible; Googlebot/2.1; +http://www. google.com/bot.html)'\'' –no-check-certificate'
|
||||
```
|
||||
|
||||
Other options:
|
||||
```bash
|
||||
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains example.com --no-parent <url>
|
||||
```
|
||||
|
||||
|
||||
## Modify User Agent
|
||||
|
||||
```bash
|
||||
$ wget -U "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" <url>
|
||||
```
|
||||
|
||||
## wget from webdav with authentication
|
||||
|
||||
```bash
|
||||
wget --http-user=user-id --http-password=password <URL>
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Reference
|
||||
|
||||
* [Download Multiple Files with wget](http://xmodulo.com/how-to-download-multiple-files-with-wget.html)
|
||||
* [Archiving website with wget](https://www.petekeen.net/archiving-websites-with-wget)
|
||||
* [Download entire webpage with wget](https://janezurevc.name/download-entire-web-page-using-wget)
|
||||
* [Change the User Agent in wget](https://www.networkinghowtos.com/howto/change-the-user-agent-in-wget/)
|
||||
89
Generic directory backup script.md
Normal file
89
Generic directory backup script.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Generic Directory Backup Script
|
||||
|
||||
I regularly have directories of files I want to back up in case of disaster. Usually these are files that change often, and I only want to keep recent versions in case I want to revert or recover changes. (Git? git, who?)
|
||||
|
||||
I have used this script over and over as a simple way to archive a directory to a location with a date-stamped filename. It also cleans up after itself by deleting files older than X days. I stick it in CRON and let it run on a schedule and I always have an archive of the last X days of the files in my directory.
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: wiki-backup.sh
|
||||
# AUTHOR: C Hawley
|
||||
# CREATED: 2022-11-30
|
||||
# REVISION: 2022-11-30
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
# Backup Source
|
||||
bsource=/mnt/data/wiki-data
|
||||
|
||||
# Backup Destination
|
||||
bdest=/mnt/backups
|
||||
|
||||
# Backup Filename (no extension)
|
||||
bfilename=wiki-data-backup
|
||||
|
||||
# Get today's date
|
||||
bdate=$(date +"%Y-%m-%d")
|
||||
|
||||
# Archive directory to the destination
|
||||
tar czf $bdest/$bfilename-$bdate.tgz $bsource
|
||||
|
||||
# Prune backups older than 7 days
|
||||
find $bdest -maxdepth 1 -type f -iname "$bfilename*.tgz" -mtime +7 -delete
|
||||
```
|
||||
|
||||
Here's one with a twist - backing up certain things on certain days of the week:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
#===================================================================
|
||||
#
|
||||
# FILE: dockerdata-backup.sh
|
||||
# USAGE:
|
||||
# DESCRIPTION:
|
||||
# OPTIONS:
|
||||
# REQUIREMENTS:
|
||||
# NOTES:
|
||||
# AUTHOR: C Hawley
|
||||
# CREATED: 2021-04-01
|
||||
# REVISION: 2022-02-02
|
||||
#
|
||||
#===================================================================
|
||||
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
# Get today's date
|
||||
bdate=$(date +"%Y-%m-%d")
|
||||
day=$(date +%u)
|
||||
|
||||
# Backup Source
|
||||
bsource=/mnt/docker
|
||||
|
||||
# Backup Destination
|
||||
bdest=/mnt/nfs/derry
|
||||
|
||||
# Backup Every Day
|
||||
for dir in gitea npm; do
|
||||
echo "Archiving $bsource/$dir -> $bdest/$dir-$bdate.tgz"
|
||||
tar czf $bdest/$dir-$bdate.tgz $bsource/$dir
|
||||
done
|
||||
|
||||
# Backup only on certain day of week
|
||||
case $day in
|
||||
3) #Wednesday
|
||||
for dir in filerun; do
|
||||
echo "Archiving $bsource/$dir -> $bdest/$dir-$bdate.tgz"
|
||||
tar czf $bdest/$dir-$bdate.tgz $bsource/$dir
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
# Prune backups older than 3 days
|
||||
find $bdest -type f -iname "*.tgz" -mtime +3 -delete
|
||||
```
|
||||
|
||||
Change the Backup source, destination and filename variables for your case and the -mtime number to change the retention days.
|
||||
293
KiTTy vs PuTTy.md
Normal file
293
KiTTy vs PuTTy.md
Normal file
@@ -0,0 +1,293 @@
|
||||
# KiTTY vs PuTTY
|
||||
|
||||
## Summary
|
||||
|
||||
Do you work on Linux machines? Do you only have a Windows machine from which to connect? Then you're probably already using PuTTY.
|
||||
|
||||
Well, step aside PuTTY, there's a new terminal client in town.
|
||||
|
||||
KiTTY is a fork of the original PuTTY software, with loads of new features, including a portable version that saves all of your sessions and settings into an INI file in the same folder.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download [KiTTY Portable](http://www.fosshub.com/KiTTY.html)
|
||||
2. ???
|
||||
3. PROFIT!
|
||||
|
||||
Just kidding. There are no other steps. The download is an EXE that's ready to go. Just double-click on it and enter your connection parameters (should be familiar if you've ever used PuTTY)
|
||||
|
||||
## Portability
|
||||
|
||||
By default, KiTTY uses the Windows registry database to save its configuration (sessions, host keys, parameters). But, it's possible to save it into a tree directories structure and to avoid writing anything into the registry.
|
||||
|
||||
Create a new folder for KiTTY anywhere on your disk and move the KiTTY.exe into it.
|
||||
|
||||
Create a file called `kitty.ini` in the same directory where you put KiTTY binary, and add these two lines:
|
||||
|
||||
```ini
|
||||
[KiTTY]
|
||||
savemode=dir
|
||||
```
|
||||
|
||||
If you've already used KiTTY to connect to some machines and have some profiles saved, you can copy all the existing configurations from the registry.
|
||||
|
||||
You just have to run this command from a command line within the KiTTY directory
|
||||
|
||||
```
|
||||
kitty.exe -convert-dir
|
||||
```
|
||||
|
||||
This option will create 6 subdirectories:
|
||||
|
||||
- Commands
|
||||
- Folders
|
||||
- Launcher
|
||||
- Sessions
|
||||
- Sessions\_Commands
|
||||
- SshHostKeys
|
||||
|
||||
containing the configuration files.
|
||||
|
||||
## Colors
|
||||
|
||||
The biggest reason I started using KiTTY was to get away from those horrible PuTTY colors. (Yes - you can change the colors in PuTTY - but this method is much easier)
|
||||
|
||||
In your KiTTY directory, there will be a directory named: Sessions. In that folder, you will find separate files for each of your saved connections.
|
||||
|
||||
Open one of them (I recommend using something like Notepad++, but plain old notepad should work too)
|
||||
|
||||
Somewhere in the middle of the file, you will find several color definitions (in RBG format)
|
||||
|
||||
You can modify each of these to change the color of the specific element. (But without knowing which element is which - it will be very difficult!)
|
||||
|
||||
Or you can simply copy/paste some pre-made schemes into the lines in your session file.
|
||||
|
||||
Copy or rename your original session file someplace safe, then copy the above lines and paste them into your session file, replacing the lines that define `Colour0` through `Colour21`.
|
||||
|
||||
Close and reopen KiTTY and restart your session. Voilà! Now, aren't those colors better? No? Then try some others:
|
||||
|
||||
### X Dotshare
|
||||
|
||||
```
|
||||
Colour0\215,208,199\
|
||||
Colour1\255,255,255\
|
||||
Colour2\21,21,21\
|
||||
Colour3\21,21,21\
|
||||
Colour4\255,137,57\
|
||||
Colour5\215,208,199\
|
||||
Colour6\16,16,16\
|
||||
Colour7\64,64,64\
|
||||
Colour8\232,79,79\
|
||||
Colour9\210,61,61\
|
||||
Colour10\184,214,140\
|
||||
Colour11\160,207,93\
|
||||
Colour12\225,170,93\
|
||||
Colour13\243,157,33\
|
||||
Colour14\125,193,207\
|
||||
Colour15\78,159,177\
|
||||
Colour16\155,100,251\
|
||||
Colour17\133,66,255\
|
||||
Colour18\109,135,141\
|
||||
Colour19\66,113,123\
|
||||
Colour20\221,221,221\
|
||||
Colour21\221,221,221\
|
||||
```
|
||||
|
||||
### Zenburn
|
||||
|
||||
```
|
||||
Colour0\220,220,204\
|
||||
Colour1\220,220,204\
|
||||
Colour2\63,63,63\
|
||||
Colour3\63,63,63\
|
||||
Colour4\115,99,90\
|
||||
Colour5\0,0,0\
|
||||
Colour6\77,77,77\
|
||||
Colour7\112,144,128\
|
||||
Colour8\112,80,80\
|
||||
Colour9\220,163,163\
|
||||
Colour10\96,180,138\
|
||||
Colour11\195,191,159\
|
||||
Colour12\240,223,175\
|
||||
Colour13\224,207,159\
|
||||
Colour14\80,96,112\
|
||||
Colour15\148,191,243\
|
||||
Colour16\220,140,195\
|
||||
Colour17\236,147,211\
|
||||
Colour18\140,208,211\
|
||||
Colour19\147,224,227\
|
||||
Colour20\220,220,204\
|
||||
Colour21\255,255,255\
|
||||
```
|
||||
|
||||
### Chalkboard
|
||||
|
||||
```
|
||||
Colour0\217,230,242\
|
||||
Colour1\217,111,95\
|
||||
Colour2\41,38,47\
|
||||
Colour3\41,38,47\
|
||||
Colour4\217,230,242\
|
||||
Colour5\217,230,242\
|
||||
Colour6\0,0,0\
|
||||
Colour7\50,50,50\
|
||||
Colour8\195,115,114\
|
||||
Colour9\219,170,170\
|
||||
Colour10\114,195,115\
|
||||
Colour11\170,219,170\
|
||||
Colour12\194,195,114\
|
||||
Colour13\218,219,170\
|
||||
Colour14\115,114,195\
|
||||
Colour15\170,170,219\
|
||||
Colour16\195,114,194\
|
||||
Colour17\219,170,218\
|
||||
Colour18\114,194,195\
|
||||
Colour19\170,218,219\
|
||||
Colour20\217,217,217\
|
||||
Colour21\255,255,255\
|
||||
```
|
||||
|
||||
### Dark Pastel
|
||||
|
||||
```
|
||||
Colour0\255,255,255\
|
||||
Colour1\255,94,125\
|
||||
Colour2\0,0,0\
|
||||
Colour3\0,0,0\
|
||||
Colour4\187,187,187\
|
||||
Colour5\255,255,255\
|
||||
Colour6\0,0,0\
|
||||
Colour7\85,85,85\
|
||||
Colour8\255,85,85\
|
||||
Colour9\255,85,85\
|
||||
Colour10\85,255,85\
|
||||
Colour11\85,255,85\
|
||||
Colour12\255,255,85\
|
||||
Colour13\255,255,85\
|
||||
Colour14\85,85,255\
|
||||
Colour15\85,85,255\
|
||||
Colour16\255,85,255\
|
||||
Colour17\255,85,255\
|
||||
Colour18\85,255,255\
|
||||
Colour19\85,255,255\
|
||||
Colour20\187,187,187\
|
||||
Colour21\255,255,255\
|
||||
```
|
||||
|
||||
### Dotshare
|
||||
|
||||
```
|
||||
Colour0\215,208,199\
|
||||
Colour1\255,255,255\
|
||||
Colour2\21,21,21\
|
||||
Colour3\21,21,21\
|
||||
Colour4\255,137,57\
|
||||
Colour5\215,208,199\
|
||||
Colour6\16,16,16\
|
||||
Colour7\64,64,64\
|
||||
Colour8\232,79,79\
|
||||
Colour9\210,61,61\
|
||||
Colour10\184,214,140\
|
||||
Colour11\160,207,93\
|
||||
Colour12\225,170,93\
|
||||
Colour13\243,157,33\
|
||||
Colour14\125,193,207\
|
||||
Colour15\78,159,177\
|
||||
Colour16\155,100,251\
|
||||
Colour17\133,66,255\
|
||||
Colour18\109,135,141\
|
||||
Colour19\66,113,123\
|
||||
Colour20\221,221,221\
|
||||
Colour21\221,221,221\
|
||||
```
|
||||
|
||||
### IC Green Ppl
|
||||
|
||||
```
|
||||
Colour0\217,239,211\
|
||||
Colour1\159,255,109\
|
||||
Colour2\58,61,63\
|
||||
Colour3\58,61,63\
|
||||
Colour4\66,255,88\
|
||||
Colour5\217,239,211\
|
||||
Colour6\31,31,31\
|
||||
Colour7\3,39,16\
|
||||
Colour8\251,0,42\
|
||||
Colour9\167,255,63\
|
||||
Colour10\51,156,36\
|
||||
Colour11\159,255,109\
|
||||
Colour12\101,155,37\
|
||||
Colour13\210,255,109\
|
||||
Colour14\20,155,69\
|
||||
Colour15\114,255,181\
|
||||
Colour16\83,184,44\
|
||||
Colour17\80,255,62\
|
||||
Colour18\44,184,104\
|
||||
Colour19\34,255,113\
|
||||
Colour20\224,255,239\
|
||||
Colour21\218,239,208\
|
||||
```
|
||||
|
||||
### Monokai Soda
|
||||
|
||||
```
|
||||
Colour0\196,197,181\
|
||||
Colour1\196,197,181\
|
||||
Colour2\26,26,26\
|
||||
Colour3\26,26,26\
|
||||
Colour4\246,247,236\
|
||||
Colour5\196,197,181\
|
||||
Colour6\26,26,26\
|
||||
Colour7\98,94,76\
|
||||
Colour8\244,0,95\
|
||||
Colour9\244,0,95\
|
||||
Colour10\152,224,36\
|
||||
Colour11\152,224,36\
|
||||
Colour12\250,132,25\
|
||||
Colour13\224,213,97\
|
||||
Colour14\157,101,255\
|
||||
Colour15\157,101,255\
|
||||
Colour16\244,0,95\
|
||||
Colour17\244,0,95\
|
||||
Colour18\88,209,235\
|
||||
Colour19\88,209,235\
|
||||
Colour20\196,197,181\
|
||||
Colour21\246,246,239\
|
||||
```
|
||||
|
||||
### Seafoam Pastel
|
||||
|
||||
```
|
||||
Colour0\212,231,212\
|
||||
Colour1\100,136,144\
|
||||
Colour2\36,52,53\
|
||||
Colour3\36,52,53\
|
||||
Colour4\87,100,122\
|
||||
Colour5\212,231,212\
|
||||
Colour6\117,117,117\
|
||||
Colour7\138,138,138\
|
||||
Colour8\130,93,77\
|
||||
Colour9\207,147,122\
|
||||
Colour10\114,140,98\
|
||||
Colour11\152,217,170\
|
||||
Colour12\173,161,109\
|
||||
Colour13\250,231,157\
|
||||
Colour14\77,123,130\
|
||||
Colour15\122,195,207\
|
||||
Colour16\138,114,103\
|
||||
Colour17\214,178,161\
|
||||
Colour18\114,148,148\
|
||||
Colour19\173,224,224\
|
||||
Colour20\224,224,224\
|
||||
Colour21\224,224,224\
|
||||
```
|
||||
|
||||
There are more and of course, you can create your own.
|
||||
|
||||
There you have it. KiTTY over PuTTY for portability. Color scheme changes and a host of other features unique to KiTTY make it my terminal client software of choice when I have to use Windows.
|
||||
|
||||
## Reference
|
||||
|
||||
- [KiTTY Homepage](http://www.9bis.net/kitty/?page=Welcome&zone=en)
|
||||
- [Color Schemes](http://putty.org.ru/themes/index.html) - The page is in Russian - but you can see the RGB codes for each scheme by clicking on them
|
||||
- [Notepad++](https://notepad-plus-plus.org/download/v6.8.6.html)
|
||||
60
Markdown notes with VS Code.md
Normal file
60
Markdown notes with VS Code.md
Normal file
@@ -0,0 +1,60 @@
|
||||
My long, winding path to Markdown notes nirvana
|
||||
|
||||
For years, I’ve been looking for a cross-platform markdown editor. There are several good ones out there, but several are not free, or they’ve got built-in workflows that I would need to either adapt or fight against.
|
||||
|
||||
For the last several years, my notes have consisted of a single directory of markdown files.
|
||||
|
||||
At home, I sync these files to various machines with [Nextcloud](https://nextcloud.com/). What I wanted was a way to manage them and perhaps link amongst them (almost like a [wiki](https://www.dokuwiki.org/dokuwiki), which I used previously, but again found myself fighting with different implementations of Markdown and note portability).
|
||||
|
||||
After settling on [Typora](https://typora.io/) for a long time, I found it to be an excellent Markdown editor, and it handled my single directory of files well with a built-in file explorer.
|
||||
|
||||
After a few months I received a suggestion from a friend at work to look into [Obsidian](https://obsidian.md/). Obsidian quickly became my favorite editor. It’s free, robust and has a large community.
|
||||
|
||||
There are tons of themes and plug-ins, and I was able to create links between notes and insert images with ease. The table plugin is a dream for anyone who messes with Markdown tables. It’s also cross-platform, and I was able to access and update my notes from both my home Linux machines and my Windows work laptop.
|
||||
|
||||
Obsidian has a pretty fast release schedule, and they are always adding new, exciting features. In July 2021 Obsidian dropped their mobile app. Now, I have always accessed my notes via the [Nextcloud Notes](https://play.google.com/store/apps/details?id=it.niedermann.owncloud.notes&hl=en_US&gl=US) app, but I was aware that the app is a bare-bones editor that is good for quick edits or reading, but not for actually creating or managing notes. I thought the Obsidian mobile app might be the solution to finally having full access to my notes everywhere I went!
|
||||
|
||||
Unfortunately, note syncing within the Obsidian app was only available (at the time) via a proprietary (paid) file-sync or some kind of roll-your-own (but not any of the big cloud providers like Google Drive, OneDrive or Nextcloud.)
|
||||
|
||||
At this point I started thinking about the dangers of locking myself into a single system from which I may never escape. Portability and the ability to use my own (preferably open-source) tools to manage my notes is the reason I never seriously considered options like OneNote or EverNote.
|
||||
|
||||
While I continued to use Obsidian without the mobile app, I started considering the possibility of an alternative.
|
||||
|
||||
The entire time I was using Obsidian, I was also trying to wrap my head around using [VS Code](https://code.visualstudio.com/) for system administration. VS Code is an open-source, cross-platform editor for programmers. It also has a huge, rich ecosystem of plug-ins and support. But I am not a programmer. Apart from a series of convoluted shell scripts and some random HTML, I was trying to use VS Code to manage git repositories on multiple machines while writing Ansible scripts to automate administration tasks.
|
||||
|
||||
So one day I took a deep dive into the vast extension collection and found some ways to manage Markdown in VS Code. Then I found a spell-check extension. I figured out the basics of workspaces and opened up my directory of notes. Hey! I am able to edit and manage my notes from VS Code! But there were a lot of features missing. This was not going to replace Obsidian. But it was nice to have an option.
|
||||
|
||||
After swapping back and forth between Obsidian and VS Code, one day I found this article: [Suping Up VS Code as a Markdown Notebook](https://kortina.nyc/essays/suping-up-vs-code-as-a-markdown-notebook/#note-navigation-with-wiki-links-and-tags-using-my-vs-code-markdown-notes-extension). He had managed to come very close to my use case, taking notes exclusively in VS Code, and had incorporated most of the features I missed most from Obsidian!
|
||||
|
||||
So I began figuring out how to duplicate my most-wanted note features in VS Code.
|
||||
|
||||
Since July 2021, I have been using VS Code exclusively to create and manage my notes. I still use the Nextcloud Notes app for mobile access, but that’s never been a big problem and the app keeps getting updated, so you never know when it might get more features!
|
||||
|
||||
## VS Code Markdown Notes
|
||||
|
||||
**TL;DR: Just tell me what to install!**
|
||||
|
||||
If you just want to have a nice editor for markdown notes, these extensions should get you there. My modifications to default settings are included below the extension link.
|
||||
|
||||
### Extension List
|
||||
|
||||
* [code-spell-checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
|
||||
* [markdown-all-in-one](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one)
|
||||
* [markdown-extended](https://marketplace.visualstudio.com/items?itemName=jebbs.markdown-extended)
|
||||
* [markdown-emoji](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-emoji)
|
||||
* [markdown-to-confluence](https://marketplace.visualstudio.com/items?itemName=t-nano.markdown-to-confluence-vscode)
|
||||
* [vscode-markdown-notes](https://marketplace.visualstudio.com/items?itemName=kortina.vscode-markdown-notes)
|
||||
```
|
||||
"vscodeMarkdownNotes.allowPipedWikiLinks": true,
|
||||
"vscodeMarkdownNotes.compileSuggestionDetails": true,
|
||||
"vscodeMarkdownNotes.slugifyCharacter": "NONE",
|
||||
"vscodeMarkdownNotes.lowercaseNewNoteFilenames": false,
|
||||
"vscodeMarkdownNotes.newNoteTemplate": "---\\ntitle: ${noteName}\\ntags: [ ]\\n---\\n\\n# ${noteName}\\n\\n## Summary",
|
||||
"vscodeMarkdownNotes.noteCompletionConvention": "noExtension"
|
||||
```
|
||||
|
||||
* [markdown-preview-enhanced](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced)
|
||||
```
|
||||
"markdown-preview-enhanced.codeBlockTheme": "atom-material.css",
|
||||
"markdown-preview-enhanced.previewTheme": "monokai.css"
|
||||
```
|
||||
21
Port information on Linux.md
Normal file
21
Port information on Linux.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Why is that port open?
|
||||
|
||||
> I don't know why are you concerned about processes listening on localhost (meaning there is no access to that port from outside). But if you really want, you can see which package is involved.
|
||||
|
||||
First of all find out what process is using it: (run as root)
|
||||
|
||||
```shell
|
||||
netstat -tunlp | grep PORT
|
||||
ps ax | grep PROCNUM
|
||||
dpkg --search EXECUTABLE
|
||||
```
|
||||
|
||||
| Variable | Description |
|
||||
|:------------- |:---------------------------------------------------------- |
|
||||
| **PROCNUM** | process number seen on the previous command output. |
|
||||
| **EXECUTABLE** | the executable with full path of the above process number. |
|
||||
|
||||
Then examine that package with aptitude show or whatever.
|
||||
|
||||
## Reference
|
||||
* [[SOLVED] What happened if I disable "rpcbind"?](https://www.linuxquestions.org/questions/linux-networking-3/what-happened-if-i-disable-rpcbind-4175594881/#post5638538)
|
||||
50
Redshift Config.md
Normal file
50
Redshift Config.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Redshift Config
|
||||
|
||||
Redshift adjusts the color temperature according to the position of the sun. A different color temperature is set during night and daytime. During twilight and early morning, the color temperature transitions smoothly from night to daytime temperature to allow your eyes to slowly adapt.
|
||||
|
||||
Create the file `$HOME/.config/redshift.conf`
|
||||
|
||||
```
|
||||
; Global settings
|
||||
[redshift]
|
||||
temp-day=6500K
|
||||
temp-night=5000K
|
||||
|
||||
transition=1
|
||||
|
||||
;gamma=0.8:0.7:0.8
|
||||
gamma=1.000:1.000:1.000
|
||||
|
||||
location-provider=geoclue2
|
||||
;location-provider=manual
|
||||
|
||||
;adjustment-method=vidmode
|
||||
adjustment-method=randr
|
||||
|
||||
;brightness=1.0:0.5
|
||||
;brightness-day=0.9
|
||||
;brightness-night=0.6
|
||||
|
||||
; The location provider and adjustment method settings are in their own sections.
|
||||
; Below is the Lat/Long for northeast Ohio (Cleveland area)
|
||||
[manual]
|
||||
lat=41.4553
|
||||
lon=-81.9179
|
||||
|
||||
; In this example screen 1 is adjusted by vidmode. Note that the numbering starts from 0, so this is actually the second screen.
|
||||
;[vidmode]
|
||||
;screen=1
|
||||
```
|
||||
|
||||
Add the following stanza to `/etc/geoclue/geoclue.conf`
|
||||
|
||||
```
|
||||
[redshift]
|
||||
allowed=true
|
||||
system=false
|
||||
users=
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
* [Failed to run Redshift: Trying location provider geoclue2... · Issue #445 · jonls/redshift · GitHub](https://github.com/jonls/redshift/issues/445)
|
||||
40
Ubuntu phased updates.md
Normal file
40
Ubuntu phased updates.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Q: Ubuntu phased updates
|
||||
|
||||
Recently, during the normal software upgrade process (i.e., apt upgrade or apt dist-upgrade) I started getting messages like this:
|
||||
|
||||
```
|
||||
[...]
|
||||
The following packages have been kept back:
|
||||
[...]
|
||||
0 upgraded, 0 newly installed, 0 to remove and [...] not upgraded.
|
||||
```
|
||||
What are my options?
|
||||
|
||||
## A: Phased Updates are a safety feature
|
||||
Some users get the upgraded packages first, and have the ability to report broken package, instead of everybody getting a broken package at once and millions of users scratching their heads.
|
||||
It's there for your protection. Don't try to outsmart it.
|
||||
|
||||
Kept-back packages due to Phased Updates will automatically resolve themselves, download, and install over a week or so.
|
||||
Most users should DO NOTHING. It's not broken. Don't try to force upgrades. Just be patient and let the system work.
|
||||
|
||||
## Diagnosis -- how to tell if Phased Updates is the culprit:
|
||||
|
||||
It's easy. Run apt-cache policy <packagename> on one of your held back packages. Look for the 'phased' percentage. It's only present if the package is currently phasing.
|
||||
|
||||
```
|
||||
$ apt-cache policy gir1.2-gstreamer-1.0
|
||||
gir1.2-gstreamer-1.0:
|
||||
Installed: 1.20.3-0ubuntu1
|
||||
Candidate: 1.20.3-0ubuntu1
|
||||
Version table:
|
||||
*** 1.20.3-0ubuntu1 500 (phased 40%) <----------------- There it is!
|
||||
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
|
||||
100 /var/lib/dpkg/status
|
||||
1.20.1-1 500
|
||||
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
* [Reference 1](https://askubuntu.com/a/1421130)
|
||||
* [Reference 2](https://discourse.ubuntu.com/t/phased-updates-in-apt-in-21-04/20345)
|
||||
7
View Apache requests per hour.md
Normal file
7
View Apache requests per hour.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# View Apache requests per hour
|
||||
|
||||
```
|
||||
grep "23/Jan" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":00"}' | sort -n | uniq -c
|
||||
```
|
||||
|
||||
* [Reference](https://iceburn.medium.com/view-level-of-traffic-with-apache-access-log-65f9e3c30b1f)
|
||||
29
Zandronum.md
Normal file
29
Zandronum.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Zandronum
|
||||
|
||||
## Summary
|
||||
|
||||
Zandronum brings classic Doom into the 21st century, maintaining the essence of what has made Doom great for so many years and, at the same time, adding new features to modernize it, creating a fresh, fun new experience.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
wget -O - http://debian.drdteam.org/drdteam.gpg | sudo apt-key add -
|
||||
sudo add-apt-repository 'deb http://debian.drdteam.org/ stable multiverse'
|
||||
sudo apt update
|
||||
sudo apt install zandronum doomseeker-zandronum libcanberra-gtk-module
|
||||
zandronum
|
||||
vim ~/.config/zandronum/zandronum.ini
|
||||
|
||||
```
|
||||
|
||||
## No Sound Fix
|
||||
|
||||
[Zandronum 3.0.1 core dumps on Arch Linux - Zandronum](https://zandronum.com/forum/viewtopic.php?t=9885)
|
||||
|
||||
> [Re: Zandronum 3.0.1 core dumps on Arch Linux](https://zandronum.com/forum/viewtopic.php?t=9885#p115551) Sun Mar 22, 2020 10:38 pm Temporary workaround is to start with -nosound, go to sound options, and change your output type to SDL. Then restart normally.
|
||||
> It's a bug in FMOD that seems to happen with newer versions of distros. It's fixed by using a newer FMOD Ex, but the above is a good workaround in the meantime.
|
||||
|
||||
## Links
|
||||
|
||||
- [Welcome to Zandronum](https://zandronum.com/)
|
||||
- [Install Zandronum on Ubuntu](https://wiki.zandronum.com/Install_Zandronum_on_Ubuntu)
|
||||
19
tar without paths.md
Normal file
19
tar without paths.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# tar without paths
|
||||
|
||||
[linux - tar - Remove leading directory components on extraction - Server Fault](https://serverfault.com/questions/330127/tar-remove-leading-directory-components-on-extraction)
|
||||
|
||||
You want to use the `--strip-components=NUMBER` option of `tar`:
|
||||
|
||||
```
|
||||
--strip-components=NUMBER
|
||||
```
|
||||
|
||||
strip NUMBER leading components from file names on extraction
|
||||
|
||||
Your command would be:
|
||||
|
||||
```
|
||||
tar xfz /var/www/site.gz --strip-components=2 -C /tmp
|
||||
```
|
||||
|
||||
[Reference](https://serverfault.com/a/330131)
|
||||
Reference in New Issue
Block a user