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.– xralfSep 27, 2011 at 9:23
-
apt-get
ends with this messageReading package lists... Done Building dependency tree Reading state information... Done E: Unable to find a source package for netstat
– xralfSep 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. Sep 27, 2011 at 9:28
-
-
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. 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.