• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To See Linux History Command With Timestamp And User

How To See Linux History Command With Timestamp And User

By Sourabh / December 6, 2022 Category: How To, Ubuntu

How to see the history command with timestamp in Linux. Users can see history command in Linux with date; Linux history command with timestamp and user.

Linux History Command With Timestamp And User

To enable timestamps in the history command, you have to export the HISTTIMEFORMAT variable using the following command:

export HISTTIMEFORMAT="%F %T "

In the above command, %F displays the date in YYYY-MM-DD format and %T displays the time in HH:MM:SS format.

If you want to also view username in command history, run the pstree command in the following manner:

$ original_user=${SUDO_USER:-$(pstree -Alsu "$$" | sed -n "s/.*(\([^)]*\)).*($USER)[^(]*$/\1/p")} $ export HISTTIMEFORMAT="<%F %T> (${original_user:-$USER}) [$$] "

NOTE: The above command works for the current session. Once you logout it will reset to the default format of your system.

To permanently change the history format, you will have to edit ~/.bashrc file.

Open the file using the following command:

$ vi ~/.bashrc

Now add the following line to set the history entry’s format:

export HISTTIMEFORMAT=”%F %T “

Now save and close the file.

Primary Sidebar

Latest Posts

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap