outputI know that we can invoke the Unix or Linux command by its absolute file path as well as the command itself. For instance we can list directory contents by typing ls as well as /bin/ls (in Linux) Is there any difference?. When i do this i got the same output but only difference in its color separation between file types you can see that in uploaded image.


Giving the command ls at the prompt would do a bit more than just call /bin/ls. If ls was an alias or a function, that alias or function would be called. If it was neither, and if it furthermore was not a built-in command (ls is very rarely a built-in command), then a path search would be performed for ls in each directory in the :-delimited list in the $PATH environment variable.

The ls that was first found in $PATH would be executed. This could potentially be another ls than /bin/ls if a directory that contained such a name was located earlier than /bin in the $PATH list.

Using /bin/sh would bypass the alias and function lookups as well as any lookups in $PATH and would instead run that command directly.

The difference in colour in the output between ls and /bin/ls could possibly be explained by ls being an alias that adds extra command line options when invoking the ls utility (check with alias ls or type -a ls in bash).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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