• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / Stat Command In Linux With Examples

Stat Command In Linux With Examples

By Sourabh / December 10, 2019 Category: How To, Ubuntu

How to check the last modified time of a file in Linux Ubuntu. Learn which command will show the last access time of a file in Unix; stat command in Linux with examples.

stat Command

stat command return information about a file.

Function: Display file (default) or filesystem status
Syntax: stat [-FLnq] [-f format|-l|-r|-s|-x] [-t timefmt] [file …]
Example: stat -F /tmp/foo

No permissions are required on the file itself, but-in the case of stat() and lstat() – execute (search) permission is required on all of the directories in path that lead to the file. During the execution of the command, time_t st_atime; {return the time of last access }, time_t st_mtime; {return the time of last modification} and time_t st_ctime; {return the time of last status change}.

Executable variants of stat command:

stat() stats the file pointed to by path and fills in buf.
lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to.
fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd.

All of these system calls return a stat structure, which contains the following fields:

struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};

Please note that the following comamnd argument value changes:

The field st_atime is changed by file accesses, for example, by execve(2), mknod(2), pipe(2), utime(2) and read(2) (of more than zero bytes). Other routines, like mmap(2), may or may not update st_atime.

The field st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2) and write(2) (of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation or deletion of files in that directory. The st_mtime field is not changed for changes in owner, group, hard link count, or mode.

The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link count, mode, etc.).

This is how the stat command is used for displaying status information of Linux files and file systems.

Tags: Echo Stat Command, Find Atime, How To Check The Last Modified Time Of A File In Linux, How To Get Timestamp Of A File In Unix, Linux Atime, Linux File Last Accessed, Linux Stat Command Access Modify Change, Linux Stat Command Output Explained, Linux Stat Directory, Linux Stat Last Access, Linux Terminal Stat Command, Ls Time, Stat Command In Linux With Examples, Stat Command In Solaris, Stat Command Permissions, Stat In Linux Command Line, Which Command Will Show The Last Access Time Of A File In Unix

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap