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.

Setup remote server

The following is my list of commands on a new (Ubuntu) server to set it up as I like it. Obviously entirely personal.

sudo apt update
sudo apt full-upgrade -y

sudo apt install byobu zsh -y
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
# Something to add `zsh-syntax-highlighting` to the `plugins` array in `.zshrc`

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/.miniconda && rm ~/miniconda.sh
eval "$($HOME/.miniconda/bin/conda shell.zsh hook)" && conda init zsh

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER