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

Clearing Command History with history -c

history -c is for when "I want to wipe out my entire command history." history -c clears the command history that's accumulated in the terminal.

Use it in the form history -c. -c means clear, and it clears the current session's in-memory history. Erasing history already saved to a file requires an additional step.

Running history -c erases every past command that was previously visible via the history command, leaving the history list empty.

A common early mistake is thinking history is erased, but it was already saved to a history file (like .bash_history), and gets restored the next time you log in.

In real work, this is used when, after working on a shared server, you want to make sure a command containing sensitive info, like a password, doesn't linger in the history.

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

🧑‍💻 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)