In Linux, commands can be categorized into several types based on their source and functionality:
-
Built-in Commands: These are commands that are built into the shell itself. They do not require an external executable. Examples include
cd,echo, andexit. -
External Commands: These are standalone executable files located in the filesystem. They are not part of the shell. Examples include
ls,cp, andgrep. You can find them in directories like/bin,/usr/bin, or/usr/local/bin. -
Aliases: These are shortcuts or custom names for existing commands. You can create an alias using the
aliascommand. For example,alias ll='ls -l'creates an aliasllforls -l. -
Functions: These are user-defined commands that can be created in the shell. Functions allow you to group commands together and execute them as a single command. You can define a function like this:
myfunction() { echo "Hello, World!" } -
Scripts: These are files containing a series of commands that can be executed as a program. Shell scripts typically have a
.shextension and can be run by invoking the script file.
Each type serves different purposes and can be used in various scenarios depending on the user's needs.
