• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Linux command to find modified and access date of file/dir/filesystem

January 1, 2014 by Sharad Chhetri Leave a Comment

In this tutorial we will learn about linux command to find last modified and access date of a file/dir and filesystem.The command is very useful for troubleshooting purpose.

Here we will use the stat command which display file or file system status.

To find the last modified and access date of a file/dir/filesystem in linux,we use the command called stat.The command will show you many information but we are looking for the three value called Access,modify and change.

To get the status of file or directory

To get the status of file/dir use the given below syntax

stat /path/of/file-dir

Below given is the example from my system

[root@nymachine ~]# ls -ld test
drwxr-xr-x 3 root root 4096 Sep 29 07:18 test
[root@mymachine ~]# 
[root@mymachine ~]# stat test
  File: `test'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d	Inode: 1048642     Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-12-29 17:08:18.560003308 +0000
Modify: 2013-09-29 07:18:55.564999916 +0000
Change: 2013-09-29 07:18:55.564999916 +0000
[root@mysites ~]# 

To find the modified and access date of a filesystem

For getting status of filesystem, use the given below syntax

stat /path/filesystem/

for eg.

[root@CentOS-Server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda               20G  5.6G   14G  30% /
none                  246M     0  246M   0% /dev/shm
[root@CentOS-Server ~]# 
[root@CentOS-Server ~]# stat /dev/vda 
  File: `/dev/vda'
  Size: 0         	Blocks: 0          IO Block: 4096   block special file
Device: 5h/5d	Inode: 5685        Links: 1     Device type: fd,0
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2013-11-25 05:53:15.763999928 +0000
Modify: 2013-11-25 05:53:15.761999928 +0000
Change: 2013-11-25 05:53:15.761999928 +0000
[root@CentOS-Server ~]# 

note: If you use -f option for file system,it will only show details of filesystem but modified/access date will not be shown.
In below output, you will get other useful information about blocks,inode,ID etc. information

For eg.

[root@CentOS-Server ~]# stat -f /dev/vda 
  File: "/dev/vda"
    ID: 0        Namelen: 255     Type: tmpfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 60872      Free: 60836      Available: 60836
Inodes: Total: 60872      Free: 60330
[root@CentOS-Server ~]# 

To know about more option,check the man page and help section

man stat
stat --help

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Give permission reference to file/dir from other file/dir in linux
  2. group ownership reference to file/dir from other file/dir in linux
  3. 6 df Command Examples To Check Mounted Filesystem On Linux
  4. Learn Linux Date Command With Examples
  5. NOTICE: nagios.cmd file not found. Please specify the location of this file in your /etc/vshell.conf file
  6. Convert video file into gif file through command line in linux
  7. How to find which filesystem is supported by running kernel
  8. How to rescan filesystem in owncloud 5
  9. Yum command to download rpm file without installing in linux system
  10. Use Linux Date Command As A Timezone Converter

Filed Under: Linux, Linux Commands Tagged With: linux command, stat

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

error could not configure a c compiler Linux

SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

How to use grep command to get fixed pattern or exact keyword

find command to search keyword in files recursively in linux

convert space into new line using sed command

Set GRUB password after installation of CentOS/Red Hat

How to create a file with cat command

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy