Can I view the source code of netstat on my Linux machine?
3 Answers
Yes you can. Download it.
But as you don't say what flavor of linux re you using here is couple of examples:
Debian/Ubuntu related:
# What package is the netstat executable in?
apt-file search /usr/bin/netstat
# Now download the source of that package
apt-get source net-tools
CentOS/Red Hat:
yumdownloader --source net-tools
-
I thought that in Linux are some standard places where I can view source code of various commands without need of downloading.xralf– xralf2011-09-27 09:23:58 +00:00Commented Sep 27, 2011 at 9:23
-
apt-getends with this messageReading package lists... Done Building dependency tree Reading state information... Done E: Unable to find a source package for netstatxralf– xralf2011-09-27 09:24:19 +00:00Commented Sep 27, 2011 at 9:24 -
1Then you'll need to enable the src repos. Go to /etc/apt/sources.list and uncomment the deb-src lines.hmontoliu– hmontoliu2011-09-27 09:28:55 +00:00Commented Sep 27, 2011 at 9:28
-
apt-getwithnet-toolsseems to download it, but where is it saved?xralf– xralf2011-09-27 09:30:30 +00:00Commented Sep 27, 2011 at 9:30 -
4@xralf: you need to explicitly download the source code because most of the distros and users consider it as a waste of space since they trust the build process from the distro.hmontoliu– hmontoliu2011-09-27 09:30:51 +00:00Commented Sep 27, 2011 at 9:30
netstat is part of the net-tools suite. The project home page is here:
https://sourceforge.net/projects/net-tools/
You can browse the netstat source here: http://sourceforge.net/p/net-tools/code/ci/master/tree/ or view the netstat.c file.
Probably you need this: http://www.tazenda.demon.co.uk/phil/net-tools/.
If you need more precise answer - use your local package manager to get info about package containing netstat utility.