Skip to content

Instantly share code, notes, and snippets.

View rmi1974's full-sized avatar

Robert Michelsen rmi1974

  • Germany
View GitHub Profile
@rmi1974
rmi1974 / how_ to_show_differences_between_two_docker_images.md
Last active February 12, 2023 16:00
How to show differences between two Docker images #commandlinefu #docker #diff #compare #images

How to show differences between two Docker images

Courtesy of [github container-diff][1]

Prerequisite:

$ cd Downloads
$ curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64
@rmi1974
rmi1974 / how_to_enable_unauthenticated_mounting_of_external_disks_using_udisksctl.md
Last active February 12, 2023 12:01
How to enable unauthenticated mounting of external disks using udisksctl #commandlinefu #udisksctl #mount

How to enable unauthenticated mounting of external disks using udisksctl

Courtesy of [reddit thread][1]

Create file /etc/polkit-1/rules.d/10-udisks2.rules with following content:

$ sudoedit /etc/polkit-1/rules.d/10-udisks2.rules

// See the polkit(8) man page for more information
@rmi1974
rmi1974 / how_to_automatically_an_encrypted_volume_at_boot.md
Created February 12, 2023 11:39
How to automatically mount an encrypted volume at boot #commandlinefu #mount #lucks #encrypted #volume

How to automatically mount an encrypted volume at boot

Courtesy of [ask.fedoraproject.org][1]

NOTE: To have this work, one of your passphrases of your LUKS encrypted disk must be the same then your login password!

Prerequisite:

$ sudo dnf install pam_mount
@rmi1974
rmi1974 / how_to_spin_down_hard_drives_with_hd_idle.md
Created January 25, 2023 12:55
How to spin-down hard drives with hd-idle #commandlinefu #hd-idle #hdidle

How to spin-down hard drives with hd-idle

Courtesy of [github.com adelolmo hd-idle][1]

Prerequisite:

$ sudo dnf install golang
@rmi1974
rmi1974 / how_automatically_enable_disable_wifi_with_ethernet_nwm.md
Created January 16, 2023 17:19
How to automatically enable and disable WiFi based on Ethernet connection with NetworkManager #wifi #networkmanager #commandlinefu

How to automatically enable and disable WiFi based on Ethernet connection with NetworkManager

Courtesy of [distroguy blog post][1]

cat << \EOF |sudo tee /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
#!/bin/bash
export LC_ALL=C

enable_disable_wifi ()
@rmi1974
rmi1974 / how_to_optimize_disk_space_usage_with_btrfs.md
Last active March 5, 2022 13:02
How to optimize disk space usage with BTRFS #commandlinefu #btrfs #rmlint

How to optimize disk space usage with BTRFS

Enable zstd compression

For general overview see here: [BTRFS Compression][1].

Check zstd compression compression ratio using [compsize][2]:

$ sudo compsize $HOME
@rmi1974
rmi1974 / how_to_control_virtualbox_from_the_command_line.md
Last active November 13, 2022 02:02
How to control VirtualBox from the command line #commandlinefu #virtualbox

How to control VirtualBox from the command line

Some of the command line examples for interacting with Windows VMs require credentials. The examples assume they are exported in the current shell environment for convience:

export VBOXUSER=vboxuser
export VBOXPASS=vboxuser
@rmi1974
rmi1974 / how_to_find_a_binaries_dependencies_using_dynamic_linker.md
Last active March 5, 2022 13:00
How to find a binary's dependencies using dynamic linker #commandlinefu #debug #linker

How to find a binary's dependencies using dynamic linker

Courtesy of [exocus project on github][1]

You can invoke ld-linux with the LD_TRACE_LOADED_OBJECTS environment variable set to 1 and it will list all of the resolved library dependencies for a binary. For example, running

LD_TRACE_LOADED_OBJECTS=1 /lib64/ld-linux-x86-64.so.2 /bin/grep
@rmi1974
rmi1974 / how_to_handle_secrets_cli.md
Created December 11, 2021 10:10
How to Handle Secrets on the Command Line #commandlinefu #secrects

How to Handle Secrets on the Command Line

Courtesy of [smallstep.com/blog][1].

The command line really wasn’t designed for secrets. So, keeping secrets secret on the command line requires some extra care and effort. The other day in my homelab I was configuring a TLS client certificate for a Grafana datasource. The intention was to write something I could run on a timer whenever the certificate is renewed. The command needed to:

  1. Build some JSON with the renewed certificate and private key injected into it
  2. PUT it to Grafana’s API to update the datasource configuration.

I thought I was being very clever when I wrote this lil' Bash pipeline:

@rmi1974
rmi1974 / how_to_display_directory_tree_with_hashes_truncated.md
Created December 7, 2021 08:05
How to display a directory tree with hashes truncated #commandlinefu

How to display a directory tree with hashes truncated

alias truncate-hashes="sed -r 's/([a-f0-9]{8})[a-f0-9]{56}/\1.../g'"
tree ~ | truncate-hashes