How to clear terminal history?

QuestionsQuestions8 SkillsProYour First Linux LabOct, 29 2025
0165

To clear the terminal history in a Linux environment, you can use the following command:

history -c

This command clears the current session's history. However, if you want to ensure that the history is also cleared from the history file (usually ~/.bash_history for bash), you can follow these steps:

  1. Clear the current session's history:

    history -c
  2. Clear the history file:

    > ~/.bash_history
  3. Optionally, you can also log out and log back in to ensure that the history is reset.

Keep in mind that clearing history is irreversible, and you will lose access to all previously executed commands.

0 Comments

no data
Be the first to share your comment!