2

I created a file long back named test.sh. Now I want to know when the file was created, not the modification time.

Which command I can use?

If I try stat test.sh:

  File: 'test.sh'
  Size: 7               Blocks: 8          IO Block: 4096   regular file
Device: xxxx/12345r    Inode: 1769677     Links: 1
Access: (0761/-rwxrw---x)  Uid: (52898/  xxxx)   Gid: ( 1202/ xxxxx)
Access: 2017-11-17 01:11:20.000000000 -0500
Modify: 2017-11-01 00:45:18.000000000 -0400
Change: 2017-11-26 09:16:15.000000000 -0500
 Birth: -

I am unable to see the created time in the output.

dessert
  • 39,392
  • 12
  • 115
  • 163
Anony
  • 773
  • 4
  • 10
  • 16
  • Is there any one line command? – Anony Nov 27 '17 at 12:47
  • Check terdons answer on the question I linked, you can actually include that code into your `.bashrc` file and have then a one line command. – Videonauth Nov 27 '17 at 12:48
  • Yes there is: Just follow @terdon's answer to the linked question. – dessert Nov 27 '17 at 12:48
  • 1
    Related: [When is Birth Date for a file actually used?](https://askubuntu.com/a/918303/178692) – steeldriver Nov 27 '17 at 12:49
  • I have not logged in as a root user. Above answer works for root user.. – Anony Nov 27 '17 at 12:51
  • 1
    As @steeldriver alludes to, you *might* be able to do this without root. Kernels 4.11 and higher allow users to access crtimes even if they don't have any special privileges. If the system you're using runs Ubuntu 17.10 (or future releases), or if it is an LTS release with a sufficiently recent HWE kernel--currently just the "edge" kernels in 16.04 LTS, such as `linux-generic-hwe-16.04-edge` (4.13), and *not* [the usual](https://wiki.ubuntu.com/Kernel/LTSEnablementStack#Ubuntu_16.04_LTS_-_Xenial_Xerus) `linux-generic-hwe-16.04` (4.10)--you can use [that method](https://askubuntu.com/a/980750). – Eliah Kagan Nov 27 '17 at 16:01

0 Answers0