Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I want to know what exactly are Linux commands? & how to identify and locate them?

share

marked as duplicate by Gilles May 28 at 23:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

excerpt from the book The Linux Command Line. The full PDF tutorial is also available here. The below excerpt is verbatim from this book, p. 42.

A command can be one of four different things:

  1. An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in scripting languages such as the shell, perl, python, ruby, etc.

  2. A command built into the shell itself. bash supports a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.

  3. A shell function. These are miniature shell scripts incorporated into the environ- ment. We will cover configuring the environment and writing shell functions in later chapters, but for now, just be aware that they exist.

  4. An alias. Commands that we can define ourselves, built from other commands.


It is often useful to know exactly which of the four kinds of commands is being used and Linux provides a couple of ways to find out.

  • type – Display A Command's Type

    The type command is a shell builtin that displays the kind of command the shell willexecute, given a particular command name. It works like this:

    type <command> Ex:
    
    type ls
    ls is aliased to `ls --color=tty'
    
    type cd
    cd is a shell builtin
    
  • which – Display An Executable's Location

    Ex:

    which ls
    /bin/ls
    

Hope This is helpful for new users to know basic about commands.

share
2  
This is pretty good. A suggestion - you might use command in place of both type and which - it's the portable way to do it. –  mikeserv May 28 at 12:46
4  
What's the source? This is obviously copied from a book/tutorial but I don't see any reference to it. –  Creek May 28 at 12:49
    
@mikeserv You mean command -v? –  Hauke Laging May 28 at 12:58
1  
@Pandya - always be sure to cite sources. It's perfectly fine to replicate here so long as the source materials are properly sourced. –  slm May 28 at 13:14
    
@HaukeLaging - yes, that is one operand. –  mikeserv May 28 at 13:16

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .