Real world example:
/dev/null:
If I want to discard all data written to largelogfile.log to free-up some space:
Code:
cat /dev/null > /var/log/largelogfile.log
If my script produces error, and wants to hide error message from stderr.
Code:
./myscript 2> /dev/null
If I want to redirect output to multiple files and want to hide stdout to screen:
Code:
echo YES|tee file1 file2 file3> /dev/null
/dev/zero:
If I want to add 100MB more swap memory:
Code:
dd if=/dev/zero of=/extra-swap bs=10000 count=10000
#this will create 100MB storage file
mkswap /extra-swap
#generate swap signature
swapon /extra-swap
#this will enable /swap-extra file as a new extra swap memory
If I want to completely destroy my MBR:
Code:
dd if=/dev/zero of=/dev/sda bs=512 count=1