Home  >  Article  >  Operation and Maintenance  >  Guide on how to check the time of a Linux file

Guide on how to check the time of a Linux file

PHPz
PHPzOriginal
2024-02-24 09:48:06636browse

Linux 文件时间查看指南

Linux File Time Viewing Guide

In the Linux operating system, each file and directory has its owner, permissions, timestamp and other attributes. Among them, the timestamp includes three parts: access time (atime), modification time (mtime) and change time (ctime). These timestamps record the relevant operation time of files. For system administrators and developers, understanding the timestamp information of files can help them better manage files and track file changes. This guide explains how to view a file's timestamp through commands and provides corresponding code examples.

  1. View access time (atime):
    Access time refers to the time when the file was last accessed. You can use the following command to view the access time of a file:

    stat <文件名>

    Example:

    stat test.txt
  2. View the modification time (mtime):
    The modification time refers to the most recent file content The time it was modified once. You can use the following command to view the modification time of a file:

    stat -c %y <文件名>

    Example:

    stat -c %y test.txt
  3. View the change time (ctime):
    The change time refers to the inode of the file The time when the metadata was last modified. You can use the following command to view the change time of the file:

    stat -c %z <文件名>

    Example:

    stat -c %z test.txt
  4. Use the ls command to view the file timestamp:
    ls command can also view the file's timestamp Timestamp information, use the -l parameter to display more detailed timestamp information. The following is an example of using the ls command to view file timestamps:

    ls -l <文件名>

    Example:

    ls -l test.txt

Through the above commands and examples, we can easily view the access time and modification of files time and change time to better manage files and track file changes. Hope this guide helps!

The above is the detailed content of Guide on how to check the time of a Linux file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn