Explaining `type` in Bash

The aim of this page📝is to present the type command in bash. Bash has no types. No objects. Nothing like anobject model in bash — keep that in mind if coming from Python or Powershell. But the type command exists! There are five types — 4 command types (aliases, functions, files, and ~60 shell built-ins) + keyword (~20).

Pavol Kutaj


For each name, indicate how it would be interpreted if used as a command name.

The above is the definition of the type command from


1.1. type indicates a type of command — not not as a variable!

  • note that type in bash does not tell you the type of variable you have - like type(<name>) in Python

Bash doesn’t have types in the same way as Python (although I would say that Python has classes rather than types). But bash variables do have attributes that are given (mostly) through declare, but the range of attributes is fairly small. You can find an attribute using declare -p, for example, declare -i creates an integer


  • coming from Powershell/python then, a weird thing may happen
# python
>>> greeting = "hello"
>>> type(greeting)
<class 'str'>
# powershell
>>> $greeting = "hello"
>>> $greeting.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
# bash
>>> greeting="hello"
>>> echo $greeting
>>> type $greeting
-bash: type: hello: not found
  • there are only 5 possible “types” of commands that the type command returns
  • 4/5 are executable and indeed function as commands; keyword is special
  • NOTE: there is an order in which types are prioritized — see the table below
  • This means that you can overwrite the default type with an alias and it has priority. Also, builtin has a priority over file
$ prnt(){
> echo "you passed me" $*
> }
$ prnt fd fdsfsd fs fdsf
you passed me fd fdsfsd fs fdsf
$ type prnt
prnt is a function
prnt ()
echo "you passed me" $*
  • in PowerShell, type is a built-in alias for Get-Content aka cat command

1.2. referencing 58 bash built-in commands

1.3. referencing 19 bash keywords

1.4. links



Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com