Support > About cloud server > What are the common usages of the stat command
What are the common usages of the stat command
Time : 2025-02-05 16:06:29
Edit : Jtti

The Stat command can be used as a utility to view a file or file system, retrieving information such as file type, octal and human-readable access permissions, last access, SELinux security context strings, file birth time, and so on. One option is to specify a custom format to display the information, as follows!

The simplest way to display stat is to display file size, block, IO block, file type, inode value, number of links, etc., such as viewing /var/log/syslog file:

$ stat /var/log/syslog

The stat command treats the input file as a normal file, if you want to display the file system state instead of the file state:

$ stat -f /var/log/syslog

You can also provide a directory/file system as a parameter:

$ stat -f /

Because Linux supports links, such as symbolic links/hard links. Some files may have 1 or more links, which can be traced using stat:

$ stat -L /

Stst-specific or custom formats can be used instead of the default format, and the c option can be used to specify the format, printing a newline character each time a format sequence is used. Alternatively, you can explain and turn off the print trailing newline option by enabling backslash escape sequences, if printf is needed in formatting to print newline \n:

# stat --printf='%U\n%G\n%C\n%z\n' /var/log/secure

%U: owner's user name, %G: owner's group name, %C: SELinux security context string, %z: time of last state change, human-readable.

Stat is used to print information in concise form:

$ stat -t /var/log/syslog

The shell may have its own version of stat, see the shell documentation for details on the options it supports. To see all the sequences of acceptable output formats, see the stat man page:

$ man stat

Relevant contents

Efficient way to speed up APT package downloads in Ubuntu Deprecated network commands and alternative command sharing in Linux Methods for evaluating cloud server latency in the United States Procedure for enabling or disabling Remote Desktop protocol on the Windows Cloud Server Jtti Cloud servers can be customized to meet your specific data access needs Recommended linux system backup utility for 2025 How to create and use alias commands under Linux The specific application of edge cloud collaboration in industrial applications
Go back

24/7/365 support.We work when you work

Support