Console snippets

Some Console snippets I regularly use

Florian Maurer

projectsgitnetworksnippetscli

419 Words

2025-08-25


This post is just a collection of some snippets I regularly use and look up in my zsh history.

Git

Some nice hooks are shown in this blog post: https://adamj.eu/tech/2022/11/07/pre-commit-run-hooks-rebase/

apply pre-commit fixes to every commit instead of having a “run pre-commit” at the end of the PR

git rebase -x 'pre-commit run --from-ref HEAD~ --to-ref HEAD' main

update the author on every commit of the rebase

git rebase --interactive --exec "git commit --amend --reset-author" --signoff main

rebase with updating all branches along the way

git rebase -i main --update-refs

Pre-Commit Python

Run all pre-commit requirements in the current env

pre-commit run --all-files

If you run this frequently, you might want to also install the commit hook using pre-commit install

MQTT/mosquitto

mosquitto_sub -F '\e[92m%t \e[96m%p\e[0m' -q 2 -h localhost -p 1883 -t "#"

Swap file

I only have 1GB of SWAP initialized and need to have another 8GB as my laptop otherwise goes OOM if too many apps are open. For this I can add

dd if=/dev/zero of=/swapfile.1 bs=1G count=8
/sbin/mkswap /swapfile.1
chmod 600 /swapfile.1
swapon /swapfile.1
swapon -s

sudo swapon /swapfile.1

Network speed test using iperf3

iperf3 -c speed.freifunk-aachen.de -P 3 -t 15 -R
iperf3 -c iperf-hexac.relaix.net -p 5201 -P10 -t10 -R
iperf3 -c  freifunkm01.ring.nlnog.net -p 5202 -R  -P10 -t15

fingerprint using linux

Add new fingerprint using:

fprintd-enroll

ansible

run the ansible playbook virtual-machines, show the diff, ask to become root and only execute the roles tagged with “freetube”:

ansible-playbook ./playbooks/virtual-machines.yml --diff --ask-become-pass --tags=freetube

You can add an additional --check to have a noop/dryrun of ansible.

APT package manager

Show the dependencies of a package

apt depends $package

Show which packages depend on a given package

apt rdepends $package

Show the package which installed this file

dpkg -S $filename

List the files which are shipped with the given installed package

dpkg -L $package

mermaid cli

Create a GANT chart from the mermaid mmd file using a given mermaid-config.json

mmdc -w 1700 -H 1000 -i projectplan.mmd -o ./media/projectplan.svg -c mermaid-config.json`

Add Wireguard config to Gnome Network-Manager

Use the nmcli connection import:

sudo nmcli c import type wireguard file /etc/wirguard/wg-0.conf

This adds the connection to the gnome-vpn UI selection.

Network

show DNS info

dig $tldr

combined ping and traceroute check:

mtr $tldr

Show IP address of a given interface:

ip a s wlo1

show the route which is used to a given IP address using a given local address:

ip r g 9.9.9.9 from 192.168.1.17

Show all routing tables (short for route show table all):

ip r s t all