Ad space (banner)
🖥️Linux Lessons
Lesson 26 / 61

Viewing Command History with history

history is for when "I want to use that command I just typed, one more time." history lists every command you've run in the terminal so far.

Just type history alone to run it. Using the number shown next to an entry, typing !number re-runs that specific command.

Running history lists your past commands, numbered, in the order you ran them. Combining it with grep to narrow down a long history is a handy technique.

A common early mistake is typing a command containing sensitive info, like a password, and having it linger in your history forever. Be careful running commands that involve secrets.

In real work, calling up history — either with history or the up-arrow key — is used daily to avoid retyping a long, complex command over and over.

Linux
Try it (type this into the pseudo terminal)
history

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)