Oneliners

Page content

Misc Oneliners

set default branch to main

git config --global init.defaultBranch main

bash - check multiple files

[ -f /etc/resolv.conf -a -f /etc/hosts ] && echo "Both files exist" || echo "One or Both Files are missing"

remove word ’nosuid’ on the line /var in /etc/fstab

sed -E -i.bak 's/(.*\/var.*)(,nosuid)(.*)/\1\3/' /etc/fstab

macos show hidden files

defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder

or

CMD + SHIFT + .

macos hide hidden files

defaults write com.apple.finder AppleShowAllFiles -boolean false; killall Finder

Count Files per Directory

cd /usr; find . -type f |cut -d/ -f2 |sort |uniq -c

Resolve IP for FQDN and add to Table

fqdn="www.egal.com"; host $fqdn |awk '$0 ~ "has" {print $NF}' |map f 'doas /sbin/pfctl -t t_allow_ssh -T add $f'

or without map command

fqdn="www.egal.com"; host $fqdn |awk '$0 ~ "has" {print $NF}' |pfctl -t spammers -T add -f-

QRCode for SSH Key

public

qrencode -t UTF8 < ~/.ssh/id_ed25519.pub

private

qrencode -t UTF8 < ~/.ssh/id_ed25519

QRCode for GPG Key

public

gpg --export --armor |sed "s/END PGP PUBLIC/END PGP \.\*/" |qrencode -o public.png

private

gpg --export-secret-keys --armor |sed "s/END PGP PRIVATE/END PGP \.\*/" |qrencode -Sv40 -o private.png

Convert CSV to JSON

cat LARGEFILE.csv |python3 -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > LARGEFILE.json

sha256: 1a402929339db108ba0c907e997352b630898bd86bdf4e5924411198b7063869