Date created: 02/28/12 21:50:34. Last modified: 03/12/21 08:36:14
Random Commands
Fun / Misc:
Parrot Party:
curl parrot.live
The Weather:
curl wttr.in/
Digital clock in the terminal:
watch -t -n 1 "date +%T | figlet"
Fork Bomb:
#/bin/bash $0& $0
Another Fork Bomb:
:(){ :|:& };:
Bash progress bar/indicator/spinner:
tar -cvzf ${TAR} ${DIR} | tqdm --unit_scale --total $(find ${DIR} -type f | wc -l ) > /dev/null
# Or...
for((i=0;i<120000;i++))
do
echo -ne "Progress: $[ ($i+1)*100/120000 ]%\r";
done;
# Or...
while :;do for s in / - \\ \|; do printf "\r$s";sleep .1;done;done
System commands:
Scrollable full `ps` output
ps awwfux | less -S
Find out how much data is waiting to be written to disk
grep ^Dirty /proc/meminfo
Release memory used by the Linux kernel on caches
free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m
Handy tricks:
Seconds to Hours:Minutes:Seconds
awk -v seconds=54321 'BEGIN {print strftime("%H:%M:%S", seconds, 1)}'
Epoch time to human time
date -d @1331485023
Sort du output by size
du -hs | sort -rh
Echo with sudo
sudo 'echo "10" > /proc/sys/vm/swappiness' # Doesn't work
sudo sh -c 'echo "10" > /proc/sys/vm/swappiness' # Works for replace, >> for append
echo "10" | sudo tee -a /proc/sys/vm/swappiness > /dev/null # Works for append, remove -a for replace
Recursive grep
grep -r "string" /blah/blah
Sort ls output by reverse modified time (so newest at bottom)
ls -ltr
Sort by size (smalllest at bottom)
ls -ls
ls -lS
Start COMMAND, and kill it if still running after 5 seconds
timeout 5s COMMAND
Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
Previous page: 'tcpdump', 'editcap', & 'ngrep' - Notes
Next page: 'rkhunter' - Notes