Daily Linux Utilities
2 min readJul 10, 2024
Start a Web server with `netcat` — netcat is a computer networking utility for reading from and writing to network connections using TCP or UDP.
sanjeev@ip-10-110-229-211:~$ while true;do echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -v -l -p 1569 -q 1;done
Listening on 0.0.0.0 1569
Connection received on 172.16.132.10 56071
GET / HTTP/1.1
Host: 10.110.229.211:1569
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Accept-Language: en-IN,en-GB;q=0.9,en;q=0.8
Accept-Encoding: gzip, deflate
Connection: keep-alive
Listening on 0.0.0.0 1569
Connection received on 172.16.132.10 56079
Listening on 0.0.0.0 1569
Sending Request Via `netcat` itself
sanjeev.rohilla@Sanjeev-Rohilas-Mac ~ % nc -v 10.110.229.211 1569
Connection to 10.110.229.211 port 1569 [tcp/ets] succeeded!
HTTP/1.1 200 OK
Wed Jul 10 06:44:24 UTC 2024
sanjeev.rohilla@Sanjeev-Rohilas-Mac ~ %
Or you can access via Browser as well
http:10.110.229.211:1569
Here are the exit codes for shell
Ref: https://tldp.org/LDP/abs/html/exitcodes.html
$ test -d copyright
$ $?
bash: 1: command not found
$ test -d ../libmysqlclient21
$ $?
bash: 0: command not found