the basics to advanced usage of the ‘nc’ command in Linux

https://ioflood.com/blog/nc-linux-command/

Advanced Use of NC Linux Command: Unleashing the Power
As you become more proficient with the ‘nc’ command in Linux, you’ll discover its true power lies in its advanced features. The ‘nc’ command’s flexibility allows it to handle more complex network tasks, such as creating a simple chat server or transferring files between systems.

Before we dive into the advanced usage of ‘nc’, let’s familiarize ourselves with some of the command-line arguments or flags that can modify the behavior of the ‘nc’ command. Here’s a table with some of the most commonly used ‘nc’ arguments.

Argument Description Example
-l Puts ‘nc’ in listening mode, waiting for incoming connections. nc -l 1234
-p Specifies the source port ‘nc’ should use, subject to privilege restrictions and availability. nc -l -p 1234
-s Specifies the IP of the network interface which ‘nc’ should use. nc -s 192.168.1.5 -l -p 1234
-u Forces ‘nc’ to use UDP instead of the default TCP. nc -u localhost 1234
-v Makes ‘nc’ give more verbose output. nc -v -l -p 1234
-n Skips DNS name resolution. nc -n -l -p 1234
-z Makes ‘nc’ scan for listening daemons, without sending any data. nc -z localhost 20-30
-w Sets the timeout for connections and responses. nc -w 5 localhost 1234
-C Sends CRLF as line-ending. nc -C -l -p 1234
-q After EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever. nc -q 5 -l -p 1234
Now that we have a basic understanding of ‘nc’ command line arguments, let’s dive deeper into the advanced use of ‘nc’.

posted @ 2025-02-23 15:14  严肃活泼快乐有趣  阅读(25)  评论(0)    收藏  举报