How to Add Date & Time with History in Linux


The command history allows the use of words from previous command lines at the command prompt type. This simplifies spelling corrections and the repetition of complicated commands or arguments.

History Command

# history
  850  useradd admin
  851  passwd admin
  852  cd /home/admin/
  853  ls -l
  854  ls -la
  855  top

Edit the file /etc/bashrc add the entry at the end of the file /etc/bashrc

# vi /etc/bashrc
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

You can also directly execute the following command:

# export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

Now again check the “history” command:

# history
  850  31/08/15 07:22:21 useradd admin
  851  31/08/15 07:22:21 passwd admin
  852  31/08/15 07:22:21 cd /home/admin/
  853  31/08/15 07:22:21 ls -l
  854  31/08/15 07:22:21 ls -la
  855  31/08/15 07:22:21 top

How to Clean History in linux

Step 1: Check the History

In order to check the executed shell commands in linux, use the history command

# history
  366  cd ..
  367  make
  368  cd posix-local/
  369  cd app/
  370  less Makefile
  371  ls -l
  372  cd bin/

Step 2: Clear the History

To clear all your history, use

# history -c

To delete a single line, use

# history -d linenumber

Linux World

The history of Linux began in 1991 with the commencement of a personal project by Finnish student Linus Torvalds to create a new free operating system kernel. Since then, the resulting Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to the 3.18 version in 2015 with more than 18 million lines of source code under the GNU General Public License

In 1991, in Helsinki, Linus Torvalds began a project that later became the Linux kernel. He wrote the program specifically for the hardware he was using and independent of an operating system because he wanted to use the functions of his new PC with an 80386 processor. Development was done on MINIX using the GNU C compiler. The GNU C Compiler is still the main choice for compiling Linux today. The code however, can be built with other compilers, such as the Intel C Compiler.

As Torvalds wrote in his book Just for Fun,[10] he eventually ended up writing an operating system kernel. On 25 August 1991 (age 21), he announced this system in a Usenet posting to the newsgroup “comp.os.minix.”:

Hello everybody out there using minix –

I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I’d like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things).

I’ve currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I’ll get something practical within a few months, and I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise I’ll implement them 🙂

Linus (

PS. Yes – it’s free of any minix code, and it has a multi-threaded fs. It is NOT portable (uses 386 task switching etc), and it probably never will support anything other than AT-harddisks, as that’s all I have :-(.

—Linus Torvalds