Sobes.tech
Junior — Middle

Where does the system get and load the command list when using history?

sobes.tech AI

Answer from AI

The history command in Unix-like systems displays a list of previously entered commands, which the system stores in a special history file. Usually, this file is a hidden file in the user's home directory, for example, ~/.bash_history for Bash.

When the shell is started, it loads commands from this file into memory so they can be viewed and repeated. As work progresses, new commands are added to this file upon session exit or in real-time, depending on the shell settings.

Thus, the list of commands is obtained from the user's history file, which is stored locally in their home directory.