I want to know what exactly are Linux commands? & how to identify and locate them?
In other words what are different kind/type/category of commands? How to identify them and locate (source) it.
I want to know what exactly are Linux commands? & how to identify and locate them?
In other words what are different kind/type/category of commands? How to identify them and locate (source) it.
Following is from from the book The Linux Command Line. The full PDF tutorial is also available here:
A command can be one of four different things:
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.
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.
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.
An alias. Commands that we can define ourselves, built from other commands.
To identify the type of command, you can use type
:
NAME
type - Display information about command type.
Example:
$ type ls
ls is aliased to `ls --color=auto'
$ type cd
cd is a shell builtin
To display the location of command, you can use which
:
$ which info
/usr/bin/info
$ which init
/sbin/init
Hope this is helpful for new users to know basic about commands.
command
in place of both type
and which
- it's the portable way to do it.
– mikeserv
May 28 '14 at 12:46
man
(and maybe info
), and the fact that the shell built-ins for bash
are documented in man bash
.
– goldilocks
May 28 '14 at 13:20