Collection of developer hacks and tricks by @ololobus
openssl rand -base64 10
openssl rand -hex 10
<CR>
characters from file (Mac OS X tested)sed -i.bak $'s/\r//' file`
tmux
usagelist – tmux ls
resume – tmux a
detach – Ctrl + b
, press d
stdout
and stderr
to filepython3 very-verbose-program.py 2>&1 | tee -a results.log
Usage by directory
du -h -d 1 /
Overall stats
df -h
find postgres_data/base/ -regex '.*[0-9]+' -exec pg_filedump "{}" \; | grep Error | sort | uniq
find postgres_data/base/ -regex '.*[0-9]+' -print0 | xargs -0 -n1 pg_filedump | grep Error | sort | uniq
du -hs * | sort -rh | head -5
sudo find / -size +500000 -print
sudo find / -size +500000 -exec sudo ls -lah "{}" \;
sudo du -k /* | awk '$1 > 500000' | sort -nr
sudo mkdir /mnt/tmpfs
sudo chmod -R 777 /mnt/tmpfs
sudo mount -t tmpfs -o size=512m ext4 /mnt/tmpfs
sudo umount /mnt/tmpfs
Create a file of the size you want (here 10MB)
dd if=/dev/zero of=/home/username/test bs=1024 count=10000
Make a loopback device out of this file
losetup -f /home/username/test
Format that device in the file system you want
mkfs.ext4 /dev/loopXX
Mount it wherever you want (/mnt/test
should exist)
mount /dev/loopXX /mnt/test
Don’t forget to unmount and clean up loop device after use, with sudo losetup -d /dev/loopXX
.
sudo apt install sysbench
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run
watch -n N_SECONDS <your command>
localedef -i en_US -f UTF-8 en_US.UTF-8
It also counts main process twice, so do -1 to the result.
ps -M 81581 | wc -l
sudo openvpn --config '/path/to/openvpn/config.ovpn'
To use with login/password create pass.txt
with:
login
password
and add auth-user-pass /path/to/pass.txt
to config.ovpn
.
Filter packets by data size and value
data.len > 1 or (data.len == 1 and data in {Q K Z I P X B E C S D H c d f F n 2})
Maybe helpful to hack mobile hotspot limitations on some cellular data plans.
sudo sysctl -w net.inet.ip.ttl=65
net.inet.ip.ttl=65
into /etc/sysctl.conf
nmcli dev wifi
sudo apt install wavemon
wavemon
sudo apt install gnome-tweak-tool