The bash historical past shops the data of all terminal instructions that are executed by a consumer on the command-line Linux system. Utilizing the historical past function, you possibly can simply find the beforehand executed instructions in your Linux system by the arrow keys navigation.

Why ought to we take away the Linux Command line Historical past?

More often than not, we don’t wish to reveal the terminal historical past of different customers in your Linux system. For instance, if you’re giving courses to your college students on a Lab laptop and also you might need taught some dangerous instructions and aren’t really helpful to make use of on our system. However a lot of the college students don’t have an thought concerning the negative effects of those important instructions. A curious pupil could search concerning the command-line historical past and check them to test the working of every command. It could crash your system many instances. Nevertheless, you possibly can restore or re-install your system in a fast manner. However, it’s not observe. So, on this case, we wish to choose to clear the command line historical past after engaged on it. Particularly when you might have shared entry with your pals or colleagues. We now have simply elaborated it with only a easy instance; there might be different issues by which you wish to clear the Linux command line historical past. On this article, we offers you a demo of how one can clear the command line historical past within the Linux system.

We now have executed all of the instructions on Ubuntu 20.04 terminal utility on this article. Subsequently, it’s essential to open the terminal window in your system. Click on on the ‘Actions’ positioned on the left nook in your system’s desktop, after which utilizing the applying search bar, you’ll search the ‘terminal’ key phrase. After finishing the search, click on on the terminal icon and launch it.

How to clear command history in Linux – Linux Hint

Eradicating the Linux Command line historical past

If you wish to view the historical past of your terminal command then, kind the next command on the terminal:

How to clear command history in Linux – Linux Hint

Usually, the command line historical past shops in a file named ‘bash_history’. This file chances are you’ll find in a specific consumer’s dwelling listing /dwelling/username/.bash_history. Execute the below-given command to find the bash_history file:

$ ls -l /dwelling/kbuzdar/.bash_history

How to clear command history in Linux – Linux Hint

Notice: A root consumer can observe the command historical past of all consumer’s in your system. However, the usual consumer can solely view their very own command line historical past.

Take away a Line from the bash historical past

If you wish to take away only a single line from the bash historical past file, then you need to use the -d choice with historical past command and enter the focused line quantity, which you wish to take away.

For instance, we wish to clear a command that accommodates your password the place you might have entered a password in a plain textual content; you possibly can simply discover the road quantity within the historical past file and clear it by executing the next command:

How to clear command history in Linux – Linux Hint

Take away or Clear all instructions from the bash historical past

It’s also possible to clear or delete all entries from the bash historical past file. So, use the choice -c with the historical past command. You possibly can run the next command on the terminal to clear or delete the all bash historical past:

How to clear command history in Linux – Linux Hint

Alternatively, by working the next command, you possibly can take away or delete all historical past of final executed instructions within the bash historical past file completely.

$ cat /dev/null > ~/.bash_history

How to clear command history in Linux – Linux Hint

Conclusion

On this article, now we have offered a greater understanding of the historical past command and why we have to clear it. From the above all talked about command, I hope now can clear the historical past of your system simply. However, at all times do not forget that what you carry out on the terminal all instructions recorded in a bash historical past file, so it is strongly recommended that you simply by no means use passwords in a plain-text format on the Linux command line. In case you have any queries and ideas associated to this text then, please share your concepts with us.

linux delete history without trace,linux history command,history -d not working,terminal output history,command unix history,history position out of range,linux clear history current session,history -c not working,clear command history windows,linux delete history multiple lines,-ksh: hist: -d: unknown option,history clear and exit linux,clear terminal commands linux,truncate bash_history,clear bash history mac,how to delete last 10 history in linux,bash clear history current session,bash clear terminal output,what's the purpose of the alias command?,how to save command history in linux,linux command history all users,linux save terminal session to file,typing cd – takes you to _____.,linux file history backup,how to delete history of last 10 commands in linux,how to clear command history permanently in linux,how to check command history in linux with date,linux history command options,linux command history file,how to check commands executed by user in linux

Share:

administrator