Listen on a network port and save data to a text file

LinuxNetworkingListenerPort

Linux Problem Overview


Is there some easy way in linux to listen for data on network and save them to a text file?

Thank you.

Linux Solutions


Solution 1 - Linux

Netcat is your friend here.

nc -l localhost 10000 > log.txt

Netcat will listen for a connection on port 10000, redirect anything received to log.txt.

Solution 2 - Linux

Also available is TCPDump.

sudo tcpdump -i eth0 -vvvvtttAXns 1500 'port 10000'

Solution 3 - Linux

Other tools are Ethereal (man page) or Wireshark and it's console variant tshark.

In any case please be aware that you are following local and company rules.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMartin PetercakView Question on Stackoverflow
Solution 1 - LinuxTomT the WeathermanView Answer on Stackoverflow
Solution 2 - LinuxMike MackintoshView Answer on Stackoverflow
Solution 3 - LinuxJayanView Answer on Stackoverflow