EDX Linux Foundation Ch 9:User Environment Section 3 and 4

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
ubuntu@ip-172-31-27-94:~$ echo $HISTFILESIZE
ubuntu@ip-172-31-27-94:~$ echo $HISTSIZE

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

Creating 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.



alias 縮寫=’指令’