Sa 17 Okt 2026 01:30:12 CEST

nice commandline tools

i really like the following tools:
lsd aka ls deluxe - a nicer ls
btop - an incredible system monitor able to show gpu usage
chafa - shows pictures in your terminal
cava - an audio visualizer
mc aka midnight commander - the swiss army knife of shells
jq - lets you edit and query json data

Di Jul 27 22:13:10 CEST 2021

how to magically make an o365-calendars working in nextcloud

provided that you already having an ics or html calendar source added to nextcloud calendar:
sudo -u www-data php -f /var/www/nextcloud/occ config:app:set dav calendarSubscriptionRefreshRate --value "PT600S"
this makes it refresh the calendar every 10 minutes. or you don't do that and wait for a week.

So Mai 31 12:44:47 CEST 2020

gnome - create menue-entries

go to
cd ~/.local/share/applications/
touch myprog.desktop
fill the file with s.th. like
[Desktop Entry]
Name=Unison (sc)
Comment=synchronize files
Exec=/usr/local/bin/unison-gtk
Icon=unison-gtk
Terminal=false
Type=Application
Categories=System;
save, now run
update-menues

Mi Mai 27 22:47:20 CEST 2020

icaclient

after installing the citrix workspace app run
sudo ln -s /usr/share/ca-certificates/mozilla/* /opt/Citrix/ICAClient/keystore/cacerts/

So Feb 23 11:58:03 CET 2020

compile unison from scratch

since unison doesn't work with different versions, just accept that you have to build this from scratch, since the next os upgrade of one of the involved clients will break protocol.
sudo apt install opam ocaml liblablgtk2-ocaml-dev liblablgtk2-ocaml
labelgtk* isn't needed for cli version only and can be skipped in the opam steps, too.
opam init
eval $(opam env)
opam switch create ocaml-base-compiler.4.05.0
eval $(opam env)
opam install lablgtk
we download the unison 2.51.2 source. unzip it somewhere and cd into it. for the gtk version you need to hack src/uigtk2.ml before and replace in line 97 from region_of_string to region_of_bytes.
make
this compiles now the gtk2 version. if cli is needed:
make text
beware that the binary has the same name. make will automatically generate cli version if lablgtk is not installed.
now copy the files to your systemfolder
sudo cp src/unison src/unison-fswatch /usr/bin/
cd /usr/bin
sudo ln -s unison unison-2.51
on older opam versions (1.x), like on raspbian stretch, things look a little bit different:
opam init
eval $(opam config env)
opam switch set 4.05.0
eval $(opam config env)
cd yourunisonsourcedirectory
make
precompiled versions can be found here:
unison-gtk 2.51.2-ocaml4.05.0 binary[x64]
unison 2.51.2-ocaml4.05.0 binary[x64]
unison-fsmonitor 2.51.2-ocaml4.05.0 binary[x64]
unison 2.51.2-ocaml4.05.0 binary[armhf]
unison-fsmonitor 2.51.2-ocaml4.05.0 binary[armhf]

Di Okt 1 08:13:55 CEST 2019

check certificate files

check .pem / check .crt
openssl x509 -noout -text -in certificate.pem
check .csr
openssl req -noout -text -verify -in cert_sign_req.csr
convert p12 to pem
openssl pkcs12 -in certificate.p12 -nocerts -out certificate.key
openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.crt
cat certificate.crt certificate.key > certificate.pem
in case the key is still encrypted after extracting it run
openssl rsa -in certificate.key -out certificate_decrypted.key
check if key belongs to certificate
openssl x509 -modulus -noout -in server.com.crt | openssl md5
openssl rsa  -modulus -noout -in server.com.key | openssl md5

So Jul 7 23:01:58 CEST 2019

exit terminal with all processes running

you want to log off but some job is still running in the background
disown -a && exit

So Jun 16 20:09:24 CEST 2019

how to get opera-stable working properly

youtube isn't working.
go to /usr/lib/x86_64-linux-gnu/opera and replace the libffmpeg.so with the chromium one.
since ubuntu now only ships snaps, we need to get the download location of that package.
curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/chromium-ffmpeg | jq
get the download url for your architecture by hand. next one is an example. then mount the package and get the libffmpeg.so from the latest chromium-folder (there are plenty)
wget https://api.snapcraft.io/api/v1/snaps/download/XXzVIXswXKHqlUATPqGCj2w2l7BxosS8_24.snap
sudo mount -t squashfs -o ro XXzVIXswXKHqlUATPqGCj2w2l7BxosS8_24.snap /mnt/
sudo cp /mnt/chromium-ffmpeg-104707/chromium-ffmpeg/libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/

Die Jan 8 15:44:51 CET 2019

aliases

as Bash user, simply fill your $HOME/.bash_aliases with stuff like:

# some more ls aliases
alias l='/usr/bin/ls -CFlh'
alias ls='lsd'
alias ll='ls -lAh'
alias la='ls -Ah'

alias ..='cd ..'
alias cd..='cd ..'
alias m:='cd /media/gerrit'
alias r:='cd /resources'
alias u:='cd /resources/_user'
alias acmd='amulecmd -P h0ll4nd'
alias createdeb='checkinstall -D'
#krass gut dupletten komprimieren
alias compressdubs='7za a -t7z -m0=lzma2 -mx=9 -mfb=273 -md=32 -ms=8g -mmt=16 -mmtf=off -mqs=on -bt -bb3'
alias delete_thumbs='rm -r ~/.thumbnails/*; python ~/bin/g3bookmarks.py'
alias dfh='df -hlTx tmpfs | ( read header ; echo "$header" ; sort -k 7 -i)'
alias dirtree='tree -fi'
alias md='mkdir'
alias agi='sudo apt-get install'
alias acs='sudo apt-cache search'
alias agu='sudo apt-get update && sudo apt-get upgrade'
alias agd='sudo apt-get update && sudo apt-get dist-upgrade'
alias publicip='curl https://schrottrecorder.com/ip/raw 2>/dev/null'
alias uuids='lsblk -o UUID,MOUNTPOINT,PATH,SIZE'
youtube-url () { yt-dlp -j ytsearch1:"$1"|jq '.webpage_url' | tr -d '"' ; }
alias y='yt-dlp --merge-output-format mp4 --format "bestvideo[ext=mp4][vcodec!*=av01]+bestaudio[ext=m4a]" --add-metadata'

sox_duration_total () {
  if [[ "$#" -lt 1 ]]; then
    echo "find files!"
    echo "  sox_duration_total *.mp3"
    echo ""
    return
  fi
  for i in "$@"; do
    val=$(soxi -d "$i")
    echo "$val | $i"
  done
  soxi -D "$@" | python -c "import sys;print(\"\ntotal sec:    \" +str( sum(float(l) for l in sys.stdin)))"
  soxi -D "$@" | python -c "import sys;print(\"total min:    \" +str( sum(float(l) for l in sys.stdin)/60 ))"
  soxi -D "$@" | python -c "import sys;import datetime;print(\"running time: \" +str( datetime.timedelta(seconds=sum(float(l) for l in sys.stdin)) ))"
}

alias please='sudo'
alias gitreset="git fetch origin master;git reset --hard origin/master"

#Do compression with all cores !!
function gzip(){ pigz $@; }
function gunzip(){ unpigz $@; }
function bzip2(){ pbzip2 $@; }
#function bunzip2(){ pbunzip2 $@ }
#function xz(){ pxz $@ }

alias mpl='mpv'
alias mplf='mpl -fs'
alias mpls='mpl -shuffle'
alias mplfs='mpls -fs'

#alias ffmerge='ffmpeg -acodec copy -vcodec copy'
ffmerge () { ffmpeg -i "$14a" -i "$1p4" -c:v copy -c:a aac -strict experimental "$1.mp4"; }
efs () { encfs `pwd`/$1 `pwd`/$2; }
ufs () { fusermount -u $1; }
torrent () { case $1 in
    "add")      transmission-remote -a $2;;
    "del")      transmission-remote -t $2 -r;;
    "wl")       watch transmission-remote -l;;
    "watch")    watch transmission-remote -t $2 -i;;
    "list")     transmission-remote -l;;
    "start")    transmission-remote -t $2 -s;;
    "stop")     transmission-remote -t $2 -S;;
    *)          echo "Usage: torrent add/del/watch/list \$params";;
    esac; }

if [ $TERM == "dumb" ]; then export TERM=xterm; fi

alias wine_oblivion='export WINEPREFIX=/ssd2/.steam/steam/steamapps/compatdata/22370/pfx'
alias wine_f4='export WINEPREFIX=/ssd2/.steam/steam/steamapps/compatdata/377160/pfx'

alias visualizer=cava
alias showpic=chafa

PS1='\[\e]0;\h \w\a\]\n\[\e[48;5;33m\] \[\e[0m\] \[\e[38;5;33m\]\u\[\e[38;5;33m\]@\[\e[38;5;33m\]\h\[\e[32m\] \[\e[38;5;33m\]\w\n\[\e[0;48;5;45m\] \[\e[0m\] \[\e[38;5;38m\]\t\[\e[0m\] \$ '

Don Apr 5 23:31:40 CEST 2018

osmc/kodi/xbmc handling

start/stop the mediacenter
sudo systemctl {start/stop} mediacenter
videolibrarycontrol. command={Clean,Scan}
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.{command}", "id": "mybash"}' -H 'content-type: application/json;' http://localhost:8080/jsonrpcr
same for audiofiles...
curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.{command}", "id": "mybash"}' -H 'content-type: application/json;' http://localhost:8080/jsonrpcr
finally exporting the library via xbmc-senc
xbmc-send -a "exportlibrary(video,false,your_backup_path)"

Don Apr 5 23:10:08 CEST 2018

sudo graphical applications under wayland

wayland forbids graphical applications to be started as another user. so if you want to start synaptic...
xhost +SI:localuser:root
sudo $1
xhost -SI:localuser:root

Mit Okt 19 18:58:51 CEST 2016

convert media

remove audio from a video
ffmpeg -i in.mp4 -an out.mp4
convert every file in the current folder to an mp3 in folder ../b (if possible)
you better use echo on the first run
find . -type f -exec ffmpeg -i "{}" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "../b/{}" \;

Die Okt 18 23:19:46 CEST 2016

iterate in bash

files in the current direcory will be renamed according to a text file. the first file will be named like the first row of the given text file and so on. beware that the text file itself will be renamed if it is in the current directory.
msc=(./*)#or mp3 or whatever
i=0
while read line
do
	#rather use echo than mv the first time
	mv "${msc[i]}" "$line"
	i=$((i+1))
done < ../filenames.txt

Mon Okt 17 10:20:30 CEST 2016

rename files, remove everything after '?'

fileyx.mp4?param1=test → filexy.mp4
#!/usr/bin/env bash
for i in `find ./ -name "*\?*"`
do 
  j=`echo $i|cut -d '?' -f1`
  mv "$i" "$j"
done

Fre Okt 14 10:44:39 CEST 2016

sort apache logs by date

#!/bin/sh
LANG=C #otherwise sort -M won't work correctly Dec <> Dez
if [ ! -f $1 ]; then
    echo "Usage: $0 "
    exit
fi
sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $1

Fre Okt 14 10:40:30 CEST 2016

block ips that try to access certain sites

!/usr/bin/env bash
logs="/var/log/apache/access.log"
abuses="block_abusive_hosts.txt" #strings with unwanted accesspaths (eg wp-admin)
hosts="abusive_hosts.txt"

#clear abusive hosts
echo > $hosts

for log in $logs
do
  echo reading $log
  while read line
  do
    grep "$line" $log|cut -d " " -f1
  done < $abuses >> $hosts
done

echo blocking...

for i in $(sort $hosts|uniq)
do
  check=`iptables -L -n|grep $i`
  if [ -n "$check" ]
  then
    echo already blocked $i
  else
    echo block $i
    iptables -A INPUT -s $i -j DROP
  fi
done

country-statistics:
for i in $(sort abusive_hosts.txt|uniq)
do
  echo -n "$i ";
  geoiplookup $i
done

Mon Okt 3 09:58:03 CEST 2016

handle ips

ban-ip () { iptables -A INPUT -s $1 -j DROP; }
alias show-bans='iptables -L -n'

Son Sep 25 00:10:58 CEST 2016

cut and convert mp3 with a given cuefile

#!/usr/bin/env bash
if [ $# -ne 2 ]; then
    echo "$0 splits an album into tracks"
    echo "Usage: $0 toc-/cuefile audiofile"
    echo "Your working directory has to be the one containing the files"
    exit
fi

#audiofile will be convertet to wave..
mplayer -ao pcm "$2"

#wave-file will be cut
cuebreakpoints "$1" | shnsplit audiodump.wav
rm audiodump.wav

echo "splittet files will be convertet to ogg.."
dir2ogg *.wav

echo "finished"
#echo "start easytag now? [j/n]"
#read answer
#if [ $answer eg 'j' ] ; then
#    easytag .
#fi

Sam Sep 24 23:02:32 CEST 2016

webcam commandline tricks

see the live webcam capture:
mplayer -fps 30 -cache 128 -tv driver=v4l2:width=1280:height=720:device=/dev/video0 tv://
to make a screenshot:
mplayer -vo png -frames 1 tv://
..and to play the capture as ascii:
mplayer -vo caca -fps 30 -cache 128 -tv driver=v4l2:width=1280:height=800:device=/dev/video0 tv://

Die Sep 20 09:45:53 CEST 2016

rename directories - remove x characters

to remove the last 3 characters from $CertainFolders in the current directory do:
find . -type d -maxdepth 1 | grep $CertainFolders > cf.txt
while read line
    do newFolder=$(echo $line|rev|cut -c 3-|rev)
    mv "$line" "$newFolder"
done < cf.txt

Die Sep 20 09:20:15 CEST 2016

recursive find

find given $String in files in the current directory tree
find . -type f -exec grep -Hl $String {} \;
or:
find ./ -type f -exec grep -q $String {} \; -print
or forget all of that and use the power of grep
grep -R $String .