» » "history" command - adding date to the output

"history" command - adding date to the output

Section: Other | Actuality: Unspecified
To 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
# 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 "
run the following command:
source ~/.bashrc
it will reload all the changes that we ordered.
Now try:
May the Force be with you,
Good Luck!!!

Print version

Tags: terminal
    Your attitude to the website Other polls