Ubuntu – “Recently used” directories and files in bash

directoryUbuntu

In Firefox under Ubuntu, when I try to save some webpages to my local computer by Ctrl+S, there will be a window popping out for me to select the destination, where I can choose "Recently Used" directories and files. I believe "Recently Used" is maintained by Ubuntu.

Some questions:

  1. I found that only those directories or files that are recently created or changed will be shown under "Recently Used". For those recently visited without being modified, they seem not be counted as recently used, but sometimes I hope they can be counted.

  2. Also there is a very limit length of history for what have been recently used, but sometimes I want to have a longer history.

  3. Can I view a list of recently used directories and files in terminal? I am using bash.

Best Answer

Try this :

ls -ltu

but you need a ext2-4 partition mounted with atime option enabled.

Ubuntu by default have the relatime option enables by default.

From man mount :

atime
Do not use noatime feature, then the inode access time is controlled by kernel defaults. See also the description for strictatime and relatime mount options.

relatime
Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.)

Since Linux 2.6.30, the kernel defaults to the behavior provided by this option (unless noatime was specified), and the strictatime option is required to obtain traditional semantics. In addition, since Linux 2.6.30, the file's last access time is always updated if it is more than 1 day old.

Example in /etc/fstab :

/dev/mapper/raid1-home /home ext4 defaults,atime 0 1

Note : enabling this option have a cost in term of performance (disk I/O).

More on atime, ctime, mtime

Related Question