Date created: Tuesday, February 28, 2012 9:50:34 PM. Last modified: Tuesday, January 30, 2024 5:30:19 PM

Random Commands

Fun / Misc:

Parrot Party:



The Weather:



Digital clock in the terminal:

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

A binary clock:

watch -n 1 'echo "obase=2;`date +%s`" | bc'


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



Glue multiple PDFs together:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=large.pdf -f small1.pdf small2.pdf small3.pdf


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'