how differently is "dir" command in windows and "ls" command in linux processed by the operating system??

link|improve this question

ls is an external program, not part of the OS or even of the shell. I believe that dir is part of the CMD.exe "shell". – Paul Tomblin Oct 11 '10 at 17:17
This isn't a programming question. Voting to migrate to Super User, where it's on topic. – David Thornley Oct 11 '10 at 17:45
so to be clear when i do "ls",does it forks a new process?does windows do the same? – user34373 Oct 11 '10 at 17:48
You can type ls in PowerShell as well. – paradroid Oct 11 '10 at 23:00
feedback

migrated from stackoverflow.com Oct 11 '10 at 20:48

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 7 down vote accepted

They are quite different:

On Windows, dir is an internal command, part of the command interpreter (cmd.exe). You won't find a dir.exe file on your system. In other words, dir is handled internally without executing another process. If you write a program, you can't launch dir directly (though you can run it through cmd, which is why for you can run os.system("dir") in Python or system("dir") in Perl).

On Linux, ls is a regular old program, just like any other, usually located at /bin/ls. You can even download the source and have a look for yourself. It is part of GNU coreutils. When you run ls, a new process is created (fork/wait) without any hidden magic.

link|improve this answer
so to be clear when i do "ls",does it forks a new process?does windows do the same? – user34373 Oct 11 '10 at 17:36
feedback

Your Answer

 
or
required, but never shown

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