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

Print version

Add comments

  • Local comments
  • Facebook comments
  • bowtiesmilelaughingblushsmileyrelaxedsmirk
    heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
    winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
    worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
    expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
    disappointedconfoundedfearfulcold_sweatperseverecrysob
    joyastonishedscreamtired_faceangryragetriumph
    sleepyyummasksunglassesdizzy_faceimpsmiling_imp
    neutral_faceno_mouthinnocent
TOP OF THE MONTH
    Your favorite Linux distribution is Other polls