diff --git a/Makefile b/Makefile index 5eefb86..a4fd400 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +MAKEFLAGS += -j +MAKEFLAGS += -s +EDITOR ?= vi FZF != command -v sk || command -v fzy || command -v fzf || \ { echo install a fuzzy finder && exit 1 ;} @@ -8,25 +11,38 @@ help: ## Print the help message articles != find * -type f -name "*.md" -db.rec: $(articles) +categories != ls -d */ + +databases = $(patsubst %/, .dbs/%.rec, $(categories)) + +default += $(databases) + +$(databases): .dbs/%.rec: %/ | .dbs/ + $(info making $(@F)) + mkdir -p $(@D) + for entry in $(shell find $< -type f -name "*.md") ; do \ + sed -n '2,/^---$$/ {/^---$$/d; p}' "$$entry" |\ + sed -e 's/\[ //' -e 's/ \]//' |\ + tr -d '"' ;\ + printf "wordcount: %s\n" "$$(wc -w < $$entry)" ;\ + printf "file: %s\n\n" "$$entry" ;\ + done >> $@ + for entry in $(shell find $< -type f -name "*.md"); do \ + recset $@ -e "file = '$${entry}'" -f wordcount --set-add="$$(wc -w < $${entry})" ;\ + done + +db.rec: $(databases) printf '%s\n' '%rec: guide' > $@ printf '%s\n' '%type: wordcount int' >> $@ printf '%s\n\n' '%sort: title' >> $@ - for x in $^ ; do \ - sed -n '2,/^---$$/ {/^---$$/d; p}' "$$x" |\ - sed -e 's/\[ //' -e 's/ \]//' |\ - tr -d '"' ;\ - printf "file: %s\n\n" "$$x" ;\ - done >> $@ - for entry in $^; do \ - recset $@ -e "file = '$${entry}'" -f wordcount --set-add="$$(wc -w < $${entry})" ;\ - done + cat $^ >> $@ recsel $@ -e "requires != ''" -CR title,requires |\ while read title requires; do \ IFS=', ' && for provider in $$requires; do \ recset $@ -e "title = '$${provider}'" -f provides -a "$${title}" ;\ done ;\ done + $(info Created main database: $@) recfix --sort $@ default += db.rec @@ -41,13 +57,14 @@ database: $(default) ## Make a recfiles database .PHONY: article article: ## Write an article - @path=$$(find . -type d -printf '%P\n' | $(FZF)); \ - read -p "Title: " title; \ - printf '%s\n' '---' >> $$path/$$title.md ; \ - printf 'title: "%s"\n' "$$title" >> $$path/$$title.md ; \ - printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$title.md ; \ - printf '%s\n\n' '---' >> $$path/$$title.md ;\ - $(EDITOR) +5 $$path/$$title.md + @path=$$(find $(categories) -type d | sort | uniq | $(FZF)) ;\ + read -p "Title: " title ;\ + filename="$$(echo "$$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')" ;\ + printf '%s\n' '---' >> $$path/$$filename.md ;\ + printf 'title: "%s"\n' "$$title" >> $$path/$$filename.md ;\ + printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$filename.md ;\ + printf '%s\n\n' '---' >> $$path/$$filename.md ;\ + $(EDITOR) +5 "$$path/$$filename.md" .PHONY: clean clean: ## Remove all generated files diff --git a/README.md b/README.md index 99ce3df..be392c1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,19 @@ The Linux Knowledge-Base provides quick-start guides for working with terminal p Install `make`, `recutils`, and any fuzzy-finder (i.e. `sk`, `fzy`, or `fzf`). -Usage: `make` +## Usage + + +```sh +make +make database + +recsel db.rec -q database +recsel db.rec -q gpg +recsel db.rec -e "title = 'ssh'" +recsel db.rec -e "title ~ 'ssh'" +recsel db.rec -e "title ~ 'bash'" -R title,wordcount +``` # Style diff --git a/basics/Joyous_ASCII.md b/basics/Joyous_ASCII.md index 1c99a4e..3597ddb 100644 --- a/basics/Joyous_ASCII.md +++ b/basics/Joyous_ASCII.md @@ -6,7 +6,20 @@ tags: [ "fun" ] - `asciiquarium` - `cbonsai -lim "$(fortune)"` -```bash +```sh cow=$(cowsay -l | sort -R | head -1) fortune -s | figlet | cowsay -nf $cow | lolcat ``` + +Watch the [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) collapse: + +```sh +x="$(du -sc ~/.cache | tr -d '[:alpha:]' | tail -1)" +until [ "$x" -eq "1" ]; do + test "$(( x % 2 ))" -eq 0 && x=$(( x / 2 )) || \ + x=$(( x * 3 + 1 )) + clear -x + figlet "$x" | lolcat + sleep 1 +done +``` diff --git a/basics/at.md b/basics/at.md index 21d96bf..7584ba7 100644 --- a/basics/at.md +++ b/basics/at.md @@ -1,6 +1,6 @@ --- title: "at" -tags: [ "Basics" ] +tags: [ "Basics", "time" ] --- Install with: diff --git a/basics/basics.md b/basics/basics.md index 47a4f2e..57e9080 100644 --- a/basics/basics.md +++ b/basics/basics.md @@ -342,11 +342,12 @@ apt install $PROGRAM Remove `lolcat`, because it's useless: -```bash +```sh sudo apt remove lolcat ``` -... and that's pretty much it. You can move, create, destroy, install things, and look things up. +...and that's pretty much it. +You can move, create, destroy, install things, and look things up. # Review diff --git a/basics/clock.md b/basics/clock.md index 0f36e2a..c116310 100644 --- a/basics/clock.md +++ b/basics/clock.md @@ -1,6 +1,6 @@ --- title: "clock" -tags: [ "Basics" ] +tags: [ "Basics", "time" ] --- Show system time: diff --git a/basics/cron.md b/basics/cron.md index 98db527..439b07a 100644 --- a/basics/cron.md +++ b/basics/cron.md @@ -1,6 +1,6 @@ --- title: "cron" -tags: [ "Basics" ] +tags: [ "Basics", "time" ] --- # Cronie diff --git a/basics/locale.md b/basics/locale.md index 52014e9..fce6e33 100644 --- a/basics/locale.md +++ b/basics/locale.md @@ -1,6 +1,6 @@ --- title: "locale" -tags: [ "Basics" ] +tags: [ "Basics", "time" ] --- Your locale tells the computer your location, preferred time-and-date format, standard language, papersize, et c. diff --git a/basics/locating.md b/basics/locating.md index 338486d..644f3ae 100644 --- a/basics/locating.md +++ b/basics/locating.md @@ -6,59 +6,30 @@ tags: [ "Basics" ] `type` shows what kind of thing you're running, be it an alias, function, or binary program. -```bash -type cmus +```sh +type cd +type ls +type -P ls +type -a cat ``` ![where is cmus?](/tapes/which.gif) # Whereis the Program -Ask where the `angband` program is, along with all its configuration files: +Where is `grep` and all its configuration files? -`whereis angband` - -Also `which` shows where a binary file (the program) is, - -```bash -which cmus +```sh +whereis grep ``` -# Search Instantly with `plocate` +Which one of these is the binary file which you actually use? -You can search every file on the computer instantly by installing `plocate`. - -Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer. - -Check how big the database is: - -```bash -du -h /var/lib/plocate/plocate.db +```sh +which grep ``` -Once you have the database, you can find nearly any file instantly. +# More -- Search for gifs: `locate .gif` -- Search for gifs in the `/usr/` directory: `locate /usr/ .gif` -- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg` -- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'` - -For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md). - -## Search More Places - -`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go. - -Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`. - -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 -cat /etc/updatedb.conf -sudo sed 's#/mnt/##' /etc/updatedb.conf -sudo updatedb -plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$' -``` +- [Search instantly with `plocate`](data/search_system.md) diff --git a/basics/time.md b/basics/time.md index 157bc19..aec7a88 100644 --- a/basics/time.md +++ b/basics/time.md @@ -1,6 +1,6 @@ --- title: "time" -tags: [ "Basics" ] +tags: [ "Basics", "time" ] --- # systemd diff --git a/chat/profanity-otr.md b/chat/profanity-otr.md deleted file mode 100644 index 2f8bf6c..0000000 --- a/chat/profanity-otr.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "profanity" -tags: [ "Chat", "OTR" ] ---- -# otr - -'Off The Record' encryption seems mostly dead to me. -But this is what I did, back in the day... - -Install libotr-dev or libotr5-dev or whatever.. - -``` -sudo apt -y install lib5otr-dev -``` - -Make your otr keys. - -``` -/otr gen -``` - -Then you can start an otr converstation. - -``` -/otr start bob@jobbies.org -``` - -Or if you already have a conversation windows open, switch to our using: - -``` -/otr -``` - -Finally, verify! - -``` -/otr question "Who are you?" bob -``` - -Bob is verified upon the answer, 'bob'. - -### OTR Finger Prints - -Get yours with - -``` -/otr myfp -``` - -``` -/otr theirfp -``` - -``` -/otr myfp -``` - diff --git a/chat/wgetpaste.md b/chat/wgetpaste.md index 60fa074..27c800c 100644 --- a/chat/wgetpaste.md +++ b/chat/wgetpaste.md @@ -5,25 +5,25 @@ tags: [ "Chat" ] See available pastebins: -```bash +```sh wgetpaste -S ``` Upload script.sh to bpaste: -```bash +```sh wgetpaste -s bpaste script.sh ``` Input clipboard to dpaste with the heading "Title" -```bash +```sh wgetpaste -s dpaste -d Title -x ``` Paste in the file then load the result to the right-hand clipboard: -```bash +```sh wgetpaste -s dpaste -X ``` diff --git a/data/backups/archives.md b/data/backups/archives.md index 98a9c7e..2de1687 100644 --- a/data/backups/archives.md +++ b/data/backups/archives.md @@ -1,6 +1,6 @@ --- title: "Archives" -tags: [ "tar", "backups" ] +tags: [ "tar", "backups", ".tgz", "tar.gz" ] --- # `tar` diff --git a/data/backups/unison.md b/data/backups/unison.md index 262b64f..3108a45 100644 --- a/data/backups/unison.md +++ b/data/backups/unison.md @@ -1,6 +1,6 @@ --- title: "unison" -tags: [ "Backups" ] +tags: [ "Backups", "synch" ] --- Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems). diff --git a/data/gpg/extras.md b/data/gpg/extras.md index a36297d..981af5b 100644 --- a/data/gpg/extras.md +++ b/data/gpg/extras.md @@ -1,6 +1,7 @@ --- title: "gpg" tags: [ "vim", "data", "GPG" ] +requires: [ "GPG Basics", "vim basics" ] --- The `vim-gnupg` plugin lets vim edit gpg-encrypted files as if they were unencrypted. diff --git a/data/pdf_erasure.md b/data/pdf_erasure.md index 8329fa2..af97986 100644 --- a/data/pdf_erasure.md +++ b/data/pdf_erasure.md @@ -1,8 +1,11 @@ --- title: "PDF Metadata Erasure" -tags: [ "Metadata", "Ghost Script" ] +tags: [ "Metadata", "Ghost Script", "gs", ".pdf" ] --- +You cannot erase pdf metadata with `exiftool` (it only *appends* your changes). +To delete pdf metadata, you'll need `gs`. + Make a text file called 'pdfmark.txt'. diff --git a/data/recfiles/Board_Games.md b/data/recfiles/Board_Games.md index 91db4ca..4f158c6 100644 --- a/data/recfiles/Board_Games.md +++ b/data/recfiles/Board_Games.md @@ -1,6 +1,7 @@ --- -title: "Board Games" +title: "Board Games with Recfiles" tags: [ "data", "recfiles", "games" ] +requires: "Recfiles" --- You can play with a board games database from boardgamegeek.com. diff --git a/data/sc-im.md b/data/sc-im.md index e6f1c5c..7362fa7 100644 --- a/data/sc-im.md +++ b/data/sc-im.md @@ -1,6 +1,6 @@ --- title: "sc-im" -tags: [ "TUI", "data" ] +tags: [ "TUI", "data", "spreadsheet", ".csv" ] --- - [Sample file](sc-im/sample.sc) diff --git a/data/search_system.md b/data/search_system.md new file mode 100644 index 0000000..1d5f1a8 --- /dev/null +++ b/data/search_system.md @@ -0,0 +1,49 @@ +--- +title: "Search System" +tags: [ "data", "search", "locate", "plocate" ] +requires: "cron" +--- + +You can search every file on the computer instantly by installing `plocate`. + +Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer. + +Check how big the database is: + +```sh +du -h /var/lib/plocate/plocate.db +``` + +Once you have the database, you can find nearly any file instantly. + +- Search for gifs: `locate .gif` +- Search for gifs in the `/usr/` directory: `locate /usr/ .gif` +- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg` +- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'` + +For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md). + +## Search More Places + +`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go. + +Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`. + +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 +su root +cat /etc/updatedb.conf +sed -i 's#/mnt/##' /etc/updatedb.conf +updatedb +exit +``` + +Now you can search in `/mnt` for films: + +```sh +plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$' +``` + diff --git a/data/soft_https.md b/data/soft_https.md index 23e206b..fcdab9a 100644 --- a/data/soft_https.md +++ b/data/soft_https.md @@ -1,6 +1,6 @@ --- title: "Soft Serve through https" -tags: [ "data", "git", "lfs" ] +tags: [ "data", "git server", "lfs" ] --- ## `http` Setup diff --git a/data/taskwarrior/timew.md b/data/taskwarrior/timew.md index bc4e229..6ffa06f 100644 --- a/data/taskwarrior/timew.md +++ b/data/taskwarrior/timew.md @@ -1,6 +1,6 @@ --- -title: "timew" -tags: [ "Data" ] +title: "timewarrior" +tags: [ "Data", "tracking", "time", "timew" ] --- # Summaries diff --git a/distros/android/ssh_to_phone.md b/distros/android/ssh_to_phone.md index 081e2a1..470886c 100644 --- a/distros/android/ssh_to_phone.md +++ b/distros/android/ssh_to_phone.md @@ -8,7 +8,7 @@ tags: [ "networking", "ssh", "android" ] 3. Open fdroid, and run: -```bash +```sh pkg upgrade pkg install busybox termux-services openssh openssh-sftp-server source $PREFIX/etc/profile.d/start-services.sh diff --git a/distros/arch/fonts.md b/distros/arch/fonts.md index 9fef2f7..8ecf651 100644 --- a/distros/arch/fonts.md +++ b/distros/arch/fonts.md @@ -6,19 +6,20 @@ tags: [ "distros" ] Update font-cache: -```bash +```sh +su root fc-cache ``` List fonts: -```bash +```sh fc-list ``` Grab the part of the font name you need for Xresources: -```bash +```sh fc-list | cut -d: -f2 ``` diff --git a/distros/debian/apt.md b/distros/debian/apt.md index 4a972fe..73203a0 100644 --- a/distros/debian/apt.md +++ b/distros/debian/apt.md @@ -8,27 +8,27 @@ tags: [ "distros" ] Messed up a package's configuration files? -```bash +```sh sudo apt-get purge [thing] ``` -```bash +```sh sudo apt autoremove ``` Check if you still have related things: -```bash +```sh apt search [thing] ``` -```bash +```sh sudo apt-get install [ thing ] ``` Still have problems? -```bash +```sh sudo dpgk --force-confmiss -i /var/cache/apt/archives/[thing] ``` diff --git a/distros/void/aeroplanes.md b/distros/void/aeroplanes.md index 8e25a17..472a81a 100644 --- a/distros/void/aeroplanes.md +++ b/distros/void/aeroplanes.md @@ -4,15 +4,21 @@ tags: [ "Void" ] --- Put your device in 'aeroplane' mode (e.g. where no trace of signal leaves it) by turning off Wi-Fi and blue-tooth. -> sudo sv stop wpa_supplicant bluetoothd +```sh +su root +sv stop wpa_supplicant bluetoothd +``` Find your device's name with `ip a`. If unsure, try this: -> name=$(ip a | grep -Eo 'wlp\w{3}') - -> echo $name +```sh +name=$(ip a | grep -Eo 'wlp\w{3}') +echo $name +``` Then set that device down: -> sudo ip link set $name down +```sh +ip link set $name down +``` diff --git a/distros/void/extrace.md b/distros/void/extrace.md index d5b5bd0..72da239 100644 --- a/distros/void/extrace.md +++ b/distros/void/extrace.md @@ -4,19 +4,19 @@ tags: [ "Void" ] --- Monitor all processes: -```bash +```sh extrace ``` Monitor one process: -```bash +```sh extrace ls ``` Monitor a script: -```bash +```sh ./script.sh | extrace ``` diff --git a/distros/void/jenkins.md b/distros/void/jenkins.md index 1d2d14c..3e6ca20 100644 --- a/distros/void/jenkins.md +++ b/distros/void/jenkins.md @@ -9,16 +9,17 @@ Jenkins is janky. ## Start Start the service file. -```bash -sudo ln -s /etc/sv/jenkins /var/service -sudo sv start jenkins +```sh +su root +ln -s /etc/sv/jenkins /var/service +sv start jenkins ``` Then visit the web interface with `$BROWSER localhost:8080`. If it's not working, try running the command from the run file the first time: -```bash +```sh chpst -u jenkins java -jar /opt/jenkins/jenkins.war ``` diff --git a/distros/void/locale.md b/distros/void/locale.md index b11c43c..6f8d7e0 100644 --- a/distros/void/locale.md +++ b/distros/void/locale.md @@ -6,13 +6,13 @@ tags: [ "void", "locale" ] Check the current locales: -```bash +```sh locale -a ``` Add the languages you want by editing `/etc/default/libc-locales`, and uncommenting your choice: -```bash +```sh #en_DK.UTF-8 UTF-8 #en_DK ISO-8859-1 en_GB.UTF-8 UTF-8 @@ -25,13 +25,14 @@ Now you can generate what you need for those languages. However, instead of generating what you need, you're going to generate everything which needs updating: -```bash -sudo xbps-reconfigure glibc-locales +```sh +su root +xbps-reconfigure glibc-locales ``` Finally, select your chosen locale by placing it in `/etc/locale.conf`. -```bash +```sh echo "LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8" > /etc/locale.conf @@ -48,7 +49,7 @@ en_GB ISO-8859-1 Check your new locales are available: -```bash +```sh locale -a ``` diff --git a/hardware/brightness.md b/hardware/brightness.md index 0f01137..c8904ee 100644 --- a/hardware/brightness.md +++ b/hardware/brightness.md @@ -1,6 +1,6 @@ --- title: "brightness" -tags: [ "hardware" ] +tags: [ "hardware", "laptop" ] --- # Brightness diff --git a/hardware/monitor.md b/hardware/monitor.md index 98a46ac..8b32e0d 100644 --- a/hardware/monitor.md +++ b/hardware/monitor.md @@ -4,9 +4,13 @@ tags: [ "hardware" ] --- See screen size -> xrandr -q +```sh +xrandr -q +``` Automatically configure: -> xrandr --auto +```sh +xrandr --auto +``` diff --git a/sound/festival.md b/sound/festival.md index 4c054b9..9adade8 100644 --- a/sound/festival.md +++ b/sound/festival.md @@ -6,11 +6,11 @@ tags: [ "Sound" ] Add your user to the audio group, and install `festival-english`. -```bash +```sh echo "(Parameter.set 'Audio_Method 'Audio_Command)" >> /usr/share/festival/voices.scm ``` -```bash +```sh echo "(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")" /usr/share/festival/voices.scm ``` diff --git a/system/Makefiles.md b/system/Makefiles.md index 30f0c61..13557bb 100644 --- a/system/Makefiles.md +++ b/system/Makefiles.md @@ -1,6 +1,6 @@ --- title: "Makefiles" -tags: [ "system", "makefiles" ] +tags: [ "system", "make" ] --- The `make` system wants to know: @@ -11,7 +11,7 @@ The `make` system wants to know: Start with a basic test-area. -```bash +```sh mkdir make_test ; cd $_ printf "%s:\n" README.md > Makefile printf "\t%s\n" 'echo "Basic makefile example." > $@' >> Makefile @@ -32,8 +32,6 @@ README.md: Makefile echo '```' >> $@ cat $< >> $@ echo '```' >> $@ - - ``` Note the order: @@ -92,7 +90,7 @@ $(storage_directory)/README.md: README.md Now you can tell `make` to create the backup: -```bash +```sh make backups/README.md ``` diff --git a/system/Makefiles/graph-easy.md b/system/Makefiles/graph-easy.md index 04d1b9c..8c4d6d1 100644 --- a/system/Makefiles/graph-easy.md +++ b/system/Makefiles/graph-easy.md @@ -1,6 +1,6 @@ --- title: "Makefile Graphs" -tags: [ "system", "makefiles", "graph" ] +tags: [ "system", "make", "graph" ] --- If you have `graph-easy` (often in the package `perl-graph-easy` or similar), you can make a graph from the makefile with `make2graph` (the package is often called `makefile2graph`). diff --git a/system/Makefiles/help.md b/system/Makefiles/help.md index 028634a..e4f4cce 100644 --- a/system/Makefiles/help.md +++ b/system/Makefiles/help.md @@ -1,6 +1,6 @@ --- title: "Makefiles" -tags: [ "system", "makefiles", "help" ] +tags: [ "system", "make", "help" ] --- Make your first target 'help' to give an overview of the main targets. diff --git a/system/Makefiles/patterns.md b/system/Makefiles/patterns.md index d4df0d4..60290a1 100644 --- a/system/Makefiles/patterns.md +++ b/system/Makefiles/patterns.md @@ -1,7 +1,7 @@ --- title: "Makefile Patterns" -tags: [ "system", "makefiles" ] +tags: [ "system", "make" ] --- Using the [basic example](../Makefile.md), you can make a complete backup of all backup files. @@ -27,7 +27,6 @@ backups/backup.tgz: backups/backup_29.md backups/backup_30.md tar czf backups/backup.tgz backups/backup_29.md backups/backup_30.md ``` - The phony `backup` target should now point to this tar backup. diff --git a/system/awk.md b/system/awk.md index 84867d4..da50197 100644 --- a/system/awk.md +++ b/system/awk.md @@ -1,6 +1,6 @@ --- title: "awk" -tags: [ "System" ] +tags: [ "System", ".csv" ] --- # Basics diff --git a/system/bash_tricks.md b/system/bash_tricks.md index db8bd11..7fa4297 100644 --- a/system/bash_tricks.md +++ b/system/bash_tricks.md @@ -30,7 +30,7 @@ There are a bunch of files: Goal: swap the word "Column" for "Alice" in all files. -``` +```sh IFS=$'\n' for f in $(find . -name "Col*"); do mv "$f" $(echo "$f" | sed s/Column/Alice/) diff --git a/system/character-encoding.md b/system/character-encoding.md index b8d9c82..ad79380 100644 --- a/system/character-encoding.md +++ b/system/character-encoding.md @@ -1,26 +1,24 @@ --- title: "character-encoding" -tags: [ "System" ] +tags: [ "System", "encoding" ] --- + Convert a text file from one encoding type to another with: -```bash +```sh iconv -f ascii -t utf8 oldfilename > newfilename ``` Available options are: -* ISO-8859-15 - -* UTF-8 - -* ASCII - -* Lots more +- ISO-8859-15 +- UTF-8 +- ASCII +- Lots more Generate a full list of encoding types available with: -```bash +```sh iconv -l ``` diff --git a/system/deduplicate.md b/system/deduplicate.md index b9fbbac..150cba2 100644 --- a/system/deduplicate.md +++ b/system/deduplicate.md @@ -1,6 +1,6 @@ --- title: "deduplicate" -tags: [ "system", "deduplicate", "duplicates", "maintenance" ] +tags: [ "system", "deduplicate", "maintenance", "storage" ] --- `rdfind`: find duplicate files, then delete them, or turn them into links. diff --git a/system/editors.md b/system/editors.md index c940aaf..03eb874 100644 --- a/system/editors.md +++ b/system/editors.md @@ -1,27 +1,24 @@ --- title: "$EDITOR" -tags: [ "System" ] +tags: [ "system" ] --- The System's default text editor can be defined within /etc/profile. It's given the variable `EDITOR`. -Add these lines to `/etc/profile.d/local.sh`: - -``` - -export EDITOR=vim - -export VISUAL=$EDITOR +Add these lines to `/etc/profile.d/custom.sh`: +```sh +echo 'export EDITOR=vim' >> /etc/profile.d/custom.sh +echo 'export VISUAL=$EDITOR' >> /etc/profile.d/custom.sh ``` Then reload that profile with: -```bash +```sh source /etc/profile ``` If you want to ensure `nano` never appears again: -```bash +```sh sudo ln -sf $(which vim) $(which nano) ``` diff --git a/system/fstab.md b/system/fstab.md index 9ec1f11..b5d749c 100644 --- a/system/fstab.md +++ b/system/fstab.md @@ -1,6 +1,6 @@ --- title: "fstab" -tags: [ "System" ] +tags: [ "system", "disk" ] --- # Basics @@ -29,7 +29,7 @@ Ignore this obsolete option. ## 6: Pass | Number | Meaning | -| | | +|:------:|:---------------------:| | 0 | Swap (or not mounted) | | 1 | Mount at / | | 2 | Mount somewhere else | @@ -37,5 +37,5 @@ Ignore this obsolete option. ## Options - `nofail` means the computer will not fail to boot, even if the drive fails, or is unplugged. It's a good option for everything except `/`. -- noauto means 'don't mount on boot' (but you can still mount with `mount -a`). +- `noauto` means 'don't mount on boot' (but you can still mount with `mount -a`). diff --git a/system/kernel.md b/system/kernel.md index c0a5569..913fa62 100644 --- a/system/kernel.md +++ b/system/kernel.md @@ -1,41 +1,41 @@ --- title: "kernel" -tags: [ "System" ] +tags: [ "system" ] --- -Check which kernet modules are loaded into memory -```bash -sudo /sbin/lsmod +Check which kernel modules are loaded into memory: + +```sh +su root +/sbin/lsmod ``` Check which virtual box modules are loaded into memory -```bash -sudo /sbin/lsmod | grep vbox +```sh +/sbin/lsmod | grep vbox ``` Virtual box is using vboxpci, vboxnetadp, vboxnetflt, vboxdr. Look at what's claiming wifi: -```bash -sudo lshw -C network +```sh +lshw -C network ``` If this shows that the device is 'unclaimed' then it's time to add a module, e.g. ath9k. -```bash -sudo modprobe ath9k +```sh +modprobe ath9k ``` Modules can also be 'restarted' by removing and adding them, e.g. the video module, 'uvcvideo': -```bash -sudo rmmod uvcvideo +```sh +rmmod uvcvideo ``` -```bash -sudo modprobe uvcvideo +```sh +modprobe uvcvideo ``` - - diff --git a/system/lf.md b/system/lf.md index 5169a50..b617451 100644 --- a/system/lf.md +++ b/system/lf.md @@ -1,6 +1,6 @@ --- title: "lf - The Light File Manager" -tags: [ "File Browser" ] +tags: [ "File Browser", "TUI" ] --- ![lf](/tapes/lf.gif) diff --git a/system/mdadm.md b/system/mdadm.md index 003f78e..23c98ca 100644 --- a/system/mdadm.md +++ b/system/mdadm.md @@ -1,6 +1,6 @@ --- title: "mdadm" -tags: [ "RAID" ] +tags: [ "RAID", "disk" ] --- # RAID5 diff --git a/system/monitoring.md b/system/monitoring.md index 6cbd163..984e6ab 100644 --- a/system/monitoring.md +++ b/system/monitoring.md @@ -15,6 +15,7 @@ Show memory usage in Gibitytes. ```bash free -g ``` + Show low and high gigibtye usage on a *l*ine, and repeat the measurement every 5 seconds: ```bash diff --git a/system/partitions.md b/system/partitions.md index 5e553a2..d12193c 100644 --- a/system/partitions.md +++ b/system/partitions.md @@ -2,10 +2,12 @@ title: "partitions" tags: [ "System" ] --- + # FDisk Basics -```bash -sudo fdisk /dev/sda +```sh +su root +fdisk /dev/sda ``` - m for help. @@ -31,20 +33,20 @@ fdisk will not help with a GPT formatted drive. For this, use gdisk, which is m Now that we have a partition, we can make it into a fileSystem. Most will use: -```bash -sudo mkfs -t ext4 /dev/sdc1 +```sh +mkfs -t ext4 /dev/sdc1 ``` or if you're making a swap partition, you can use: -```bash -sudo mkswap /dev/sdb2 +```sh +mkswap /dev/sdb2 ``` or for the reiser fileSystem, we can use: -```bash -sudo mkreiserfs /dev/sdc2 +```sh +mkreiserfs /dev/sdc2 ``` # File System Types @@ -61,86 +63,86 @@ sudo mkreiserfs /dev/sdc2 # Parted -```bash -sudo parted /dev/sdb +```sh +parted /dev/sdb ``` # Monitoring Look at physical and virtual partitions: -```bash +```sh df -h ``` or divide things by inode - the thing which records where files are? -```bash +```sh df -i ``` Examine a fileSystem with: -```bash -sudo dumpe2fs /dev/sda1 | less +```sh +dumpe2fs /dev/sda1 | less ``` # Prevention There are multiple programs which work mostly the same way. -```bash -sudo tune2fs -c 30 /dev/sda1 +```sh +tune2fs -c 30 /dev/sda1 ``` This will check sda1 every 30 boots. It can also be checked every month. -```bash -sudo tune2fs -i 1m /dev/sda1 +```sh +tune2fs -i 1m /dev/sda1 ``` This thing can also make a new label for the System: -```bash -sudo tune2fs -L new_name /dev/sdb3 +```sh +tune2fs -L new_name /dev/sdb3 ``` # Repair Start by unmounting the fileSystem. -```bash -sudo umount /dev/sdc1 +```sh +umount /dev/sdc1 ``` Then it's time to check. -```bash -sudo fsck /dev/sdc1 +```sh +fsck /dev/sdc1 ``` And possibly repair damage: -```bash +```sh e2fsck -p /dev/sdc1 ``` or the same with: -```bash -sudo debugfs /dev/sdc1 +```sh +debugfs /dev/sdc1 ``` # Mounting You can mount with a specified filetype with: -```bash -sudo mount -t ext3 /dev/sdc2 /mnt/stick +```sh +mount -t ext3 /dev/sdc2 /mnt/stick ``` or if you don't know the type, just try the lot: -```bash -sudo mount -a /dev/sdc1 /mnt/stick +```sh +mount -a /dev/sdc1 /mnt/stick ``` # File Systems @@ -152,35 +154,35 @@ NB: When I followed these instructions, the process destroyed my data. Seemed fi Check the fileSystem's health: -```bash -sudo e2fsck -f /dev/sdb1 +```sh +e2fsck -f /dev/sdb1 ``` Resize the file System to something smaller than what you want, so here I want 500G and so I resize to 450 G. -```bash +```sh resize2fs /dev/sdb1 450G ``` Then delete the partition with either gdisk or fdisk, depending upon the layout. -```bash -sudo fdisk /dev/sdb +```sh +fdisk /dev/sdb ``` -```bash +```sh d ``` Then make a new fileSystem of the desired type with: -```bash +```sh n ``` And finally resize to the full size you want: -sudo resize2fs /dev/sdb1 +resize2fs /dev/sdb1 And then check your disk again with e2fsck. @@ -193,20 +195,18 @@ Let's start with names. PV = 'Physical Volume', VG = 'Volume Group', and LV = ' Now we can create a volume group out of sdb2 and sdc3: -```bash -sudo vgcreate my-new-vg /dev/sdb2 /dev/sdc3 +```sh +vgcreate my-new-vg /dev/sdb2 /dev/sdc3 ``` Then make a new logical volume out of the volume group: -```bash -sudo lvcreate -n my-new-lv my-new-vg +```sh +lvcreate -n my-new-lv my-new-vg ``` Then have a look at all logical volumes: -```bash -sudo lvscan +```sh +lvscan ``` - - diff --git a/system/swap.md b/system/swap.md index 5123187..5a06084 100644 --- a/system/swap.md +++ b/system/swap.md @@ -4,49 +4,47 @@ tags: [ "basics" ] --- # Making a Swap File -```bash +```sh +su root cd /var/cache/ -``` - -```bash -sudo dd if=/dev/zero of=swapfile bs=1K count=4M +dd if=/dev/zero of=swapfile bs=1K count=4M ``` This creates a swapfile of (1k x 4M) 4 Gigs. Change 4M to XM for an XGig swap. -```bash -sudo chmod 600 swapfile +```sh +chmod 600 swapfile ``` -```bash -sudo mkswap swapfile +```sh +mkswap swapfile ``` -```bash -sudo swapon swapfile +```sh +swapon swapfile ``` Test it's working with top -```bash +```sh top -bn1 | grep -i swap ``` or: -```bash -echo "/var/cache/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab +```sh +echo "/var/cache/swapfile none swap sw 0 0" | tee -a /etc/fstab ``` Test it'll work at boot with: -```bash -sudo swapoff swapfile +```sh +swapoff swapfile ``` -```bash -sudo swapon -va +```sh +swapon -va ``` # Partition Swaps @@ -57,13 +55,13 @@ Put this in /etc/fstab: Then test it works with: -```bash -sudo swapon -va +```sh +swapon -va ``` Test other partitions in fstab with: -```bash -sudo mount -a +```sh +mount -a ``` diff --git a/system/tmux.md b/system/tmux.md index a666031..5caa672 100644 --- a/system/tmux.md +++ b/system/tmux.md @@ -1,10 +1,10 @@ --- title: "tmux" -tags: [ "System" ] +tags: [ "system" ] --- Start with: -```bash +```sh tmux ``` @@ -34,21 +34,21 @@ In addition to Windows, there are panes. Crate a new session with the name 'backup'. -```bash +```sh tmux new -s backup ``` List sessions: -```bash +```sh tmux list-sessions ``` -```bash +```sh tmux kill-session -t 2 ``` -```bash +```sh tmux attach -t backup ``` diff --git a/virtualization/docker.md b/virtualization/docker.md index ba92228..2e2acca 100644 --- a/virtualization/docker.md +++ b/virtualization/docker.md @@ -2,21 +2,21 @@ title: "Docker" tags: [ "documentation", "Virtualization" ] --- -```bash +```sh sudo pacman -S docker ``` -```bash +```sh sudo usermod -aG docker $USER ``` -```bash +```sh sudo systemctl start docker ``` You need to either log out and back in again to be in the docker group, or run everything as root. -```bash +```sh # docker info ``` @@ -24,19 +24,19 @@ This should show you things are working. Search for a distro you want -```bash +```sh docker search debian ``` If you get a hit, pull it. -```bash +```sh docker pull debian ``` Then run a live image: -```bash +```sh docker run -it debian ``` @@ -44,13 +44,13 @@ docker run -it debian Check currently running containers with -```bash +```sh docker ps ``` Check all containers with -```bash +```sh docker ps -a ``` @@ -58,7 +58,7 @@ Now we can get a list of all containers. To delete one, take the id, e.g. '97796727e883', and run: -```bash +```sh docker rm 97796727e883 ``` @@ -66,7 +66,7 @@ docker rm 97796727e883 Get a list of docker container ips -```bash +```sh docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' *container_name_or_id* ``` diff --git a/virtualization/virtualbox.md b/virtualization/virtualbox.md index e7ec7fd..01b0daf 100644 --- a/virtualization/virtualbox.md +++ b/virtualization/virtualbox.md @@ -6,27 +6,27 @@ tags: [ "System" ] ## Arch Linux -```bash +```sh sudo pacman -S virtualbox-host-modules-arch virtualbox-guest-iso ``` -```bash +```sh sudo modprobe vboxdrv ``` -```bash +```sh # vboxreload ``` Make dd image into vdi -```bash +```sh VBoxManage convertdd base.dd output.vdi --format VDI ``` If this doesn't work, try to make a new bite size with just -```bash +```sh sudo dd if=image.dd of=image2.dd bs=512 conv=sync ``` @@ -34,19 +34,19 @@ sudo dd if=image.dd of=image2.dd bs=512 conv=sync List boxes: -```bash +```sh VBoxManage list vms ``` Start a headless instance -```bash +```sh VBoxManage startvm "rata" --type headless ``` To pause the machine: -```bash +```sh VBoxManage controlvm "rata" pause --type headless ``` @@ -64,15 +64,15 @@ You can do a number of things to virtualboxes this way: Creating a VM requires registering it: -```bash +```sh VBoxManage createvm --name Ubuntu19.04 --register --ostype Ubuntu ``` -```bash +```sh VBoxManage modifyvm Ubuntu19.04 --memory 1042 ``` -```bash +```sh VBoxManage storagectl Ubuntu19.04 -name IDE --add ide --controller PIIX4 --bootable on ``` diff --git a/virtualization/xen/xen_basics.md b/virtualization/xen/xen_basics.md index b960782..950caba 100644 --- a/virtualization/xen/xen_basics.md +++ b/virtualization/xen/xen_basics.md @@ -5,15 +5,15 @@ tags: [ "xe", "virtualization", "volume" ] # Make a local iso repository -```bash +```sh STORE_PATH=/var/opt/xen/ISO_Store ``` -```bash +```sh mkdir -p $STORE_PATH ``` -```bash +```sh xe sr-create name-label="$STORAGE_NAME" type=iso device-config:location=$STORE_PATH device-config:legacy_mode=true content-type=iso ``` @@ -23,7 +23,7 @@ This creates a UUID for the new directory: # Main Console -```bash +```sh xsconsole ``` @@ -31,13 +31,13 @@ xsconsole List volumes: -```bash +```sh lvs ``` List groups: -```bash +```sh vgs ``` diff --git a/vision/lowdown.md b/vision/lowdown.md index 408a415..0e5e854 100644 --- a/vision/lowdown.md +++ b/vision/lowdown.md @@ -5,21 +5,21 @@ tags: [ "Markdown", "PDF", "Vision" ] Turn a markdown file into a pdf: -```bash +```sh lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf ``` *Example:* put [this Makefile](lowdown/example.txt) in a directory, rename it `Makefile`, then do: -```bash +```sh make example make ``` To give the document a title, put that title in the metadata: -```bash +```sh sed -i "1 i---" "$FILE".md sed -i "1 ititle: $TITLE" "$FILE".md sed -i "1 i---" "$FILE".md