1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/nc.md

40 lines
766 B
Markdown
Raw Normal View History

2014-03-03 21:22:40 +11:00
# nc
2019-02-16 17:15:04 +00:00
> Netcat is a versatile utility for working with TCP or UDP data.
2014-03-03 21:22:40 +11:00
2019-02-16 17:15:04 +00:00
- Listen on a specified port and print any data received:
2014-03-03 21:22:40 +11:00
`nc -l {{port}}`
2014-03-03 21:22:40 +11:00
- Connect to a certain port (you can then write to this port):
2014-03-03 21:22:40 +11:00
`nc {{ip_address}} {{port}}`
- Set a timeout:
2014-03-03 21:22:40 +11:00
`nc -w {{timeout_in_seconds}} {{ipaddress}} {{port}}`
- Serve a file:
2014-03-03 21:22:40 +11:00
`nc -l {{port}} < {{file}}`
2014-03-03 21:22:40 +11:00
- Receive a file:
2014-03-03 21:22:40 +11:00
`nc {{ip_address}} {{port}} > {{file}}`
2014-03-08 10:37:44 +08:00
- Server stay up after client detach:
2014-03-08 10:37:44 +08:00
`nc -k -l {{port}}`
- Client stay up after EOF:
2014-03-08 10:37:44 +08:00
`nc -q {{timeout}} {{ip_address}}`
2016-06-13 11:54:36 +08:00
2019-02-16 17:15:04 +00:00
- Scan the open ports of a specified host:
2016-06-13 11:54:36 +08:00
`nc -v -z {{ip_address}} {{port}}`
2019-02-16 17:15:04 +00:00
- Act as proxy and forward data from a local TCP port to the given remote host:
2016-06-13 11:54:36 +08:00
2019-02-16 17:15:04 +00:00
`nc -l {{local_port}} | nc {{hostname}} {{remote_port}}`