How to Clear the Terminal History on Linux or Mac OS

Mac or Linux have a very convenient terminal app through which various actions can be completed by executing different pre-defined commands.

The commands could be very complex at times, and if, for some reason, these commands are to be put in several times, you might get frustrated very soon.

But for that purpose, the developers of these systems have ejected inside the feature of saving the commands as history through which the users could easily press the UP arrow button to get their last used command on the terminal screen.

It could be continuously done to get back to many other past commands. This history of the commands would be rather very useful. Still, at times it could also prove fatal if you suddenly put in any other command by mistake, so to solve this, you could prefer to delete up to the history of the terminal.

Steps to Clear the Terminal History on Linux or Mac OS

Here in this article, we have written the method with which you could clear the Terminal History on Linux or Mac OS.

1. To clear the history of the current terminal session on your Mac or Linux, use the command “history -c“. This is the command built into bash itself and deals with the history of the commands in the terminal and hence tells to delete or clear all for the current session.

Now, if you have any command histories on the terminal for the all-new session, you can easily clear it up through the command above.

command

2. To clear the entire history of your terminal bash, you would require using the command “rm -/.bash_history“. This command also deals with the stored history of the terminal app for the new session. You could use this command to delete the history of commands stored in the bash as text files from the previous sessions.

rm -/.bash_history

3. To manually open the history text file and delete the items or the commands from it, just type in the command “open ~/.bash_history” or use up the name of the text editor in the place of open in the command for use in Linux.

open ~/.bash_history

4. Another useful command you could probably be familiar with is the “Clear” command.

So this was the method through which you could clear the whole terminal history on Linux or Mac OS. As from the article, you know that the method isn’t too difficult, but any moderate user could apply it without any issues.