Header Ads

Breaking News

Tweaking history on Linux | Network World


The bash history command on Linux systems helps with remembering commands you’ve previously run and repeating those commands without having to retype them.

You could decide, however, that you’d be just as happy to forget that you referenced a dozen man pages, listed your files every 10 minutes or viewed previously run commands by typing “history”. In this post, we’re going to look at how you can get the history command to remember just what you want it to remember and forget commands that are likely to be of little “historic value”.

Viewing your command history

To view previously run commands, you simply type “history”. You’ll probably see a long list of commands. The number of commands remembered depends on an environment variable called $HISTSIZE that is set up in your ~/.bashrc file, but there’s nothing stopping you from changing this setting if you want to save more or fewer commands.

To view history, use the history command:

$ history
209 uname -v
210 date
211 man chage
...

To see the maximum number of commands that will be displayed:

$ echo $HISTSIZE
500

You can change $HISTSIZE and make the change permanent by running commands like these:

Copyright © 2020 IDG Communications, Inc.

Source Link

No comments