distro name
lsb_release -a
or cat /etc/lsb-release
simple time
/usr/bin/time -f 'TIME:%e RAM:%M\n' go run cmd/dmc/*.go
quick bench cmd alias
alias bench="/usr/bin/time -f 'TIME:%e RAM:%M KB\n'"
alias hr='printf "%0.s-" {1..80}; echo'
run command multiple times
for i in {1..3}; do bench go run cmd/dmc/*.go; done
remove prefix
from a list of files
for file in prefix*; do mv -v $file "${file#prefix}"; done
if you only care about stdout
ls -a | tee output.file
If you want to include stderr
program [arguments...] 2>&1 | tee outfile
Becareful, in Python you have to include the -u
flag to print to both terminal+file
python -u main.py 2>&1 | tee outfile
Stress (1 GiB) memory with Python
python -c "print(len(bytearray(1024*1024*1000)))"
Discover devices on local network
sudo nmap -sP 192.168.2.1/24
Send file with rsync + show progress
rsync -r --info=progress2 --info=name0 /tmp/foo.txt [email protected]:/media/jp/DATA
Fix NTFS Windows read-only partition when mounting
sudo ntfsfix /dev/sdxX
Kill by port
sudo fuser 33060/tcp
or kill -9 $(lsof -t -i:8000)
or
sudo kill `sudo lsof -t -i:33060`
kill by pname
sudo pkill -f gunicorn
git log no pager
git --no-pager log --decorate=short --pretty=oneline
disable text wrapping on terminal
setterm -linewrap off
slurm jobs
ssh user@cluster 'squeue --format="%.9i %.9P %.30j %.8u %.8T %.10M %.9l %.6D %R" -u user'
download every .out
file
rsync -avz -e 'ssh -p 10022' '[email protected]:~/batches/out/*.out' /tmp
Interactive auto-rm python3 shell
docker run --rm -it -v "$(pwd)":/data --entrypoint bash python:3.11-slim