Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

macOS Terminal caches the commands that are executed in its command history. This is a list of recently typed commands that is preserved between Terminal sessions.

Whenever a command is executed in Terminal, it is added to the command history. You can view this history by typing the following command:

history

By default, the command history is saved to a file on your computer. This file is called .bash_history and it is located in your home directory. The history file is read each time a new Terminal session is started and the commands in it are added to the command history.

The size of the command history is controlled by the value of the HISTSIZE environment variable. By default, this variable is set to 500, meaning the Terminal will keep the last 500 commands in the history. You can modify this value in your shell configuration file (usually ~/.bash_profile or ~/.bashrc) to increase or decrease the size of the history.

The command history can be useful for quickly repeating previous commands or finding a command that you executed earlier. You can also use the arrow keys to navigate through the command history and edit previous commands before executing them again.