Technology and General Blog

The stat command shows the thorough summary of the provided file or file method. We will display you in this report the simple use of the stat command with various illustrations.

Syntax of Stat Command

The essential syntax of the Linux stat command is provided down below:

$ stat [options] [file-name]

Much more than a single file identify and choices can pass an argument with the stat command that controls the command habits and results.

Exhibit Linux File Standing Utilizing Stat Command

When only offered the file name with the stat command, the comprehensive information about file position will display screen on the terminal. For example, the next file depth can be displayed by making use of the state command:

Display screen the Info About the File Procedure

To display the facts about technique status rather of a file means to verify the process status in which the offered file resides. In this case, use the alternative “-f” with the file title which is given underneath:

The following details about the system status will demonstrate on the terminal:

You can also pass the listing or filesystem as an argument alternatively of passing the file identify, which is revealed in the adhering to screenshot:

Allow or Follow the Symbolic One-way links

As we know, Linux supports symbolic back links (symlink). When you use the stat command on a symlink, it will display screen the following about the symlink, but it doesn’t supply the information about the file it details to. You can assessment the pursuing screenshot:

To comply with or enable the symlinks, use the “-L” choice with the stat command as follows:

$ stat -L /and so forth/resolv.conf

So, by applying the over command, the symlink and file info will screen on the terminal.

Display screen Output in a Customized Format

Two distinctive options are readily available that can be employed with the stat command to format the output: -c, –printf=”format” and (–format=”format”).

The –format immediately inserts a new line soon after every operand’s consequence. The –printf choice interprets the backslash and escape sequences.

Let us reveal with an instance. Form the subsequent command to try out the –printf possibility:

# stat –printf=”%Un%Gn%zn” take a look at_file.txt

The that means of the structure sequences, which are used in the higher than command provided down below:

%U – Screen the owner title like ‘kbuzdar’

%G – utilized for group’s proprietor name this sort of as ‘kbuzdar’

%z – display the time of final change in status in human-readable structure

There are extra sequences you can use with the –printf alternative according to your requirements.

Display Output in the Terse Format

Utilizing the stat command, you can screen the details in the terse structure that is primarily handy for parsing. Type the option “-t” or –terse with the stat command to exhibit the facts in the terse format as follows:

To take a look at a lot more options about the stat command, browse the guide webpages of the stat command by managing the subsequent terminal command:



This write-up gives a short information and facts about the stat command. We have explained all the basic and important options in this posting that will ideally enable you.

Leave a Reply

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