Tag Archives: linux

#CommandLineFu: 8 Deadly Commands You Should Never Run on Linux

Being a command line junky, I thought I’d share this fun little article I found the other day from @chrisbhoffman – 8 Deadly Commands You Should Never Run on Linux.

rm -rf / – Deletes Everything!

:(){ :|: & };: – Fork Bomb

mkfs.ext4 /dev/sda1 – Formats a Hard Drive

command > /dev/sda – Writes Directly to a Hard Drive

dd if=/dev/random of=/dev/sda – Writes Junk Onto a Hard Drive

mv ~ /dev/null – Moves Your Home Directory to a Black Hole

wget http://example.com/something -O – | sh – Downloads and Runs a Script

Chris Hoffman is a technology writer and all-around computer geek. He’s as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.

CommandLineFu: FOR LOOP – report file count in pwd/* && print disk usage

for i in */ ;
        echo -n "$i:" >> "/path/to/some/file/already/created.txt" ;
        find "$i" -type f | wc -l >> "/path/to/same/file/already/created.txt" ;
        du -hs "$i" ;
exit 0

Quick and dirty…
Actually this is quite slow when dealing with directories containing thousands of little files.
But it gets the job done.  I’ll play around with it and see if forking helps.