Sometimes you need to know when a user or process changed files in a particular directory and sort them chronologically in descending order.


If you are using Filezilla to get and put files on your server through sftp you can always turn on "Show raw directory listing" in the Debug settings’ options and copy the queue history to a text file or spreadsheet but there is a better way using the command line on Ubuntu.

First, just navigate to your desired directory in the terminal:

cd /someplace/somefolder/

Once in your directory run the following command but append the last part "list.txt" with the type of file you would like to create; we recommend creating a simple text file so you can manipulate it easily in your favorite markup editor or spreadsheet work in LibreOffice Calc.

ls -la -t -R > list.txt

Let us break down what the command means:

ls = list
-la = long format
-t = sort by time
-R = recursive files in folder
> = output to file type
list.txt = to text file.

A new text file named list.txt will be created in the current directory similar to our example results below.

After 6 months the listed details no longer retain time stamps as you can see starting in March in the example output.

.:
total 1551012
-rw-r--r-- 1 root root 0 Dec 13 10:24 list.txt
-rw-rw-r-- 1 www-data www-data 1585282 Nov 22 11:36 some_file-1.odf
-rw-rw-r-- 1 www-data www-data 1587891 Nov 22 11:36 some_file-2.odf
-rw-rw-r-- 1 www-data www-data 2113550 Nov 22 11:36 some_file-3.odf
-rw-rw-r-- 1 www-data www-data 2113547 Nov 22 11:36 some_file-4.odf
-rw-rw-r-- 1 www-data www-data 2113539 Nov 22 11:36 some_file-5.odf
-rw-rw-r-- 1 www-data www-data 3673011 Nov 22 11:36 some_file-6.odf
-rw-rw-r-- 1 www-data www-data 1611180 Nov 22 11:36 some_file-7.odf
-rw-rw-r-- 1 www-data www-data 1611180 Nov 22 11:36 some_file-8.odf
-rw-rw-r-- 1 www-data www-data 333859 Aug 9 16:35 some_file-9.odf
-rw-rw-r-- 1 www-data www-data 646949 Jul 25 10:58 other_file-1234.odf
-rw-rw-r-- 1 www-data www-data 1117634 Jun 26 16:44 other_file-2435.odf
-rw-rw-r-- 1 www-data www-data 1125494 Jun 26 16:44 other_file-3456.odf
-rw-rw-r-- 1 www-data www-data 1116370 Jun 26 16:44 other_file-875.odf
-rw-rw-r-- 1 www-data www-data 1100897 Jun 26 16:44 other_file-2345.odf
-rw-rw-r-- 1 www-data www-data 1169926 Jun 26 16:44 other_file-36712.odf
-rw-rw-r-- 1 www-data www-data 1623921 Jun 22 14:25 other_file-896.odf
-rw-rw-r-- 1 www-data www-data 695568 Jun 22 14:25 other_file-856.odf
-rw-rw-r-- 1 www-data www-data 696689 Jun 22 14:25 other_file-855.odf
-rw-rw-r-- 1 www-data www-data 672128 Mar 29 2017 some_file-347.odf
-rw-rw-r-- 1 www-data www-data 882614 Mar 29 2017 some_file-234.odf
-rw-rw-r-- 1 www-data www-data 672080 Mar 29 2017 some_file-098.odf
-rw-rw-r-- 1 www-data www-data 672090 Mar 29 2017 some_file-123.odf
-rw-rw-r-- 1 www-data www-data 672100 Mar 29 2017 some_file-976.odf
-rw-rw-r-- 1 www-data www-data 672106 Mar 29 2017 some_file-546.odf
-rw-rw-r-- 1 www-data www-data 672106 Mar 29 2017 some_file-908.odf

The command line in Linux stems from a proud tradition of computing lineage but with great power comes great things! GFIST is specialized in unleashing tools for your business or non-profit. Please contact us at (559) 242-6647, send us an email or text us so we can help you unleash you!

About the Writer
Chris Lessley
Author: Chris Lessley
A server admin, dev ops warrior and website designer since 2002, Chris is a lover of all things Linux and open-source! Each blog topic has been tested by fire in the real world and shared with the hope to help others. Need more help? Hire me! Chris' other interests include fine art and the humanities in the classical tradition and can be found writing for our friends over at gripfastart.works. If you like this content, kindly consider donating to keep this website free to all, without ads.

Comments powered by CComment

Member of The Internet Defense LeagueOpen Source Initiative