Click on each book below to review & buy on Amazon.
As an Amazon Associate, I earn from qualifying purchases.
LPI Linux Essentials Exam 010-160 - Topic 2.1 - Command Types - Internal vs External
In the Linux operating system, commands can be categorized into two primary types: internal commands and external commands. The distinction between these two types is essential to comprehend how the shell processes commands.
Internal Commands
Internal commands, also known as built-in commands, are an integral part of the shell itself. These commands are directly executed by the shell without the need for invoking an external program. This inherent integration makes internal commands more efficient, as they do not require the overhead of creating a new process. Common examples of internal commands include cd
for changing directories, echo
for printing text, pwd
for displaying the current working directory, and alias
for creating custom command shortcuts.
External Commands
External commands, in contrast, are standalone programs or scripts residing in directories specified in the system's PATH
environment variable. When you issue an external command, it is executed by the shell as a separate process. External commands can include a wide range of utilities, either provided by the Linux distribution or third-party software. Popular external commands comprise ls
for listing directory contents, cp
for copying files, and grep
for searching text. Additionally, custom scripts or programs you create and install are also considered external commands.
Using the type
Command
To distinguish between internal and external commands, the type
command in Linux serves as a helpful tool. It reveals the nature of a given command by specifying whether it's internal or external. The command will return either command is a shell builtin
for internal commands, or it will return something else such as the full command path, or whether it is an alias for an external command. The following exercise will get you using the type
command to see the differences:
Exercise: Using the type
command, identify whether a command is an internal or external command:
Check what type of command cd
is:
type cd
The output will resemble, the following, indicating it is an internal command:
cd is a shell builtin
Check what type of command echo
is:
type echo
The output will resemble, the following, indicating it is an internal command:
echo is a shell builtin
Check what type of command ls
is:
type ls
The output will resemble, the following, indicating it is an external command:
ls is aliased to `ls --color=auto'
Check what type of command cp
is:
type cp
The output will resemble, the following, indicating it is an external command:
cp is /usr/bin/cp
Support DTV Linux
Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.
NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.