You're asking about shell history, which is a very useful feature in the Linux terminal!
Shell history keeps track of the commands you've previously typed, allowing you to recall, edit, and re-execute them without retyping.
Here's how you can check your shell history:
-
To view your command history:
Simply type:historyThis command will display a numbered list of commands you've executed in your current shell session and possibly previous ones, depending on your shell's configuration.
-
To navigate through previous commands:
- Press the Up Arrow key to cycle through your past commands one by one, from most recent to oldest.
- Press the Down Arrow key to go the other way, from older to newer.
-
To search through your history (Reverse Search):
- Press
Ctrl + R. A(reverse-i-search)prompt will appear. - Start typing a part of the command you remember. Bash will show you the most recent command that matches your input.
- Keep pressing
Ctrl + Rto cycle through older commands that also match. - Once you find the command you want, you can press
Enterto execute it, or theLeft/Right Arrowkeys to edit it before executing.
- Press
-
History file:
Your shell history is usually stored in a file in your home directory. For Bash, it's typically~/.bash_history. You can view this file directly with a text editor likecat,less, ornano:cat ~/.bash_historyThis file often contains a larger history than what
historycommand shows in a single session, ashistoryonly shows current session and then appends from the file when shell exits.
This feature is incredibly helpful for productivity when working in the terminal!
Does that help you check your shell history?