How to check shell history?

QuestionsQuestions8 SkillsProDec, 11 2025
0111

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:

  1. To view your command history:
    Simply type:

    history

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

  2. 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.
  3. 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 + R to cycle through older commands that also match.
    • Once you find the command you want, you can press Enter to execute it, or the Left/Right Arrow keys to edit it before executing.
  4. 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 like cat, less, or nano:

    cat ~/.bash_history

    This file often contains a larger history than what history command shows in a single session, as history only 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?

0 Comments

no data
Be the first to share your comment!