Oneliners
Page content
Misc Oneliners
Tar Folder and copy to remote Machine
tar cf - /etc/ |ssh ${remote-host} "cd /tmp/ && cat > $(hostname)-etc.tar"
Tar & GZIP Folder and copy to remote Machine
tar czf - /etc/ |ssh ${remote-host} "cd /tmp/ && cat > $(hostname)-etc.tar.gz"
Dump Certs Chain
s="google.com"; timeout 2 openssl s_client -servername ${s} -connect ${s}:443 -showcerts > /tmp/${s}.chain
selfsigned certificate for 1 year
cd /etc/ssl; openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 356
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
Show your Python Path
python3 -c "import sys; print('\n'.join(sys.path))"
Any Comments ?
sha256: 1a402929339db108ba0c907e997352b630898bd86bdf4e5924411198b7063869