A command in a Linux shell can be one of four things:
- An executable program: This is a file that can be run as a program. This includes compiled binary programs (like those written in C++) and programs written in scripting languages (such as the shell itself, Perl, or Python).
- A shell builtin: A command that is built directly into the shell program itself. For example, the
cdcommand is a shell builtin. - A shell function: A small script that’s integrated directly into the shell’s environment.
- An alias: A custom command you define yourself that acts as a shortcut for another command or sequence of commands.
Identifying Commands
You can use the following commands to determine the type and location of a command:
type: This is a shell builtin that tells you how the shell will interpret a command name. For example,type lsmight show you thatlsis an alias, whiletype cpindicates it’s an executable program at a specific path, like/usr/bin/cp.

which: This command only works for executable programs. It tells you the exact location of the executable file that the shell will run. For example,which lswill output/usr/bin/ls.
Command Documentation and Help
Linux provides several ways to get documentation for commands:
help: Use this for information on shell builtins. You typehelpfollowed by the command name, likehelp cd.--help: Many executable programs support this option to display a brief summary of the command’s syntax and options. You can use it likemkdir --help.man: This command displays a program’s man (manual) page. Man pages are formal reference documents that contain a synopsis, description, and list of options. They are not tutorials and typically don’t include examples.manpages are organized into sections, such as section 1 for user commands and section 5 for file formats. To access a specific section, you useman section number command, such asman 5 passwd.apropos: This command searches the names and one-line descriptions ofmanpages for a given keyword. It’s useful when you don’t know the exact name of a command.whatis: This command provides a one-line summary from a command’smanpage.info: The GNU Project provides an alternative tomanpages called “info” pages. These documents are hyperlinked and structured like a tree, allowing for more in-depth, connected information. You can use commands likenfor next node,pfor previous, andqto quit.
Creating our Own Commands with alias
You can create your own custom commands using the alias command.
- Putting commands on one line: You can combine multiple commands on a single line by separating them with a semicolon (
;). For instance,cd /usr; ls; cd -will change to/usr, list the files, and then return to your original directory. - Creating an alias: The syntax is
alias name='string'. The name is the new command you’re creating, and the string contains the command(s) you want to run. The string must be enclosed in quotes. For example,alias foo='cd /usr; ls; cd -'. - Viewing aliases: To see all aliases currently defined in your shell, you can simply type the
aliascommand without any arguments. - Removing an alias: To remove a temporary alias you’ve created, use the
unaliascommand, such asunalias foo. - Persistence: Aliases created on the command line are temporary and will be gone when your shell session ends.