“history” command – adding date to the output

"history" command - adding date to the outputTo view the entire history of Linux commands is more convenient to use the utility history. After execution, the screen will display the entire command history Linux.A list of common commands:

  • !! – refers to the previous command;
  • !n – refers to the command number n;
  • !-n – refers to the command number of the “current minus n”;
  • history -c – clear the history by deleting all the records
  • history -d n – delete from the history entry number n
  • history -a – to append commands entered in the current session bash, at the end of the file $HISTFILE

We can limit the number of rows returned. For example, the command below will display a list of the last 25 commands:

# show all history commands
history
# display last 25 commands
history 25
To display the time and date when any command has been executed, need to set the “HISTTIMEFORMAT”.
Open ~/.bashrc:
nano ~/.bashrc
And add the line at the end:
export HISTTIMEFORMAT=”%h %d %H:%M:%S “
"history" command - adding date to the output run the following command:
source ~/.bashrc
it will reload all the changes that we ordered.
Now try:
history
"history" command - adding date to the output May the Force be with you,
Good Luck!!!

Share to friends
Shekin
Rate author
( No ratings yet )
MintGuide.Org
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments