The command history is stored in the file ‘bash_history’ which you can access as follows:

linux:~ # less ~/.bash_history

The file contains a list of all the commands which are stored in the buffer. You can also see these commands in sequence with the line numbers by using ‘history’ command.

linux:~ # history

The history will show the same output as the contents of the file bash_history except that it shows the output with line numbers. The number of commands stored in the buffer are controlled by the environment parameter HISTSIZE. By default, the value of this variable is 1000 which means it can store 1000 lines in the history. You can change this value to get hold of greater set of history commands. Suppose we want to change the history size to 1500 lines, use the following command to server the purpose.

linux:~ # HISTSIZE=1500

Adnan Khurshid

Adnan Khurshid, the author of this article, has been working in a telecommunication sector since 2007. He has worked there as a VAS (Value Added Services) engineer and has excelled remarkably in the field. Working in this field has been his passion and he has always made efforts to keep himself up to date. Find more about him on LinkedIn

More Posts

Tags: , ,

1 Comment on How to retrieve command history in Linux/Unix servers

  1. kyle says:

    yeah nice

Leave a Reply