LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls vs dir (https://www.linuxquestions.org/questions/linux-newbie-8/ls-vs-dir-4175560205/)

timdog335 11-30-2015 02:26 AM

ls vs dir
 
Hi all-

It's my understanding that ls the Linux command for listing files, but both my distros (Debian and Fedora) have the dir command as well. I can't tell any difference between the two in the man pages. What is the difference between ls and dir, if any?

descendant_command 11-30-2015 03:12 AM

https://askubuntu.com/questions/1039...minal-commands

JJJCR 11-30-2015 03:20 AM

from the link descendant_command had given:

Short Answer : None, dir is an alias of ls, ls have --color by default

it's giving you convenience only, if you are switching back and forth from Win to Lin and if the thing that is on the top of your head is dir since you are in Windows the moment you switch to Linux chances dir still on your mind, so you might type it also.

astrogeek 11-30-2015 03:23 AM

Almost...

But dir is not an alias for ls - it is a separately compiled binary.

As I recall dir shares most or all of the ls code base, but still it is a separate binary, not an alias.

Habitual 11-30-2015 06:18 AM

Open terminal and type
Code:

type dir
to see if yours is a binary or an alias.

wpeckham 11-30-2015 07:27 AM

Mint
 
On my system dir appears a separate binary, but upon examination is a hard link to ls.
On other systems it may be a soft link or an alias. (On my AIX and HP-UX system it used to be an alias.)

I would not obsess over it. There are many such examples of the Linux distro managers or package maintainers trying to make life easy for Microsoft refugees.

LanceTaylor 11-30-2015 08:21 AM

On my Linux Mint system, they are two distinct binaries, but they are exactly the same size.

Code:

$ stat /bin/dir
  File: ‘/bin/dir’
  Size: 110080            Blocks: 216        IO Block: 4096  regular file
Device: 805h/2053d        Inode: 34475110    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2015-07-06 18:43:15.000000000 -0500
Modify: 2015-01-13 21:50:14.000000000 -0600
Change: 2015-07-06 18:43:16.215392819 -0500

$ stat /bin/ls
  File: ‘/bin/ls’
  Size: 110080            Blocks: 216        IO Block: 4096  regular file
Device: 805h/2053d        Inode: 34475127    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2015-11-30 07:35:04.012739573 -0600
Modify: 2015-01-13 21:50:14.000000000 -0600
Change: 2015-07-06 18:43:16.215392819 -0500

The man pages for each show that they are both written by Richard M. Stallman and David MacKenzie.
The only differences in the man pages is that any reference to "ls" is replaced with "dir".
So, although they are distinct binaries, it appears that they are likely the same code.


All times are GMT -5. The time now is 07:01 AM.