Date created: 02/28/12 21:50:34. Last modified: 03/12/21 08:36:14

Random Commands

Fun / Misc:

Parrot Party:



The Weather:



Digital clock in the terminal:

watch -t -n 1 "date +%T | figlet"


Fork Bomb:



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...

echo -ne "Progress: $[ ($i+1)*100/120000 ]%\r";

# 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



alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'