NC (Netcat) is known as the "Swiss Army Knife" in the network tool, although the volume is small but powerful, NC the simplest function is the port scan, here I take note of it as a file transfer of magical use.
First look at the help information.
$ nc-h OpenBSD netcat (Debian patchlevel 1.105-7ubuntu1) This is NC from the NETCAT-OPENBSD package.
An alternative NC are available in the Netcat-traditional package. USAGE:NC [ -46bcddhjklnrstuuvzz] [-i-length] [-I interval] [-o-length] [-P proxy_username] [-P source_port] [-Q seconds ] [-S source] [-t Toskeyword] [-v rtable] [-w timeout] [-X Proxy_protocol] [-X proxy_address[:p ORT]] [destination] [ Port] Command Summary:-4 use ipv4-6 ipv6-b Allow broadcast-c Send CRLF as Line-endin g-d Enable the debug socket option-d Detach from stdin-h this help text-i length TCP receive Buffer length-i secs Delay interval for lines sent, ports scanned-j use Jumbo Frame-k Keep Inboun
D sockets open for multiple connects-l Listen mode, for inbound connects-n suppress, Name/port -O length TCP send buffer length-p proxyuser Username for proxy authentication-p PORT specify local port for remote connects-q secs quit over EOF on stdin and delay of Secs-r Randomiz E remote ports-s Enable the TCP MD5 signature option-s addr Local source address-t Toskeyword Set IP Type of service-t Answer TELNET negotiation-u use UNIX domain socket-u UDP mode-v rtable Sp Ecify Alternate Routing table-v verbose-w secs Timeout for connects and final net Reads-x Proto ProX Y protocol: "4", "5" (SOCKS) or "Connect"-X addr[:p ORT] Specify proxy address and port-z DCCP
ZERO-I/O mode [used for scanning] Port numbers can is individual or ranges:lo-hi [inclusive]
Port Scan:
$ nc-z-v-n 127.0.0.1 20-100
...
Connection to 127.0.0.1 Port [tcp/*] succeeded!
...
Simple File Transfer:
Client:
$ nc-l 192.168.1.11 1234 > Passwd.txt &
Service side:
$ NC 192.168.1.11 1234 </etc/passwd
can also be
cat/etc/passwd | NC 192.168.1.11 1234
Service-side IP is 192.169.1.11, port is 1234
So, when two Linux machines need to simply transfer files, it's better