docs:tips_n_tricks:snippets.html
Table of Contents
Snippets of Information
(to be sorted later)
Ethernet MAC Addresses
I conclude, that software generated MAC addresses in the Xen context need to start with
00:16:3e:xx:xx:xx
printf '00:16:3e:%02x:%02x:%02x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) ip link set $IFACE address $HWADDR
or1)
x2-xx-xx-xx-xx-xx x6-xx-xx-xx-xx-xx xa-xx-xx-xx-xx-xx xe-xx-xx-xx-xx-xx
printf '%02x:%02x:%02x:%02x:%02x:%02x\n' $(( (RANDOM%256 | 0x02) & 0xfe )) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) ip link set $IFACE address $HWADDR
SSH Host Key Fingerprints
ssh-keygen -lf <pub key file>
The part to be entered at the ssh prompt when connecting to unknown hosts is after the number, i.e. starting with the alg. specifier and need not contain the comment.
less in screen
- ~/.screenrc
# workaround for the glitch, that "less" inside "screen" 5 on # "ipfire" 2.29 shows blinking text instead of reverse video: setenv LESS_TERMCAP_so ^[[7m setenv LESS_TERMCAP_se ^[[27m : :
Credits: ChatGPT
Using $(...) in Nagios'/Icingas command_line
$ needs to be escaped by a second $$
- /etc/icinga/commands.cfg
command_line /usr/local/bin/send_something.sh "$$(printf '%s\n%s' '$HOSTNAME' '$HOSTOUTPUT')"
Credits: Nagios Object Definitions at old-www-mathrice.pages.math.cnrs.fr (Well actually that was the first relevant Startpage hit after ChatGPT failed completely)
Reference: Command Definition - The primary source of the above
Notifications via ntfy at every login
- /etc/pam.d/common-session
: session default=ignore pam_exec.so quiet /bin/sh -c [ test 'open_session' = "$PAM_TYPE" && /usr/bin/wget -q -O /dev/null --post-data "$PAM_USER hat sich gerade von $PAM_RHOST über $PAM_TTY eingeloggt" --header "X-Title: Login" --header "X-Priority: 4" --header "X-Tags: unlock" https://ntfy.sh/my_ntfy_topic]
$PAM_TTY will be ssh when appropriate
References:
man 5 pam.confman 8 pam_exec
What's happening on port X?
Refactor rcs Versioning respecting comments
for i in `seq 1 17` do rlog -r1.2.1.$i /etc/RCS/fstab,v > /tmp/work/log/1.2.1.$i co -u -M -r1.2.1.$i /etc/RCS/fstab,v log=$( ( egrep -m1 '^date: .*author:.*state:' ; sed '$d' | fgrep -v '*** empty log message ***' ) < /tmp/work/log/1.2.1.$i | sed '1d' ) rcs -l1 /etc/RCS/fstab,v ci -d -m"$log" /etc/RCS/fstab,v done
diff <(rlog -r1 /etc/RCS/fstab,v ) <(rlog -r1.2.1 /etc/RCS/fstab,v )
for i in `seq 17 -1 1` do j=$(( i+2 )) rcsdiff -r1.2.1.$i -r1.$j /etc/RCS/fstab,v \ && rcs -o1.2.1.$i /etc/RCS/fstab,v done
Make bash remember all whitespace including newlines when typing in multiline commands
shopt -s lithist
Make zsh split variable contents at whitespace
setopt shwordsplit
Make less display things coloured
apt install --no-install-recommends source-highlight colordiff ccze export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" export LESS="-R" less index.php rcsdiff index.php | colordiff | less -SRF rlog index.php | ccze -A | less -SRF
Getting the serial number of my Laptop
~ # dmidecode -s system-serial-number
Remove disconnect but still shown USB disks
udevadm trigger # ? # udevadm trigger --action=add echo 1 > /sys/class/block/sd[x]/device/delete
docs/tips_n_tricks/snippets.html.txt · Last modified: 09.11.2025 17:35 CET by peter