Slackware notes
===============
"When in doubt use brute force" --Ken Thompson
"I'm in the camp where if something works properly then there's no need
to rock the boat. If there's a known issue, you know where to find me"
--Patrick Volkerding
"...the only maintenance task I have to do is keeping the machines up to
date and changing the toner cartridges on the printers. That's what is
meant by 'stable'." -- kikinovack
http://slackware.uk/slackware/slackware-14.1/Slackware-HOWTO
http://www.slackware.com/changelog/stable.php?cpu=i386
http://www.slackware.no/ # weekly -current 32bit iso
One liners
----------
tar xvfz archive.tar.gz # unpack tar.gz file
tar xvjf archive.tar.bz2 # unpack archive.bz2 file
tar -zcvf archive.tar.gz folder # packs folder and all of its contents into a tar.gz file. s
tar xfv archive.anytype # tar can guess compression types! Unpacks any tar.whatever
for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done # untar all .tar.gz files in a directory
split -b 1000m somefile # splits a large file into 1Gb chunks for burning to dvd. Chunks named xaa, xab ...
cat x* > somefile # joins the files produced by the split command
ffmpeg -i v.mp4 -vn -ab 128k a.mp3 # extract mp3 audio from mp4 video file
grep -Po '(?<=href=")[^"]*' file.html # prints everything after href=" until a new double quote appears
wget -nc -i list.txt # downloads all the files in list.txt without duplicating files that are already downloaded
telnet telnet.wmflabs.org # Set terminal character type to UTF-8 and you have the whole of wikipedia to read on the train...
for i in *.mp3; do mpg321 -w "`basename "$i" .mp3`".wav "$i"; done # converts all the mp3s in the current folder to wavs
wget -r -nH --no-parent --reject=index.html* --cut-dirs=1 --no-clobber http://slackware.uk/slackware/slackware-14.2/patches/packages/ # fetch upgrades
for f in *\ *; do mv "$f" "${f// /_}"; done # replaces spaces in filenames with underscores - includes subdirectories
rsync -av --exclude=x86 --delete rsync://slackware.uk/slackware/slackware64-14.2/patches/packages/ . # Downloads the contents of the patches directory to current directory. Note trailing dot.
rsync -av --delete rsync://slackware.uk/slackware/slackware-14.1/patches/packages/ . # updates the 14.1 i686 installations
lynx -dump -hiddenlinks=listonly http://www.gardnermuseum.org/music/listen/music_library?filter=composer | grep http://traffic.libsyn.com/gardnermuseum | cut -c 7- > a.txt # pulls out all links to CC licenced mp3 files on the Isabella Stewart Gardner Museum music library page
wget -nc -i a.txt --wait=60 # used with above command to download only newly added mp3 files
sed '/pattern/d' ./infile # prints file to terminal with all lines that match pattern removed
pdfmom -etp mybook.mom > mybook.pdf # processes a text file containing groff_mom macros, text, pictures, tables and mathematical equations into a pdf file using groff
man -t command > command .ps # exports the man page for command to ps file
echo $(uname -n)-$(date +%Y%m%d) # machine name and current date in a form suitable for naming e.g. incremental backups
ls /var/log/packages | grep openoffice | tr '\n' ' ' > oneline.txt # generate a list of the Apache OpenOffice files so that I can cat the file and copy the output as argument to removepkg
find . -maxdepth 1 -name "*string*" -print # lists file names that match string. Omit maxdepth for recursive search
openssl rand -base64 12 | grep ^[a-zA-Z0-9]*$ # generate a 12 character password with no funny symbols
head -c 1000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n 10 # generate 10 lines of 15 random alphanumeric characters
rsync -rtvu --modify-window=1 --delete --progress /home/keith/folder/ /media/keith/Elements/folder # rsync command line to sync a folder from ext4 linux drive to ntfs external drive
find . -type f -name '*pattern*' -delete # removes all files that match pattern recursively starting from here. Handy for message files of deleted programs in /usr/share/locale
echo "It seemed like a good idea at the time" | sed 's/\s/\n/g' | sed 's/./\u&/' | awk '{ printf "%s\n", substr($1,1,2) }' | tr -d '\r\n' && echo "" # prints first two chars of each word in a string with first letter capitalised. If one letter word, just prints one character
find /var/log/packages/ -type f -printf '%T+ %p\n' | sort -nr | head # lists most recent 10 installed packages so you know when you last updated
man ksh | col -bx > ksh.txt # man recognises the pipe and dumps txt col clears the control characters for bold &c
montage +frame +shadow +label -tile 3x3 -geometry 150x200+0+0 *.jpg post.jpg # resize Nokia images from 1200 wide 1600 high to 150x200 and tile in a 3x3 array using ImageMagick's montage command.
sleep 10 && xwd -root -silent | convert xwd:- png:screen2.png # screenshot (needs imagemagic)
rsync -rtvu --modify-window=1 --exclude=".*" --delete --progress /home/keith/ /run/media/keith/52695A6F6816ABA4/X61s/ # backup home directory (sans dots) to external ntfs format hard drive
sed -e 's/^/prefix/' file > file.new # prefix each line in a file
csplit notes.md /===/-1 {*} # Split a markdown file with == headings into separate files.
csplit -f prefix 3600.txt '/KEYWORD/' '{*}' # splits a long text file into chunks starting with KEYWORD and prefixed by prefix
sed '$!N;/.*\n.*====.*/P;D' notes.md # prints line above a match (not consecutive matches)
sed ':a;N;$!{/\n$/!ba}; s/[[:blank:]]*\n[[:blank:]]*/ /g' wrapped.txt > unwrapped.txt # wrapped has paragraphs of text wrapped at col 80 or wherever separated by blank lines, unwrapped will have paragraphs ending in a single new line
pandoc -t html -s input.odt -s -o output.html # convert an odt to relatively clean html. Not sure about images, objects &c
ntpdate pool.ntp.org # sync the local hardware clock to network time one off
sed 's/^/prefix/; s/$/postfix/' file.txt # add a prefix and a postfix to each line in a file
sed -i 's/[.,;!?] */&\n/g' file # splits each line in the file on punctuation 'semantic linebreaks'. Use fmt to return to formatted text.
sed -e 's/\([.?!]\) \{2,\}/\1 /g' file # fixes fmt two spaces after fill stop. You can pipe the output of fmt into sed.
tar -czpf /var/tmp/home.tgz . # tar up your whole home drive including dotfiles
tar --exclude='./Music' --exclude='./Pictures' --exclude='./*.iso' -czpf /var/tmp/home.tgz . # tar up dotfiles and exclude some directories
tar xvf home.tgz # copy mytar.tgz to /home/user and then untar to restore dotfiles and data
tar -cvf mydirectory.tar mydirectory # just tar up directory no compression. Good for images or binary package files
setxkbmap -option caps:escape # make the caps lock key a second escape for vi or mg in OpenBSD or anywhere
setxkbmap -layout gb # English UK keyboard layout
magick mogrify -resize 512x512 -quality 100 -path small *.jpg # generates resized copies of all jpg files in current directory into a sub-directory called 'small'
ls -t | awk 't {if ($0 == l) print "..."; exit} NR == 5 {l = $0; t = 1} 1' # list files with the five most recent distinct modification times
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum | sort -k 2 > checksums_`date +%Y-%m-%d`.md5 # searches current (.) directory recursively and calculates a checksum for each file in every subdirectory or in the directory. Can be used to check for bitrot over years. Ignores .md5 files
lynx -dump -listonly k58.uk | cut -c 6- | sed 's/http:/https:/' | grep 'k58.uk' > sitemap.txt # one-liner to make a sitemap from the index page on k58.
November 13th 2024
------------------
sdf's gopher space.
Text files need 644 permissions, and directories need 755 permissions.
Entries in a gophermap need an actual tab character between description
and location. I've not sorted if each directory needs its own gophermap
yet, or if you can have one gophermap at root and just list directory
contents.
November 10th 2024
------------------
xfce4 version 4.12 on Slackware 15.0
https://www.linuxquestions.org/questions/slackware-14/this-is-my-slackware-desktop-725754/page355.html#post6537448
'backleveled' to xfce version 4.12 (last GTK2) with selection of
libraries that need adding. Also some compiler errors with newer
compilers but not sure if those are with the xfce.
Algol 68 compiler
> "While many of the delegates presented papers that discussed the
> difficulty of implementation of the new language, the small team from
> the Royal Radar Establishment presented their working compiler for a
> substantially complete subset of the language that they called Algol
> 68-R [ Wikipedia-2 ]. Algol68-R was already in daily use for
> production code on the ICL 1907F computer at RRE, where it had
> replaced Algol 60 for new development. The Algol 68-R compiler was
> later distributed without charge by ICL to other users of 1900-series
> hardware, and it was this compiler that I first used when I went to
> University."
A later version of this compiler might have been in use at Warwick
University's computer centre in 1976.
October 11th 2024
-----------------
Moto g14 cheapie android for taking pics in whitby
https://www.reddit.com/r/MotoG/comments/16p5d4p/moto_g14_screen_keeps_waking_up_randomly_every/
To stop the screen switching on when you move the phone or touch the
screen you have to:
1) Switch Ambient Display on and disable 'turn on touch screen'
2) Switch Ambient Display off again (rolleyes)
3) Switch Lift to Wake off
Then the screen won't come on until you short press the power button and
sanity is regained.
September 29th 2024
-------------------
Reduce computer algebra package installed from the most recent
snapshot rpm. I use the Codemist Standard Lisp implementation.
redcsl invokes a GUI repl by default.
This GUI is implemented using the fox toolkit which is quite nice
light and cross platform BUT the default font sizes are tiny even on
a 1366x768 screen. There is a font size setting for the font used in
the repl but not in the font used in the GUI widgets (menu 'bar'
which is actually buttons and the associated menus).
https://sourceforge.net/p/foxgui/mailman/message/14874756/
The foxgui-users mailing list came up with a work-around.
Add the following to the settings file at
~/.foxrc/Codemist/reduce
[SETTINGS]
normalfont=helvetica,140,medium,roman,normal,iso8859-1
If the Xorg bitmap font you happen to use is not available, the
application will just segfault. I needed to experiment a bit, but
the above worked on Fedora 21 under Gnome/Wayland presumably under
xwayland. So it appears that 'normalfont' provides the base font for
all the widgets.
September 20th 2024
-------------------
Idea for occ25: emacs.
https://karthinks.com/software/batteries-included-with-emacs/
https://old.reddit.com/r/emacs/comments/1f44evi/its_fine_to_use_plain_emacs_and_a_simple_config/?rdt=54353
I'm using Gnome Shell 47 on Fedora 41 Beta for lutz.
Noticebly faster in desktop but heavy on the ram.
September 12th 2024
-------------------
$ cat ~/bin/ospl
# This command breaks a paragraph with hard line breaks
# into one clause per line (sentence, comma or question mark)
# It only replaces punctuation with at least one space after
# so 'this gets matched. As it should' but 'C.A.T. ' only
# gets matched after the final full stop.
# It reverses the effect of fmt
# Meant for use with }!ospl from nvi
tr '\n' ' ' | sed "s/[.,;?] [ ]*/\0\n/g"
$
See sed&awk p40
August 28th 2024
----------------
Current .exrc when using vim.tiny to provide vi
set showmode
set showmatch
set ruler
set shiftwidth=4
set tabstop=4
"set verbose
"set leftright (not sure if I want wrap or scroll so I try both)
map #4 !}fmt^M
map #5 !}ospl^M
map ; :
"this might sort out the arrows in insert mode in vim.tiny
map! ^[OA ^[ka
map! ^[OB ^[ja
map! ^[OC ^[la
map! ^[OD ^[ha
Remember that ^M is 'Ctrl-V and a new line' and ^[ is 'Ctrl-V and Escape
key' not just the characters as printed.
Alas using vim.tiny loses the infinite undo capacity of nvi (u to undo
then . to repeat undo)
August 26th 2024
----------------
Cinnamon DE set critical battery action to suspend and change time
Installed Mint LMDE 6 (Faye) on x220.
The critical battery settings did not by default include suspend, so
I added it as follows;
https://forums.linuxmint.com/viewtopic.php?f=42&t=302573&hilit=power#3
edit /usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
as root and alter the 'critical_options' python statement (a fair way down the file) to read
critical_options = [
("shutdown", _("Shutdown immediately")),
("hibernate", _("Hibernate")),
("suspend", _("Suspend")),
("nothing", _("Do nothing"))
]
Basically adding the line '("suspend", _("Suspend")),'. Go to settings
Power Manager and you'd find Suspend as an option.
Then increase the default battery life to trigger critical actions from
420 second to 1800 seconds (7 mins to 30 mins) so you have time to find
a mains plug. 30 mins on normal is about 6 to 8 hours on suspend.
Nice to see a setting from Cinnamon 19 still working.
Documents: make a draft script in ~/bin
Current state of mkdrft
keith@x220:~$ cat ~/bin/mkdrft
#! /bin/sh
# Variables
dir=$PWD/drafts
file="$1"
date=$(date -I)
# Test for drafts directory in current directory
# and it it isnt there create it
if [ ! -e $dir ]; then
mkdir $dir
elif [ ! -d $dir ]; then
echo "$dir already exists but is not a directory"
fi
# Make a copy of $file inside drafts with date added to
# end of file name
cp $file $dir/$file"-"$date
keith@x220:~$
Basic: it allows over writing of drafts with same date. But at least it
catches directory not there or a file of same name. Works fine in test
directory.
August 22nd 2024
----------------
https://christian.amsuess.com/tools/arandr/
Just installed arandr to help with external monitors.
xfig has very small bitmap fonts hard coded.
A 1280x1024 large monitor will help.
But also
xrandr --output LVDS-1 --scale 0.8x0.8
and
xrandr --output LVDS-1 --scale 1x1
The first command line zooms in so xfig looks 25% larger which is fine
The second command reverts to 100% scale.
Also
for simple two monitor setups
August 21st 2024
----------------
IceWM on OpenBSD installed with the helpers including icewmbg from
packages.
My changed preferences...
home/keith/.config/icewm/preferences <
foo$ grep -v '^\#' /home/keith/.config/icewm/preferences | grep -v '^$'
TaskBarShowCPUStatus=0 # 0/1
TaskBarShowWorkspaces=0 # 0/1
TaskBarWorkspacesLimit="1"
TimeFormat="%H:%M"
WorkspaceNames=" 1 "
ActiveTaskBarFontNameXft="DejaVu Sans:size=10:bold"
ClockFontNameXft="DejaVu Sans Mono:monospace:size=10"
ColorClock="rgb:C0/C0/C0"
ColorClockText="rgb:00/00/00"
NormalTaskBarFontNameXft="DejaVu Sans:size=10"
TitleFontNameXft="DejaVu Sans:size=10"
DesktopBackgroundColor="teal"
I'm using the Win95 theme with teal background colour for giggles.
It works very nicely and is quite light on memory and the processor.
August 20th 2024
----------------
Below is contents of ~/.xpdfrc
That file works on Xpdf version 4 (the QT one) and means I can not have
the side bar and the strange scrolling mode. OpenBSD has the man xpdfrc
man page with all options, and the man xpdf page COMMANDS section has
the commands available.
initialDisplayMode single
initialSidebarState no
initialSelectMode block
popupMenuCmd "Zoom to selection" zoomToSelection
popupMenuCmd "Zoom fit page" zoomFitPage
popupMenuCmd "Zoom fit width" zoomFitWidth
popupMenuCmd Reload reload
OpenBSD ~/.profile back2stick
alias back2stick='rsync -rtvu --modify-window=1 \
--exclude=".*" \
--exclude="*.iso" \
--exclude="*.img" \
--exclude="*.core" \
--exclude="usb" \
--progress --delete \
/home/keith/* /home/keith/usb/obsd75-home/'
That alias will copy contents of ~/keith to external stick mounted on
~/usb. Excluding big stuff like iso and img files and the odd core dump
from Chromium.
I need to get a 16 or 32Gb usb drive.
August 19th 2024
----------------
echo "This is a sentence with *two words* emphasised" | sed 's/ \*/ \\fI/' | sed 's/\* /\\fR /'
Ugly but it works. Might allow emphasis to span two lines as well as
separate patterns for start of emphasis (asterisk preceeded by a space)
and for end (asterisk succeeded by a space).
cat bread.ms | sed 's/^$/.PP/' | sed 's/ \*/ \\fI/' | sed 's/\* /\\fR /' | groff -T pdf -ms > b.pdf
If I put the sed lines above into a script file and use them as a
filter, and add sed lines for **strong** and `code` then that is a chunk
of markup already done. Just need to disable the matching inside the
preprocessor requests like .EQ....EN.
So far I have this...
foo$ cat mrk.sh
cat $1 | # useless use of cat?
sed 's/^$/.PP/' | # put paragraph request in each blank line
sed 's/ \*/ \\fI/' | # space-* = start of italics
sed 's/\* /\\fR /' | # *-space = end of italics
sed 's/^\# /.NH 1\
/' # OpenBSD sed won't allow \n in substitution so literal new line
I'll add in the other character styles and the rest of the headings
tommorrow.
Note from the future
echo "This *might* be a *sentence*. And *this*?" \
| sed 's/\([.? ]\)\*/\1\\fI/g' | sed 's/\*\([.? ]\)/\\fR\1/g'
Capture expressions or 'backreferences' (but not actually).
The [.? ] means match either of a full-stop, a question mark or a space.
The \([.? ]\) 'captures' this match as \1 (you can have up to \9 of these)
The replacement part prints what you captured as \1 and what you want to replace it with
It is the second sed that is important...
sed 's/\*\([.? ]\)/\\fR\1/g'
's/matched expression/substitution/g'
The matched expression is \* (an asterisk) and [.? ] any of . or ? or a space.
The \(part\) bit of the matched expression is stored as \1
The g on the end says not to stop after first match on a line.
The substitution is \\fR first (need \\ because we want a literal \ printed)
then whatever we stored in the substitution \1 gets printed
So: thing*. -> thing/fR.
And that*? -> that/fR?
And something* else -> something/fR else
Problem: how do I include punctuation in the emphasis?
Cross that bridge &c
August 18th 2024
----------------
Reddit for heavens sake - nowt on stackoverflows
https://old.reddit.com/r/bash/comments/17twwyv/how_to_remove_single_new_lines_from_the_end_of_a/
awk '
NF { printf sep "%s", $0; sep = ""; next }
{ sep = "\n\n" }
END { printf "\n" }
' filename
Above fragment takes a text file with paragraphs with hard breaks
(single new line) at the end of each line and a blank line between
paragraphs and renders it as a single line for each paragraph but
preserves the blank line between paragraphs. Exactly what I want for the
markdownish -> ms converter that I want to hack up.
Then blank line -> .PP
Line starting with * after a blank line but with space following * -> .IP "\[bu]" 0.25i
Word in a line starting with * like *emphasis -> \fI
Word in a line ending with * like emphasis* -> \fR
And **strong -> \fB with strong** -> \fR
And `words -> \fC with words` -> \fR
Above will need to trap no space after * | ** | ` to avoid list at line start
Line starting with # words -> .NH 1 \n words \n .LP supressing .PP
Line starting with ## words - .NH 2 \n words \n .LP supressing .PP
Line starting with ### words - .NH 3 \n words \n .LP supressing .PP
And then
Line starting with .EQ | .TS | .PS | .RS | .G1 -> pass all lines through verbatim until
Line starting with .EN | .TE | .PE | .RE | .G2 -> lines after processed as normal
This is not a markdown to -> ms converter as such it is just saving time
and allowing drafting of text before doing the markup.
For added points, once substitutions made, each line broken into hard
break lines again in one sentence per line mode while preserving the
troff code.
August 17th 2024
----------------
The ftp function on OpenBSD has more functionality than the one
in Linux. It can fetch Web pages. So below is a preliminary mad
science hack that can fetch a Web page, get rid of one level
of html tags, dump the resulting textish stuff into format and then
into less with 'squash lines'.
ftp -o - https://www.theregister.com | sed -e 's/<[^>]*>//g' | fmt | less -s
Sort of works, but misses style sheets and scripts so a couple
more sed lines needed for {css} and