Clear Linux / UNIX BASH Shell Command Line Cache / History

Clear Linux / UNIX BASH Shell Command Line Cache / History

To clear the cache or history of the command line in a Linux or Unix-like system, you can use the history command with the -c option.

For example, to clear the command line history for the current session, you can use the following command:

refer‮:ot ‬lautturi.com
history -c

This will clear the command line history for the current session.

To clear the command line history for all sessions, you can use the history -c command followed by the history -w command. The history -w command writes the current command line history to the history file (typically ~/.bash_history).

For example, to clear the command line history for all sessions, you can use the following commands:

history -c
history -w

This will clear the command line history for all sessions.

Note: The history command may not be available on all Linux or Unix-like systems. In that case, you can use the echo > command to clear the command line history file (e.g., ~/.bash_history). For example:

echo > ~/.bash_history

This will overwrite the command line history file with an empty file, effectively clearing the command line history.

You can find more information about the history command and its options in the history documentation or by running the history --help command.

Created Time:2017-10-28 14:02:23  Author:lautturi