Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
$ help type
type: type [-afptP] name [name ...]
Display information about command type.
For each NAME, indicate how it would be interpreted if used as a
command name.
----------------------
So here are some command types:
$ type type
type is a shell builtin
$ type bash
bash is /bin/bash
$ type ls
ls is aliased to `ls --color=auto'
$ type mkdir
mkdir is hashed (/bin/mkdir)
$ type echo
echo is a shell builtin
$ type ps
ps is /bin/ps
Questions:
What is the difference of command types between the outputs above?
We have these groupings:
a) bash is /bin/bash, ps is /bin/ps
b) mkdir is hashed (/bin/mkdir)
c) echo is a shell builtin
c) ls is aliased to `ls --color=auto'
What are the differences amongst the command types?
Note: I understand what alias is.
As an example, why is mkdir called a hashed command, and
bash or ps is just shown as a /path/filename,
and echo is called a shell builtin.
I also thought bash is a shell.
So the output of type command is confusing to me.....
Thank you.
Some command interpreters maintain a hash table of frequently used commands.
This eliminates having to search through a long PATH environment variable to find a corresponding executable for a command.
It can cause some problems when the command is added to a directory in the path, but not where the hash table has it recorded. These interpreters also include a "rehash" command that causes it to make a pass through the directories and identify new entries, and generate a new hash table.
The "type" command allows you to identify what is actually going to be used when a given command is issued. If a command is located in the hash table it lets you know that (useful if you expected a different result in a command).
The way shells interpret commands is also why the "." is normally excluded from the search path as a security hazard. You really don't want someone elses command to be picked when you really wanted the one you always use...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.