1

This question already has an answer here:

From ls --help, dir --help, vdir --help I notice there's no difference at all except for program names (the 'Usage: ' line and a few lines at the bottom). However vdir seems to be some kind of an alias of ls -l, while dir seems like making no difference. Can anyone tell me what are the exact differences among them?

marked as duplicate by JdeBP, Kiwy, schily, RalfFriedl, Anthony Geoghegan Nov 8 '18 at 23:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • aren't dir & vdir just aliases to variations of ls? – Jeff Schaller Feb 11 '17 at 12:10
  • @JeffSchaller They are 3 separate binary executables in GNU Core Utilities. That's the reason for the title. – iBug Feb 11 '17 at 12:21
  • ok; first google hit made it look like an alias: gnu.org/software/coreutils/manual/html_node/… – Jeff Schaller Feb 11 '17 at 12:28
  • 1
    this doesn't explain why they had to make dir and vdir separate executables instead of hardlinks to ls; a lot of programs work differently by checking the argv0 (eg. ex vs vi); why aren't they doing the same? – mosvy Nov 7 '18 at 10:24
4
  • From info dir: dir is equivalent to ls -C -b
  • From info vdir: vdir is equivalent to ls -l -b

On an Ubuntu system I have, they appear to be the same binary (they have same exact size), but are not linked to each other, but I assume they could be:

$ ls -li /bin/{ls,dir,vdir}
131116 -rwxr-xr-x 1 root root 126584 Feb 18  2016 /bin/dir
131160 -rwxr-xr-x 1 root root 126584 Feb 18  2016 /bin/ls
131261 -rwxr-xr-x 1 root root 126584 Feb 18  2016 /bin/vdir

On my OpenBSD system, the sizes differ in a way that makes me think that the only thing that differs between them is the name of the utility stored in the binary itself:

$ ls -li /usr/local/bin/{gls,gdir,gvdir}
390089 -rwxr-xr-x  1 root  bin  191244 Dec 30 12:31 /usr/local/bin/gdir
390113 -rwxr-xr-x  1 root  bin  191243 Dec 30 12:31 /usr/local/bin/gls
390185 -rwxr-xr-x  1 root  bin  191245 Dec 30 12:31 /usr/local/bin/gvdir
  • they aren't linked to each other; they're built as separate executables -- see ls-dir.c and ls-ls.c – mosvy Nov 7 '18 at 10:30
  • ... and comparing them shows they differ, if only by a few bytes. – Stephen Kitt Nov 7 '18 at 19:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.