Commands by bandit36 (3)

  • You can use this to loop any command to periodically see the output. while true; do [YOUR COMMAND HERE]; sleep [# of seconds]; done; Alternatively, you can put it in a simple shell script to save typing! #/!bin/bash while true; do $1; sleep $2; done; /path/to/ "ifconfig eth0 | grep 'inet addr:'" 60 Show Sample Output

    while true; do ifconfig eth0 | grep "inet addr:"; sleep 60; done;
    bandit36 · 2009-04-01 19:29:28 8
  • populate the auth.hosts file with a list of IP addresses that are authorized to be in use and when you run this command it will return the addresses that are pingable and not in the authorized list. Can be combined with the "Command line Twitter" command to tweet unauthorized access. Show Sample Output

    diff <(nmap -sP | grep ^Host | sed 's/.appears to be up.//g' | sed 's/Host //g') auth.hosts | sed 's/[0-9][a-z,A-Z][0-9]$//' | sed 's/</UNAUTHORIZED IP -/g'
    bandit36 · 2009-03-12 05:28:08 3
  • This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations. sudo dd if=/media/disk/backup/sda.backup of=/dev/sda Alternatively, you can use an SSH connection to do your backups: dd if=/dev/sda | ssh [email protected] dd of=~/backup/sda.backup

    sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
    bandit36 · 2009-02-27 20:23:37 2

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Set pcap & SUID Bit for priv. network programs (like nmap)

list block devices
Shows all block devices in a tree with descruptions of what they are.

send a circular
don't need echo :P

How to establish a remote Gnu screen session that you can re-connect to
Long before tabbed terminals existed, people have been using Gnu screen to open many shells in a single text terminal. Combined with ssh, it gives you the ability to have many open shells with a single remote connection using the above options. If you detach with "Ctrl-a d" or if the ssh session is accidentally terminated, all processes running in your remote shells remain undisturbed, ready for you to reconnect. Other useful screen commands are "Ctrl-a c" (open new shell) and "Ctrl-a a" (alternate between shells). Read this quick reference for more screen commands:

Check every URL redirect (HTTP status codes 301/302) with curl
curl -sLkIv --stderr - -s: silences the output when piped to a different command -L: follow every redirect -k: ignores certificate errors -I: just request the headers -v: be verbose --stderr - : redirect stderr to stdout URL to check for redirects piped to grep -i location: -i: grep target text ignoring case location: : greps every string containing "location:" piped to awk {'print $3'} prints the third column in every string piped to sed '/^$/d' removes blank lines

Which files/dirs waste my disk space
I added -S to du so that you don't include /foo/bar/baz.iso in /foo, and change sorts -n to -h so that it can properly sort the human readable sizes.

search office documents for credit card numbers and social security number SSN docx xlsx
# CC with SSN dash ( low false positive only match ###-##-#### not any 8digi number ) $ find . -iname "*.???x" -type f -exec unzip -p '{}' '*' \; | sed -e 's/]\{1,\}>/ /g; s/[^[:print:]]\{1,\}/ /g' | egrep "\b4[0-9]{12}(?:[0-9]{3})?\b|\b5[1-5][0-9]{14}\b|\b6011[0-9]{14}\b|\b3(?:0[0-5]\b|\b[68][0-9])[0-9]{11}\b|\b3[47][0-9]{13}\b|\b[0-9]{3}-[0-9]{2}-[0-9]{4}\b" $ rmccurdyDOTcom

Rename files in batch

Rename duplicates from MusicBrainz Picard
Renames duplicates from MusicBrainz Picard, so you get the latest copy and not a bunch of duplicates.

Open a file at the specified line
You may also use +line:column syntax.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: