What is a Command in Bash?

Bash Liste Des Attaques Ovh


This page is about command in bash.

Command are in bash the expression unit

A command (or an expression) is a sequence of words separated by blanks, terminated by a control operator.

For the builtin bash function command, see Bash - Command (The Builtin command command)

Each command execution has an environment.

Search Order

The default order for command lookup is:

There are three built-ins that you can use to override this order:

Exit Status

The return status (of Exit Status) is:

  • its exit status as provided by the POSIX 1003.1 waitpid function,
  • or 128+n if the command was terminated by signal n.



See Bash - Command Execution

Check availibilty

# Check the command $1
function check_command() {
	command -v $1 -v 2>&1 > /dev/null || { echo >&2 "I require $1 but it's not installed.  Aborting."; exit 1; }


Linux - man (Manual, Help, Documentation)


To create a shortcut of a command with parameters, see Bash - Alias (of a command) - Builtin command

List the history of the command called


With the command history:


you will get an history of the command

1000  cat installation_overview_di.txt
 1001  fc -l 999
 1002  man fc
 1003  history
 1004  history|grep NQS
 1005  ls -al
 1006  ls -al
 1007  dir
 1008  history

The exclamation mark start a history command substitution, except when followed by a space character, tab, newline, = or (.

  • !! execute the last command executed. It would execute the history command (1008)
  • !str - Re runs the last command that you ran that starts with str (string). For instance, !ls would execute the last ls command ie the command 1006
  • !1007 Rerun the command 1007. A dir command in our case.
  • !-2 Refer to the current command line minus 2. Ie the command 1007 (dir)
  • !?str? - Refer to the most recent command containing str (string). For instance, !?al? will start the command 1000 and not the command 1006 because it does not take into account the option !


The 'fc' utility lists or edits and re-executes, commands previously entered to an interactive sh.

fc -l 999

will list the last 999 command

Ctrl + r

List of common command

Command Description
ifconfig To detect the IP Adress
netstat -rn routing table
Ctrl+C interruption of script
hostname name To set the hostname, name is the system name you want for your local machine (fully qualified domain name or not)
Navigation / NFS
mkdir make directory
cd change directory ( cd .. is the shortcut for moving up one directory level).
ex. cd “Entreprise Linux 2007”
ls ls -a show the cached file
mv Changes the names of directories and subdirectories mv old_name new_name
pwd display the name of the current directory. The pwd command stands for “print working directory”
which give the path of a file. Ex : “which java” return “/usr/bin/java”
ln make links (short cut) between files
df Disk Free to know the used space (Example: df -h where h stands for human readable)
rm delete a file
rmdir delete a directory
CD Rom
mount On redhat linux 6 or below: mount /dev/hdc /mnt/cdrom and for above versions: mount /dev/cdrom /mnt/cdrom
echo To get the value of en environment variable (ex.: echo $ARBORPATH)
env or set A long list of bash environment variables appears
whoami Return the current user
top display top CPU processes
Text Manipulation
grep filters content based on certain strings
sed search and replace
awk sed and grep in one tool

Documentation / Reference

Discover More
Bash Liste Des Attaques Ovh
Bash - History (builtin command)

history is a Builtin Command that shows the history of the command executed. A space at the start of a command will stop the command (and any password) from being stored in the history. With...
Bash Liste Des Attaques Ovh
Bash - (Argument|Positional Parameter)

An argument is a parameter given: to a command to a function or to the bash shell They are referenced by position. A positional parameter is a parameter denoted: by one or more digits, ...
Bash Liste Des Attaques Ovh
Bash - (Builtin|Intern|System|Reserved|Shell) variable name

Reserved variable name are named that have a special meaning for the bash shell. PS1 defines the shell's command-line prompt. HOME defines the home directory for a user. PATH defines a list...
Bash Liste Des Attaques Ovh
Bash - (Return|Exit) (Value|Status)

The return status (also known as Exit Status of Exit Code) of a simple command is its exit status as provided by: the posix 1003.1 waitpid function, or 128+n if the command was terminated by signal...
Bash Liste Des Attaques Ovh
Bash - Alias (of a command) - Builtin command

Alias allows to define shortcuts and synonyms for commonly used: shell commands (of group of command) or script The basic syntax is: where: p is to only print the aliases [name[=value]...
Bash Liste Des Attaques Ovh
Bash - Bash cli

Bash is an sh-compatible a shell that executes commands read: from the standard input or from a file (script). In addition to the single-character shell options documented in the description...
Bash Liste Des Attaques Ovh
Bash - Builtin Commands

builtin refers to: a builtin command. See or to the specific builtin command. See (useful when defining a function whose name is the same as a shell builtin) The builtin command execute the specified...
Bash Liste Des Attaques Ovh
Bash - Case

The case control statement execute commands based on regular expression pattern matching. Initscript example: Selectively execute COMMANDS based upon WORD matching glob PATTERN. The | is used to...
Bash Liste Des Attaques Ovh
Bash - Command (The Builtin command command)

command The command function suppress the the shell function lookup in the search command order. For command as a bash definition, see . where: command is the command to execute. Only builtin...
Bash Liste Des Attaques Ovh
Bash - Command Execution

To execute a command in a script backticks in the same shell $( ) in a subshell from a string in a subshell from standard input See also: You can execute an expression inside an input...

Share this page:
Follow us:
Task Runner