Engaged on Linux doesn’t usually require that we ponder epoch time, however the idea performs an necessary function in a “behind the scenes” form of approach. Epoch time relies on the variety of seconds since 00:00:00 on January 1, 1970, and is used to report dates/instances on Linux techniques in an abbreviated format. For instance, Jan 2, 1970, would have been saved as 86400 (that many seconds later than Jan 1, 1970). That’s 60 x 60 x 24 – the variety of seconds in a single day. Jan 3, 1970, began at 172800 (2 x 86400) seconds after the beginning of Jan 1, 1970, and Jan 4, 1970, began one other 86400 seconds later, and so forth.
There are three dates and instances related to Linux information – the final entry time (atime), the date and time when the content material of the file was final modified (mtime), and the final time that the file’s metadata (e.g., file permissions) have been modified (ctime). All of those dates and instances are saved within the inodes which can be related to the actual information.
To view these dates and instances, you need to use the stat command which, within the instance under, additionally reveals the file’s “beginning” time – which many variations of Linux don’t report – together with the file measurement, proprietor, permissions, inode quantity, and many others. This info can be saved within the file’s inode.
$ stat xyz File: xyz Dimension: 1297 Blocks: 8 IO Block: 4096 common file Gadget: 0,42 Inode: 22965 Hyperlinks: 1 Entry: (0660/-rw-rw----) Uid: ( 1001/ shs) Gid: ( 1001/ shs) Context: unconfined_u:object_r:user_home_t:s0 Entry: 2024-02-17 10:53:45.295165033 -0500 Modify: 2024-02-17 10:59:03.335266910 -0500 Change: 2024-02-17 10:59:40.891623555 -0500 Beginning: 2024-02-17 10:03:16.379458282 -0500
Whereas the checklist of the dates and instances above might all look considerably regular, they show a protracted string of nanoseconds (e.g., 335266910) and a sign of the time zone (-0500) related to the date. The time zone on this instance (-0500) means GMT-5 (Japanese US).
The date command can do some helpful conversions for you in the event you’d wish to show the present time within the epoch (seconds for the reason that begin of Jan 1, 1970) format. The examples under present the instructions to make use of.
To show the present epoch time (i.e., present the date because the variety of seconds since Jan 1, 1970), use the command proven under: