FactorPad
Faster Learning Tutorials

Linux type command summary with examples

type allows you to show a command's type and location.
  1. Purpose - Learn what type is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with type.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 8, 2016
Updated: July 26, 2018
In this tutorial, 11 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / type command


The Linux type command

Beginner

Learn to find a file's type and location at the Linux command line.

Video Tutorial

Linux type command summary with examples (4:02)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our eleventh word, or command to memorize is type from the category Help.

type allows you to show a command's type and location. In our last video we wanted to send output to a file instead of the screen. So here we'll use the type command to do that.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The type command has 5 options, and arguments you provide are the commands you're interested in learning about.

Let's discuss three command types: first, the 60 or so bash shell builtins we saw in video 9. Second is a vast group of non-shell commands. Third, are aliases which we will cover in our next video.

To access types, we'll go option-less, and use the -t option. The second capability is to add locations, using the -a option.

So why is type an important command? Well, type is a nice way to start your search for help. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go, start with an easy one, type type.

$ type type type is a shell builtin

Ok, it's a builtin. Next, let's pass multiple arguments, from our four previous videos.

$ type ls cd bash cat ls is aliased to `ls --color=auto' cd is a shell builtin bash is /bin/bash cat is hashed (/bin/cat)

Now, up arrow, add the -t option and compare.

$ type -t ls cd bash cat alias builtin file file

See, shorter types, for the descriptions. Next, let's get command types and locations using -a.

$ type -a ls cd bash cat ls is aliased to `ls --color=auto' ls is /bin/ls cd is a shell builtin bash is /bin/bash cat is /bin/cat

And last, let's tackle the problem from the last video and create a file with the same output. Find the command with up arrow, and redirect output with this symbol >, a file name and examine.

$ type ls cd bash cat > video11.txt $ cat video11.txt ls is aliased to `ls --color=auto' cd is a shell builtin bash is /bin/bash cat is hashed (/bin/cat)

A Final Tip

Okay now you know how to use type. And you know the syntax for commands, options and arguments.

One last tip about the type command. So we touched on alias here but didn't explore it, so tune in for our next video. Later, we'll also discuss a fourth command type called a function.

Okay, thanks for visiting today. I hope this was a fun introduction to the type command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Like what you see? Subscribe and tell a friend.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the cat command, hit Back.
  • To learn how to save keystrokes with the alias command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / type command



 
 
Keywords:
linux type command
type linux
find files in linux
find programs in linux
linux file types
linux builtin type
alias type in linux
hashed type in linux
file locations in linux
shell type
linux print to file
caret symbol in linux