Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / ext4-vs-xfs-max-usable-space.sh
Last active February 26, 2023 14:47
ext4 vs xfs max usable space for 16 TB drive
# 16 TB drive with ext4 file system optimized for max available space:
# --------------------------------------------------------------------
$ sudo mkfs.ext4 -m 0 -T largefile4 /dev/sdX
/dev/sdX: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdX: 8 bytes were erased at offset 0xe8d7dfffe00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdX: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdX: calling ioctl to re-read partition table: Success
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 3906461696 4k blocks and 3814912 inodes
Filesystem UUID: 3ea950c5-ae13-4755-a6b8-6f317f6f8dea
@gregjhogan
gregjhogan / ssh-keygen--host-key-to-custom-output-dir.sh
Created March 3, 2021 02:04
generate ssh host keys for sshd and output to a non-standard location
#!/bin/sh -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
grep "^HostKey" /etc/ssh/sshd_config | while read -r HOST_KEY; do
KEY_FILE=$(echo "$HOST_KEY" | cut -d' ' -f2)
KEY_DIR=$(dirname "$KEY_FILE")
KEY_TYPE=$(echo "$KEY_FILE" | cut -d'_' -f3)
@gregjhogan
gregjhogan / ubuntu-20.04-fix-spotify-deb-install.sh
Created December 2, 2020 22:24
Ubuntu 20.04 fix Spotify deb install offline (error code: 4)
# run this every time you open spotify (after it has launched and says it is offline)
# it probably notices network manager is stopped for a second which disables the check
sudo systemctl restart network-manager.service
# turning off network manager makes it immediately show online when it starts up
sudo systemctl stop network-manager.service
sudo systemctl disable network-manager.service
@gregjhogan
gregjhogan / ssh-keygen-rm-known-hosts.sh
Created October 29, 2020 19:01
ssh-keygen remove hosts from known_hosts
SERVER=<your-server>
DOMAIN=<your-domain>
ssh-keygen -R ${SERVER}
ssh-keygen -R ${SERVER}.${DOMAIN}
ssh-keygen -R $(dig +short ${SERVER}.${DOMAIN})
@gregjhogan
gregjhogan / ssh-keyscan-add-known-hosts.sh
Created October 29, 2020 18:26
ssh-keyscan add hosts to known_hosts
# list of hostnames from file
ssh-keyscan -H -f /<path>/<to>/<file> >> ~/.ssh/known_hosts
@gregjhogan
gregjhogan / docker-buildx-arm64.sh
Last active July 1, 2020 03:46
setup and build an arm64 docker image on x86/amd64
# requires docker-cli 19.03 or higher
docker run --privileged linuxkit/binfmt:v0.7
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx use arm64builder || docker buildx create --name arm64builder --use
docker buildx inspect --bootstrap
docker buildx build --platform=linux/arm64 -t <tag> -f <docker-file> .
@gregjhogan
gregjhogan / nmap-scan-show-open.sh
Created June 11, 2020 22:06
nmap scan for port open and only show open results
nmap -p <port> 192.168.0.*|grep -B3 open
@gregjhogan
gregjhogan / ubuntu-20.04-adwaita-dark-theme-install.sh
Last active August 17, 2023 16:02
ubuntu 20.04 install adwaita dark theme
# default theme broken and not available after upgrade from ubuntu 18.04
# running these two commands seems to fix it
sudo apt-get --reinstall install ubuntu-session
sudo apt-get --reinstall install yaru-*
# optionally reset everything
dconf reset -f /org/gnome/
# tweak tool to select theme
sudo apt-get install gnome-tweak
# add adwaita-dark theme variant
sudo apt-get install gnome-themes-extra
@gregjhogan
gregjhogan / find-delete-progress.sh
Created April 17, 2020 19:05
find and delete all files in a directory (with progress)
find . -print -delete | pv -l > /dev/null
@gregjhogan
gregjhogan / ubuntu-back-blackground-color.sh
Created March 2, 2020 19:40
ubuntu black background color
gsettings set org.gnome.desktop.background picture-options 'none'
gsettings set org.gnome.desktop.background primary-color '#000000'