Categories: LinuxUbuntu

How to Display When a File was Last Accessed in Ubuntu

As a Ubuntu user, you would agree how powerful and rich is the set of commands that you can use to access and manipulate files. In this tutorial, we will explore one such command, the Linux stat command. This command, when used with a file name, gives the following useful information about the file:

  • Size
  • Type
  • IO Block
  • Device
  • Inode
  • User ID
  • Group ID
  • Access Time
  • Modification Time
  • Creation Time

In this article, we will explain how you can use the stat command to view when a specific file was last accessed.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system. We will be using the Ubuntu command line, the Terminal, to see the stats of a file. You can open the Terminal application either through the system Dash or the Ctrl+Alt+T shortcut.

This is the simple syntax of the stat command that you can use to view the last access time of a file:

$ stat filename

For example, this is the output of the stat command I ran on one of my files:

The “Access” details in the output indicate the exact information that we are looking for.

You can also view when an application was last accessed by printing the statistics of the file that launches that application. For example, if you want to view when Firefox was last launched, move to the /usr/bin folder and then use the following command to view last accessed time of Firefox:

$ stat firefox

The stat command is much more powerful than this. To view it's full capacity you can view the manpage through the command, ‘man stat’.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago