History Linux Command Overview/Tutorial. Only The Useful.

Linux / Unix Command: history

Linux Command Description
This command displays a list of the most recently executed commands on Linux and Unix workstations and servers.

For the impatient here is the proper syntax:


history
history [n]
history -c
history -d offset
history [-anrw] [filename]
history -ps arg

Here are the only real useful options for this very useful linux command.

-c will clear the history list.


history -c

will remove all entries in your history list.

-d will delete the command at the specified offset.


history -d 24

will remove the 24th entry. Each line is labeled so it’s easy to clean up after yourself if you don’t want your boss to easily find your blunder.

There are other arguments available but I’ve never had a use for them and you can always use the man pages to check up on them if you need to.

Sometimes the history file removes some entries in order to keep the list from taking to much space. This can be unpleasant when you’re looking for some nix command that you know you’ve executed but can’t remember the exact syntax of. To increase the size of the list you will need to edit your bash_profile in your home directory (That is, assuming you are using bash like most sane linux users). This can be done very easily :

Add these two lines to your .bash_profile. This will not take effect until your next login.


vi ~/.bash_profile
HISTSIZE=340
HISTFILESIZE=680

Share

Leave a Reply