If you issue ls -all command some files or directories have the year and some have the time? Why do some show the year while others show the time? Is the time representative of the time the file was created?

enter image description here

  • 15
    You are using -all. Note the last L is superfluous, because all does not stand for the word "all" but for -a (show all files) and -l (long listing format). All together, ls -al is the same as what you are using. – fedorqui Oct 21 '15 at 14:55

By default, file timestamps are listed in abbreviated form, using a date like ‘Mar 30 2002’ for non-recent timestamps, and a date-without-year and time like ‘Mar 30 23:45’ for recent timestamps. This format can change depending on the current locale as detailed below.

A timestamp is considered to be recent if it is less than six months old, and is not dated in the future. If a timestamp dated today is not listed in recent form, the timestamp is in the future, which means you probably have clock skew problems which may break programs like make that rely on file timestamps.

Source: http://www.gnu.org/software/coreutils/manual/coreutils.html#Formatting-file-timestamps

To illustrate:

$ for i in {1..7}; do touch -d "$i months ago" file$i; done
$ ls -l
total 0
-rw-r--r-- 1 terdon terdon 0 Sep 21 02:38 file1
-rw-r--r-- 1 terdon terdon 0 Aug 21 02:38 file2
-rw-r--r-- 1 terdon terdon 0 Jul 21 02:38 file3
-rw-r--r-- 1 terdon terdon 0 Jun 21 02:38 file4
-rw-r--r-- 1 terdon terdon 0 May 21 02:38 file5
-rw-r--r-- 1 terdon terdon 0 Apr 21  2015 file6
-rw-r--r-- 1 terdon terdon 0 Mar 21  2015 file7
  • 4
    Worth noting that times in the future will also show the year rather than time. This can happen if you exchange files between hosts where the clock is not in sync. – kasperd Oct 21 '15 at 9:04

The time represented is modification time. Please note that ls -all is the same thing as ls -l -a, which is different from ls --all. There is no reason to use double l in your example. If you want to see the modification time for each file, you can use ls -al --full-time.

  • 5
    In GNU ls for normal use --time-style=long-iso could be more useful. --full-time shows seconds including nine ciphers (!) after the decimal dot which is normally not needed. – pabouk Oct 21 '15 at 8:30
  • 1
    --full-time implies -l, so you could just use ls -a --full-time. – kasperd Oct 21 '15 at 9:00

If the date/time that it is trying to display is in the past six months, ls displays the date and the time.  If it's longer ago than six months — or if it's in the future — ls displays the date and the year.

As stated in the other answers,

  • ls -ll is equivalent to ls -l, and
  • ls -all is equivalent to ls -al, which is equivalent to ls -a -l, ls -l -a, and ls -la.

With the -l option, ls displays the modification date/time of files (including directories, since "everything is a file"), unless

  • -c is also specified, in which case it displays change time, or
  • -u is also specified, in which case it displays access time.

See ls(1) for more information.


This output is tuned for maximal information content: when the time is "close enough" to the current time (not entirely sure, but I'm guessing within six months) the year is elided and the time of day shown instead. Otherwise, the year is shown. This is the default mostly because you likely don't care as much about the precise time-of-day something was modified, if that time is years ago. GNU coreutils ls has the --time-style option, to control this explicitly.


Have you realized something? It just appear the hour time on 20 October, which is today, that means that it will show the last time you modified the file, but, in other days which aren't today, it will only show the date without the time.

It turns out that it is not this, as answered by Thomas. I just tried to use the deduction method, not assured to have a correct conclusion after all.

  • 1
    Aug 6 19:50 .config, Aug 6 19:48 VNCHOWTO. – G-Man Says 'Reinstate Monica' Oct 20 '15 at 23:38
  • Perfect, I just did a deduction thing looking the dates and connecting the points, which cannot be always a perfect conclusion. – Rafael Campos Nunes Oct 20 '15 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.