One of the most used Linux commands is ls
which lists files in a folder. By default, the sort is done in alphabetical order.
Keep in mind that the default time which is visible, is the last modification time of the content, where changes in filename or permissions does not affect. You may also check these articles: Sort Files By Last Access Time in Linux and Sort Files By Last Modification Time in Linux.
$ ls -lt
total 44
-rw-r--r-- 1 theuser apache 15 Dec 28 14:54 file1.php
-rw-r--r-- 1 theuser apache 20 Dec 18 14:57 file2.php
-rwxr-xr-x 1 theuser apache 29615 Dec 16 14:57 booking.php
-rw-r--r-- 1 theuser apache 15 Nov 15 14:57 README.md
Descending order is the default, meaning that the newest file is on top.
The l
stands for list mode. Without it, only file names are viewed without dates. However, without dates visible, you can still sort by date.
$ ls -ltr
total 44
-rw-r--r-- 1 theuser apache 15 Nov 15 14:57 README.md
-rwxr-xr-x 1 theuser apache 29615 Dec 16 14:57 booking.php
-rw-r--r-- 1 theuser apache 20 Dec 18 14:57 file2.php
-rw-r--r-- 1 theuser apache 15 Dec 28 14:54 file1.php
The r
stands for reverse and it can be used in general in any listing.