Linux Fundamentals /var/backups directory

I can’t come up with the answer to the question below:
What is the name of the last modified file in the “/var/backups” directory?
I am trying: ls /var/backups
I cannot come up with anything else, because it is not explained in the course, and I’m a newbie. Can anyone please help me out/give me a hint?
They explain how to use “touch” to create empty file and “mkdir” to create a directory.
Thanks.

1 Like

I’d start with ls -al /var/backups to make sure any hidden files are exposed.

Thanks a lot for your help. So, these are my findings:

htb-student@nixfund:~$ ls -al /var/backups
total 2168
drwxr-xr-x  2 root root     4096 May  6 07:28 .
drwxr-xr-x 14 root root     4096 Sep 23  2020 ..
-rw-r--r--  1 root root    51200 Oct 29  2020 alternatives.tar.0
-rw-r--r--  1 root root     2497 Oct 16  2020 alternatives.tar.1.gz
-rw-r--r--  1 root root     2492 Sep 24  2020 alternatives.tar.2.gz
-rw-r--r--  1 root root    41872 Nov 12 18:15 apt.extended_states.0
-rw-r--r--  1 root root     4437 Nov 12 18:12 apt.extended_states.1.gz
-rw-r--r--  1 root root     4623 Oct 22  2020 apt.extended_states.2.gz
-rw-r--r--  1 root root     4601 Oct 15  2020 apt.extended_states.3.gz
-rw-r--r--  1 root root     4572 Sep 23  2020 apt.extended_states.4.gz
-rw-r--r--  1 root root      437 Aug  5  2019 dpkg.diversions.0
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.1.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.2.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.3.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.4.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.5.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.6.gz
-rw-r--r--  1 root root      367 Sep 23  2020 dpkg.statoverride.0
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.1.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.2.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.3.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.4.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.5.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.6.gz
-rw-r--r--  1 root root   742750 Nov 11 06:24 dpkg.status.0
-rw-r--r--  1 root root   206270 Nov 11 06:24 dpkg.status.1.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.2.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.3.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.4.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.5.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.6.gz
-rw-------  1 root root      860 Sep 23  2020 group.bak
-rw-------  1 root shadow    716 Sep 23  2020 gshadow.bak
-rw-------  1 root root     2014 Sep 23  2020 passwd.bak
-rw-------  1 root shadow   1362 Sep 23  2020 shadow.bak

I think file types are distinguished as d for directories, - for regular files.

After that, I have tried with -r to reverse the order so that the most recently modified file shows as last item:

htb-student@nixfund:~$ ls -al -r /var/backups
total 2168
-rw-------  1 root shadow   1362 Sep 23  2020 shadow.bak
-rw-------  1 root root     2014 Sep 23  2020 passwd.bak
-rw-------  1 root shadow    716 Sep 23  2020 gshadow.bak
-rw-------  1 root root      860 Sep 23  2020 group.bak
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.6.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.5.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.4.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.3.gz
-rw-r--r--  1 root root   206270 Nov  5 06:37 dpkg.status.2.gz
-rw-r--r--  1 root root   206270 Nov 11 06:24 dpkg.status.1.gz
-rw-r--r--  1 root root   742750 Nov 11 06:24 dpkg.status.0
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.6.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.5.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.4.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.3.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.2.gz
-rw-r--r--  1 root root      229 Sep 23  2020 dpkg.statoverride.1.gz
-rw-r--r--  1 root root      367 Sep 23  2020 dpkg.statoverride.0
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.6.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.5.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.4.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.3.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.2.gz
-rw-r--r--  1 root root      202 Aug  5  2019 dpkg.diversions.1.gz
-rw-r--r--  1 root root      437 Aug  5  2019 dpkg.diversions.0
-rw-r--r--  1 root root     4572 Sep 23  2020 apt.extended_states.4.gz
-rw-r--r--  1 root root     4601 Oct 15  2020 apt.extended_states.3.gz
-rw-r--r--  1 root root     4623 Oct 22  2020 apt.extended_states.2.gz
-rw-r--r--  1 root root     4437 Nov 12 18:12 apt.extended_states.1.gz
-rw-r--r--  1 root root    41872 Nov 12 18:15 apt.extended_states.0
-rw-r--r--  1 root root     2492 Sep 24  2020 alternatives.tar.2.gz
-rw-r--r--  1 root root     2497 Oct 16  2020 alternatives.tar.1.gz
-rw-r--r--  1 root root    51200 Oct 29  2020 alternatives.tar.0
drwxr-xr-x 14 root root     4096 Sep 23  2020 ..
drwxr-xr-x  2 root root     4096 May  6 07:28 .

So, the answer to the question should be shadow.bak? It says incorrect answer.

-r doesn’t list them in date order, it is listing them in reverse alphabetic order, I would suggest looking at the dates and finding the file most recently modified e.g. Oct 15 2020 is more recent than Sep 24 2020, find the most recent file modified.

Thanks for your advice, it worked. I also did ls al -t /var/backups and got it sorted by timestamp.

I had the command right all the time without getting to forums.
I was just entering the first modified file name instead of the last, I feel so dumb when I shouldn’t.

I figured out using ls -lt