Running a Continuous Ping that doesn’t stop (on Windows)

If you open a command prompt in Windows, and do a ping test, you’ll notice that it will only perform four pings and then stop.  This is OK if you want to do a quick test, but, what if you want to perform a continuous ping that keeps pinging?

Well, we have the -t option!

ping -t <hostname or IP address>

This will now ping continuously until you stop it – by pressing Ctrl and C or closing the window!

Add Line Numbers to grep Output

Often you will grep for certain strings in a text file, but need to find which line it’s on within that file. On a standard grep output, you will see the output, but have no idea which line the string has been found on.

grep has an option, -n, which resolves that.

As an example, imagine we’re grep’ing a text file for the word “line”:

$ grep "line" example-file.txt
This is line 1
This is line 3
This is line 5
This is line 7
Another line
And Another line

We have found every instance of “line” in example-file.txt, however, if we wanted to find these quickly in a text editor, we wouldn’t know which line to go to.  Therefore, we add the -n option:

$ grep -n "line" example-file.txt
1:This is line 1
3:This is line 3
5:This is line 5
7:This is line 7
10:Another line
11:And Another line

Now, we have the line number as part of the output, and we can instantly jump to that line in our favourite text editor. (Which is Vim, right?)

Add Line Numbers to “cat” Output

cat can be used to print the contents of a file in a Terminal, and it’s often useful to number each line of the output (including empty lines).

Adding line numbers is as simple as adding the -n switch to the command:

cat -n filename.txt

Example Output, with -n switch:

$ cat -n filename.txt

1 Line 1
2 Line 2
3 Line 3
4 Line 4
5 Line 5

Example Output, without -n:

$ cat filename.txt

Line 1
Line 2
Line 3
Line 4
Line 5


“Ping Hostname” Returning an IPv6 Address Instead of IPv4? (Windows)

On Windows based PCs and Servers, and where IPv6 is enabled on one of the network adapters, you may find that when you do a:

ping name-of-host

… you get an IPv6 address returned in the results.  But what if you want to test IPv4 connectivity?  You can add a -4 switch to the ping command to force it to use IPv4 as follows:

ping -4 name-of-host

Ping will now ping the IPv4 address as opposed to the IPv6.

It’s worth noting, that if you do want to test for IPv6 connectivity, you can add a -6 switch to force that:

ping -6 name-of-host

Using grep and Ignoring Case (Case Insensitive grep)

grep is a great way to find phrases, words, and characters in text.  One of the biggest stumbling blocks is case – is the word “Hello”, “hello”, “HELLO”, or even “HeLLo”?  All of these are different, and a “grep “Hello”” would only find lines containing the first “Hello” example.

You can, however, exclude case from a grep to make it not case sensitive – simply add -i:

grep -i “Hello” textfile.txt

Alternatively, you could use it in conjunction with cat and tac (Reverse Cat)

cat textfile.txt | grep -i “Hello”

The above will find all lines containing “Hello” in textfile.txt, whether it’s “Hello”, “HELLO”, HElLO”, etc, making it much easier to find instances of “Hello” if you don’t really need to care about case.


(Read the article on Wikipedia about Case Sensitivity..)

CIDR, Subnet Masks, and Usable IP Addresses Quick Reference Guide (Cheat Sheet)

A quick reference Subnet and CIDR guide.

What’s a /28?  How many IPs do I get to use with a /26?  Well, see the table below!
Usable IPs is the Total IPs minus the Network and Broadcast IPs.



Subnet Mask

Total IPs

Usable IPs


Using dig to Query a Specific DNS Server (Name Server) Directly (Linux, BSD, OSX)

There may be occasions when you wish to query a DNS server directly.  I often do it before changing DNS servers for a domain; I’ll setup the new records on the new DNS servers, and then query them directly to ensure they are returning the correct records.

I recommend that anyone running DNS services for any domain looks into these commands – they’re very useful, especially when you’re making changes.

dig has a feature which allows you to specify a name server along with the record you want to query.

For example, one of the DNS servers for is “”.  We can query this server directly, for the www record by doing the following:

$ dig

You’ll get some output with a section titled Answer Section:

;; ANSWER SECTION:       86400   IN      A

This details the result ( and also the TTL for the record (in seconds).  The TTL is important, as this is how long caching DNS servers should cache the result for – in this case, 86400 seconds which is 1 day. Using this command to find out a TTL value for a particular record is also quite useful, especially if you’re investigating DNS cache issues.

You can also do the same to check other records such as MX records, by simpling adding the record type to the command.  For example, to get the MX records is reporting for

$ dig MX

… with the results:

;; ANSWER SECTION:           10800   IN      MX      10           10800   IN      MX      10           10800   IN      MX      10           10800   IN      MX      10

You can see in this instance, that the TTL is 10800 seconds which is 3 hours, and all MX records have the same priority level of 10.

iPhone Data Usage: My Average Monthly Data Usage

Here in the UK, mobile operators include different amounts of data with the iPhone data tarrifs – some even offer unlimited (with fair use making them not unlimited at all).  Check the terms very closely, to know exactly how much data is included with your tariff on a monthly basis.

I bought an iPhone 3GS just under a year ago (20th June 2009) and my data usage in that time has been just 908MB, sent and received.  That’s not much.  I do use WiFi when at home, though.

I have an Exchange push account (with quite a bit of mail flow), random other push apps, I use the browser quite a bit when out and about, I use the maps, and I send a fair few e-mails, often including pictures etc.  I’d say my use is fairly typical.

My average data use (none-WiFi data) a month is 75MB.  So, even if you doubled the use, it’s still only 150MB.  You could say you use data on your iPhone five times as much as me, and it’s still only 375MB a month!

The allowances are often quite high (for a phone) – I’d be surprised if you hit the limit (at time of this post) offered by the mobile companies, certainly in the UK, unless you’re tethering it and using it as a modem, or constantly streaming video such as YouTube etc.

What’s your data usage?  Let me know in comments below!

iPhone Data Usage
iPhone Data Usage

When Did You Last Reboot Your Microsoft Windows 7 Machine? (Check Uptime)

Finding out when you last rebooted your Windows 7 machine can be completed using the “systeminfo” command.

Open a Command Prompt by going to Start and opening “cmd”. You will then be presented with a command prompt window, where you need to type the systeminfo command below:

C:\> systeminfo | find "System Boot Time"
System Boot Time:          05/06/2010, 12:55:07

You will then be shown the date and time the server was booted (as seen in the example above).

You can just run “systeminfo” on it’s own (with no ‘| find “System Boot Time”‘), and you will be presented with a lot of other information such as Hotfixes, Network Connections, etc.