Skip to main content
LPIC-1 Exam 101

LPIC-1 Using the command type

By June 28, 2015September 12th, 2022No Comments

For objective 104.7 of the LPIC-1 101 exam there are a few commands to look at, one of which is type. The command type itself is a shell builtin, in other words the program is part of the BASH shell and not a stand-alone program. Try the following command :

$ type type

In the above example we are using the command type with an argument of type. I know it looks strange but it is an introduction to the command. We should be able to see the output similar to the following:

type is a shell builtin

Now that we have been able to determine the type of command it is we can realise other information about the command. Being a shell builtin there will not be a man page. We will need to use man bash and search for the type in the man page. There is no explicit help for type but using type –help is an invalid option and display the usage statement

As we saw for the command type it was a shell builtin; however It could be 1 of the following 5 types

  1. Alias
  2. Shell Builtin
  3. Keyword
  4. Function
  5. Command File

If we use check on type ls, most often this will report as an alias. Trying the command type case should return a shell keyword. If we unalias ls, and then try type ls again we should see that it is hashed to a file.

Lets start to look at some of the useful options. We can also use type to show all types for a given command; for example with ls aliased as normal we can use type -a ls and the output will show that is found as an alias first and then the file:

$ type -a ls
ls is aliased to 'ls --color=auto'
ls is /bin/ls

The use of type -t will just show the the single word type of a command:

$ type -t if