LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2015, 03:26 AM   #1
timdog335
LQ Newbie
 
Registered: Nov 2015
Posts: 1

Rep: Reputation: Disabled
Question 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?
 
Old 11-30-2015, 04:12 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,420

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
https://askubuntu.com/questions/1039...minal-commands
 
Old 11-30-2015, 04:20 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,122

Rep: Reputation: 190Reputation: 190
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.
 
Old 11-30-2015, 04:23 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,029
Blog Entries: 1

Rep: Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114
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.
 
Old 11-30-2015, 07:18 AM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 7,680
Blog Entries: 10

Rep: Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080
Open terminal and type
Code:
type dir
to see if yours is a binary or an alias.
 
Old 11-30-2015, 08:27 AM   #6
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,796

Rep: Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619
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.
 
Old 11-30-2015, 09:21 AM   #7
LanceTaylor
Member
 
Registered: Nov 2015
Location: Houston, Texas, US
Distribution: RHEL/CentOS, Debian/Linux Mint, SLES
Posts: 40

Rep: Reputation: 19
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copying files from home dir to another dir from another dir in a lower dir chomito44 Linux - General 5 10-19-2013 07:18 PM
Move files contained in source dir to destination dir, but not source dir itself unixunderground Linux - Software 3 09-20-2013 12:17 PM
tar dir and sub dir removing files but not existing not empty dir j-me Linux - General 2 08-12-2013 12:37 PM
exclude parameter of rsync- 'dir' vs "dir" vs dir rng Linux - General 5 06-13-2012 02:47 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 03:57 PM


All times are GMT -5. The time now is 01:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration