This is a personal list of tools and manuals which I probably don’t use daily, but will help a bunch when their purpose is needed.

Tools

  • checkinstall - Replaces make install and creates an uninstallable .deb of any ‘regular’ source package.
  • 365 mail forwarding - Allows forwarding of domain mails without a (paid) mailbox in Office 365
  • appimagelauncher - Properly integrates AppImage applications into the OS.

Tricks

SSH Reverse Tunnel

Use the following to create a reverse tunnel which allows you to reach a service from a remote host, which only your local host can reach.

ssh <remote-user>@<remote-host> -R <remote-host-local-port>:<target-host>:<target-port>

Make sure to set a <remote-host-local-port> that can be allocated. You will not see an error if you for example use port 222 which only root can allocate, it just won’t work.

Then use localhost:<remote-host-local-port> on the remote host to reach the service. For example using git clone.

git clone ssh://git@localhost:<remote-host-local-port>/your/repo.git

rsync large local drive

rsync -axHAWXS --info=progress2 --numeric-ids /src/ /dest/

It has the following flags:

-a  : all files, with permissions, etc..
-x  : stay on one file system
-H  : preserve hard links (not included with -a)
-A  : preserve ACLs/permissions (not included with -a)
-W  : copy files whole (w/o delta-xfer algorithm)
-X  : preserve extended attributes (not included with -a)
--info=progress2 : less verbose but useful overall progress
--numeric-ids : copy uid/gid as is, instead of trying to map based on user/group names

If you’d like accurate timing of a sync with many files and folders, use the --no-i-r flag. This will increase the time before actual copying starts quite a bit, though.

Be aware that /src/ /dest/ will rsync the content of /src/ into /dest/, while /src will copy that folder into /dest/.

Reset git fork to upstream1

This happens when your fork is out of date, and has a mess of commits you don’t wish to keep. In your own forked repository, do the following:

git remote add upstream https://gitserver.com/upstream-repo.git
git checkout master
git pull upstream master
git reset --hard upstream/master
git push origin master --force

You can replace master with any branch you wish to reset.

Squash (master) branch

The following squashes the master branch, meaning you’ll have just one commit left with the current state of the repository. You need to be able to force push to master.

git checkout --orphan new-master master
git commit -m "squashed"
git branch -M new-master master
git push --force

Update snaps and remove old revisions

snap refresh

snap list --all | awk '/disabled/{print $1, $3}' |
    while read snapname revision; do
        snap remove "$snapname" --revision="$revision"
    done

Add alias with runtime variable substitution

Add this to your .<shell>rc:

dr () { docker run --rm -ti -v "$PWD":/pwd --workdir /pwd "$@"; }

to quickly run a container in the current directory, using for example dr ubuntu ls.

or

gdb () { docker run --rm -ti --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v "$PWD":/pwd --workdir /pwd registry.gitlab.com/gereedschap/gdb tmux new gdb -q "$@"; }

to open a fancy gdb session on the spot.

Don’t forget to source .<shell>rc or open a new shell.

Remove latest except n snapshots from ZSys bpool

At some point bpool is full and won’t make new snapshots. Using this command we do a cleanup of all snapshots except for the last 4.

zfs list -rH -t snapshot -o name bpool -S creation | tail -n+5 | xargs -n1 sudo zfs destroy

Setup Linux system

Setting up a new system, tracking when preferences change.

General

sudo apt update
sudo apt full-upgrade -y
sudo apt install -y fish

wget -qO- https://get.docker.com | sudo sh -s --
sudo usermod -aG docker $USER

fish -c 'set -U fish_greeting ""'

~/.config/fish/conf.d/aliases.fish

function dr
  docker run --rm -ti -v "$PWD":/pwd -w /pwd $argv
end
function drp
  dr --pull always $argv
end
function dru
  dr -u "$(id -u):$(id -g)" $argv;
end
function drup
  drp -u "$(id -u):$(id -g)" $argv;
end

~/.config/fish/conf.d/ssh.fish

eval (ssh-agent -c) > /dev/null
ssh-add -q

Server specific

sudo apt install byobu
byobu-enable

Desktop specific

sudo add-apt-repository -y ppa:appimagelauncher-team/stable

sudo apt install -y appimagelauncher

sudo snap install --classic code
sudo snap install thunderbird
sudo snap install signal-desktop

WSL2 specific

~/.config/fish/conf.d/time.fish

sudo ntpdate time.windows.com > /dev/null
echo "$USER ALL=(root) NOPASSWD: /usr/sbin/ntpdate" | sudo EDITOR='tee -a' visudo