howtos


Oracle VirtualBox: Enable eth0 on backtrack4 / enable default ethernet card on backtrack

ifup eth0

*INFO: The default Ethernet device is disabled on boot but it can easily be enabled by just issuing the above command. (You still need to configure it depending on your system’s structure). In order to activate the Ethernet card you need to call the above command from the Terminal.


One line for loop

for i in $(seq $START $STEP $END); do echo "Iteration $i"; someCommand; someOtherCommand ; done

*INFO: $START: The starting value for the for loop, can be replaced by an integer.
$STEP: The step that the for loop is performing at the end of each iteration, can be replaced by an integer.
$END: The ending value for the for loop, can be replaced by an integer.

*NOTE: All kinds of bash for loops can be coded as above and made into one liners.


Execute a command on the results of a search with the find command 1

find $LOCATION -name "$FILENAME" -exec somecommand '{}' \;

The above command will search in $LOCATION for all files named $FILENAME and apply the command that you define at somecommand.

The argument ‘{}’ inserts each file found into the somecommand syntax. The \; argument indicates the exec command line has ended — YOU MUST INCLUDE IT.


Get the total size of a directory or file

du -sh someName

*INFO: someName can be replaced by any folder or file name or even a regular expression (for example to get the size of all txt files you need to invoke du -sh *.txt)
By using the parameter -s (which stands for summarize) you will get back only the total size in bytes.
By using the parameter -h (which stands for human readable format), for any size output you will get it back in Kilobytes, Megabytes etc.