Find the Time of Access, Change & Modify File in Linux & Unix

Symptom

You want to find the access, change and modify time of a file in your Linux or Unix operating system.

Solution

1. You can achieve that by executing below command. As per this example, i am going to find the details on arabapak.txt file.

# stat arabapak.txt
  File: `arabapak.txt'
  Size: 42905           Blocks: 96         IO Block: 32768  regular file
Device: 23h/35d Inode: 11653804    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 3108/  oraara)   Gid: (  201/     dba)
Access: 2013-02-01 23:43:43.557892000 +0100
Modify: 2013-02-01 23:43:43.558894000 +0100
Change: 2013-02-04 03:42:37.226786000 +0100

From the command output, you can see Access time, Modify time and Change time. Please bear in mind, the term Access is referring to the last time the file was read, view or displayed (more, less). Modify means when was the last the file content was modified (vi). Finally, the Change term was determined by when was the last meta data of the file been modified (chmod, chown).

2. As an example, i am going to read the arabapak.txt using the more command and then, i will execute the command stat again.

# more arabapak.txt
# stat arabapak.txt
  File: `arabapak.txt'
  Size: 42905           Blocks: 96         IO Block: 32768  regular file
Device: 23h/35d Inode: 11653804    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 3108/  oraara)   Gid: (  201/     dba)
Access: 2013-02-18 08:28:38.428104000 +0100
Modify: 2013-02-01 23:43:43.558894000 +0100
Change: 2013-02-04 03:42:37.226786000 +0100

As you can see, the Access time is now change to the current time that you are displaying the file.

3. As for Modify and Change, you can make some experiments here. You can use VI editor to change the file content or CHMOD to change the file permission. Then, you can see the different when you are executing the stat command again.

You May Also Like

Leave a Reply?