Useful Linux Commands
Networking tools
netcat
nc [options] host port
The most basic command to find if a port is open would be
$ nc -z -v 192.168.1.71 80
which would return:
192.168.1.71: inverse host lookup failed: Unknown host
(UNKNOWN) [192.168.1.71] 80 (http) open
The result on the last line shows open
, which means port 80 is open. The error before that just means that netcat tried to do a reverse lookup on the IP address but couldn’t find this. So this error can be safely ignored.
The -z
option tells nc to only scan for open ports without sending an data to them while the -v
option means provide more verbose information.
echo "GET" | nc 192.168.1.71 80
to check if you can connect to a http server at 192.168.1.71 in the event you do not have wget or curl.
wget
A tool to check web connections.
$ wget --spider http://192.168.1.70
iperf3
This is a tool to check network bandwidth performance
Regex symbols
Given below are a list of notations used for regex matching:
. Any one character
* Match any number of previous (including 0)
+ Match any number of previous
$ End of line
^ Beginning of line
S any non-white character
s any whitespace character
? optional
[a-z] any lowercase letter
[A-Z] any uppercase letter
[A-Za-z] any letter
\ escape something