The ping command sends ICMP echo requests to a target host to test network connectivity and determine if it is reachable. ls and dir are used to list directory contents, while host is used for DNS lookups, making them incorrect for testing connectivity.