Section 3:Recalling Previous Commands
Up and Down
you can recall previously used commands simply by using the Up and Down cursor keys.
To view the list of previously executed commands, you can just type history at the command line.
The list of commands is displayed with the most recent command appearing last in the list. This information is stored in ~/.bash_history.
Using History Environment Variables
$HISTFILE stores the location of the history file. $HISTFILESIZE stores the maximum number of lines in the history file. $HISTSIZE stores the maximum number of lines in the history file for the current session.
ubuntu@ip-172-31-27-94:~$ echo $HISTFILE /home/ubuntu/.bash_history ubuntu@ip-172-31-27-94:~$ echo $HISTFILESIZE 2000 ubuntu@ip-172-31-27-94:~$ echo $HISTSIZE 1000 ubuntu@ip-172-31-27-94:~$
Finding and Using Previous Commands
Up/Down arrow key
Browse through the list of commands previously executed
!! (Pronounced as bang-bang)
Execute the previous command
Search previously used commands
Executing Previous Commands
Section 4:Command Aliases
You can create customized commands or modify the behavior of already existing ones by creating aliases. Most often these aliases are placed in your
~/.bashrc file so they are available to any command shells you create.