• 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

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

Linux Command To Check RAM Size In Ubuntu Terminal In GB

How To Install Proprietary Drivers In Linux Ubuntu Using Terminal

How To Shutdown Linux With A 15 Minute Delay And Message

Free AI Courses With Certificate For Beginners In India

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

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