When people start learning Linux, one of the first things they discover is the terminal. At first, it looks simple: type a command, press Enter, and something happens.
ls
The files appear.
cd /home/user
The directory changes.
echo "Hello"
A message appears on the screen.
But behind this simple interaction is a powerful system that has been developed over decades. Bash is not just a program that launches other programs. It is a complete command interpreter with its own language, syntax, variables, functions, and a large collection of built-in commands.
Understanding these built-in commands is one of the most important steps toward becoming comfortable with Bash.
Without knowing them, you will not only struggle to write even simple shell scripts, but everyday work in the terminal will also remain much slower and less efficient.
This article starts a new section dedicated to Bash built-in commands. Each command will be explained separately in future posts, with examples and practical use cases.
What Are Bash Built-in Commands?
When you type a command into Bash, it does not always launch an external program.
For example:
ls
usually runs an external program located somewhere like:
/usr/bin/ls
However:
cd
does not work this way.
There is no standalone:
/usr/bin/cd
program.
Instead, cd is implemented directly inside Bash.
These commands are called built-in commands.
They are part of the shell itself.
You can check this using:
type cd
The result:
cd is a shell builtin
Another example:
type echo
Output:
echo is a shell builtin
Bash knows how to execute these commands internally without starting another program.
Why Does Bash Need Built-in Commands?
At first glance, you may wonder:
Why not just make everything a normal external program?
The answer is that some operations must modify the current shell environment.
The best example is cd.
Imagine that cd was an external program:
cd /home/user/Documents
Bash would start a new process:
bash
|
+-- cd program
The cd program changes its own directory and exits.
But the original shell is still in the same place.
Your terminal would not actually move anywhere.
Therefore, commands like:
cdexportunsetsourceexitread
must run inside the current shell process.
This is why Bash provides them internally.
How This Series Will Be Organized
The list of Bash built-in commands is quite large, so instead of creating one enormous article that nobody wants to read from beginning to end, each command will have its own dedicated post.
Every article in this series will follow the same structure:
1. Command name and short explanation
Example:
cd - Change the current directory
2. Command syntax
The general form of the command:
cd [-LP] [directory]
3. Options and parameters
Explanation of every available option.
Example:
-L
Use logical paths
-P
Use physical paths
4. Detailed explanation
A complete explanation of:
- what the command does
- why it exists
- when to use it
- possible problems
- practical examples
5. Examples
Commands beginning with:
$
are examples that should be typed directly into the terminal.
Example:
$ pwd
/home/user
Examples containing:
#!/bin/bash
are complete scripts.
Example:
#!/bin/bash
echo "Hello from Bash"
These should be saved into a file and executed as scripts.
At the end of every article, there will also be a link back to this complete list of Bash built-in commands.
Complete List of Bash Built-in Commands
Below is the complete list of commands that will be covered in this series.
Shell Syntax and Structure
!
Negates the result of the following command.
Example:
! grep "error" logfile.txt
Normally, grep returns success when it finds something.
Adding ! reverses the result.
#
Comment
Everything after this symbol is ignored by Bash.
Example:
# This line explains what the script does
echo "Hello"
Comments are essential for readable scripts.
#!
Interpreter declaration (shebang)
Example:
#!/bin/bash
This tells Linux which interpreter should execute the script.
:
Empty command
The colon command does nothing and always returns success.
Example:
:
It is often used in scripts where Bash syntax requires a command.
.
Execute commands from a file
Example:
. configuration.sh
It executes another script inside the current shell.
Similar to:
source configuration.sh
[[ ]]
Advanced conditional expression
A more powerful version of:
test
Example:
if [[ $USER == "root" ]]
then
echo "Administrator"
fi
Functions and Variables
name()
Create a Bash function
Example:
hello()
{
echo "Hello"
}
Functions allow you to organize reusable pieces of code.
function
Alternative syntax for creating functions.
Example:
function hello
{
echo "Hello"
}
alias
Create command shortcuts.
Example:
alias ll="ls -la"
Now:
ll
runs:
ls -la
declare
Create variables and control their attributes.
Example:
declare -i number=10
Creates an integer variable.
local
Creates variables available only inside functions.
Example:
my_function()
{
local value="test"
}
readonly
Creates variables that cannot be changed.
Example:
readonly VERSION="1.0"
export
Makes variables available to child processes.
Example:
export PATH
unset
Deletes variables.
Example:
unset NAME
Directory Navigation
cd
Change current directory.
Example:
cd /var/log
pwd
Display current directory.
Example:
pwd
dirs
Display directory stack.
pushd
Save a directory and move there.
popd
Return from directory stack.
Script Flow Control
if
Conditional execution.
Example:
if [ "$USER" = "root" ]
then
echo "Admin"
fi
case
Multiple-choice conditions.
for
Loop through values.
Example:
for file in *
do
echo $file
done
while
Loop while condition is true.
until
Loop until condition becomes true.
break
Exit a loop.
continue
Skip the current loop iteration.
return
Return from a function.
exit
Exit a script.
Input and Output
echo
Print text.
Example:
echo "Hello Bash"
printf
Formatted output.
Example:
printf "Number: %d\n" 10
read
Read input from users.
Example:
read NAME
mapfile
Read file contents into an array.
readarray
Alias for mapfile.
Process Management
jobs
Show background jobs.
bg
Move a process to background.
fg
Bring a process to foreground.
kill
Send signals to processes.
Example:
kill 1234
wait
Wait for processes to finish.
disown
Detach processes from Bash.
suspend
Pause the current shell.
Command Management
command
Execute commands while ignoring functions.
builtin
Force execution of a built-in command.
enable
Enable or disable built-in commands.
type
Show command type.
Example:
type ls
hash
Manage remembered command locations.
help
Display Bash help.
Example:
help cd
History and Debugging
history
Show command history.
fc
Manage history commands.
caller
Display calling function information.
trap
Handle signals.
Example:
trap cleanup EXIT
Advanced Shell Control
eval
Execute generated commands.
exec
Replace the current process.
source
Execute a file in the current shell.
set
Configure shell options.
shopt
Manage Bash-specific options.
shift
Move script parameters.
getopts
Process command-line arguments.
time
Measure command execution time.
times
Display accumulated CPU time.
ulimit
Control resource limits.
umask
Control default file permissions.
Boolean Commands
true
Always returns success.
Example:
true
echo $?
Output:
0
false
Always returns failure.
Example:
false
echo $?
Output:
1
Conclusion
Bash built-in commands are the foundation of shell scripting.
They are the tools that transform Bash from a simple command launcher into a complete programming environment.
Learning these commands will help you:
- write better scripts
- understand how Bash works internally
- automate repetitive tasks
- troubleshoot problems faster
- become much more comfortable with Linux
This article is only the beginning. Each command listed above deserves its own explanation, examples, and practical discussion.
The next posts in this series will explore these commands one by one, starting from the simplest commands and gradually moving toward more advanced Bash scripting techniques.