How to Describe a Command in Linux

The "type" command in Linux is one of the more useful commands yet it is also one of the more obtuse. Using the "type" command shows how any of the commands or names you include beyond the command would be interpreted if input. This means that it would explain any macros you created, any commands you've aliased or any other additions you've made to the BASH (BASH= Bourne-Again SHell).

Things You'll Need

  • Linux
  • BASH
Show More

Instructions

    • 1

      Create aliases for commands in order to make the "type" command useful. For example, you may want to shorten a string like ls -F to simply ls. Typing alias ls='ls -F' would make the standard ls command behave as the ls -F command instead. In general, creating aliases reduces the amount of time it takes to enter commands, and incorporates your own personal preferences.

    • 2

      Use a text editor to create a BASH file containing all of your aliases. Name the file .bash_aliases, and it will run when Linux boots. Creating your list of aliases in this way makes it so you don't have to enter them line by line in the BASH console.

    • 3

      Type "type [-atp] [name ...]" at the BASH prompt to use the "type" command. This will return the current value for the [name ...] you indicate, as well as adjust the output according to the parameters you include. For example, if you were to type "type ls" then you would receive "ls -F" as a return.

    • 4

      Include the command line switches "-a," "-t" or "-p" to change the parameters of the type command at the time of use. Using "-a" will display a list of all executables with the file name.

    • 5

      Note what each command line parameter's function is. Using "-t" will display a single word relating to the actual type of the command you wish to describe (alias, function, builtin, keyword or file). Using "-p" will display the name of the file used with the "type" command.

Tips & Warnings

  • Keep a list of your aliases and macros on hand so you don't always have to rely on "type." Some people choose to collate their commands via printout while others just rely on pen and paper.

  • Syntax is incredibly important with the "type" command. If you fail to type elements of the "type" command accurately then it will fail to describe your selected functions and instead simply return blank. Make it a habit to check your typing prior to pressing "Enter."

Related Searches:

Resources

Comments

You May Also Like

Related Ads

Featured