0

I am working on linux, and came across instances netstat -an and netstat -na.

Are they both same.what are their significance

user1885159
  • 45
  • 1
  • 6
  • We live in 21st century and we are supposed to migrate to `ss -a` (`ss` doesn't resolve names by default, no need for `-n`.) – nodakai Feb 06 '14 at 10:20

3 Answers3

3

Both having the same effect.

Most of the programs found on a GNU/Linux system, as netstat, using the glibc function getopt for parsing their command line arguments. That's why you have to look at the documentation of GNU getopt, especially it's argument syntax which follows the POSIX standard. Here it is: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html

However, not all programs are using this syntax. Especially shell scripts or programs written in a language that has no bindings for GNU getopt. This means the question can't be answered in general, you need to check the man page if you want to know the exact argument syntax for a certain program. But netstat uses getopt.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
1

It doesn't matter how you pass the arguments to below,

while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuVv?wxl", longopts, &lop)) != EOF)
   switch (i) {
     ...
   case 'a':
      flag_all++;
      break;
   case 'n':
      flag_not |= FLAG_NUM;
      break;
     ...

Just the cases a & n are enabled which is processed later with the respective flags set.

Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46
0

There is no difference in "-an" and "-na"

user2699113
  • 4,262
  • 3
  • 25
  • 43