3S COMPUTERS Technology Updates Live
No Result
View All Result
 
  • Home
  • Computer
    • Desktop
    • Laptop
    • Hardware
  • Mobile
    • Apps
  • Gadget
  • Operating System
    • Android
    • Linux
    • Windows
    • OS
  • Technology
  • Coronavirus
  • Contact
3S COMPUTERS Technology Updates Live
No Result
View All Result
3S COMPUTERS Technology Updates Live
Home Operating System Linux

8 Stat Command Examples in Linux

3S NEWS by 3S NEWS
December 31, 2020
in Linux
0
3S
Share on FacebookShare on TwitterShare on WhatsApp


In Linux, there at all times appears to be an ingenious manner of getting issues accomplished. For any job, there’s at all times multiple command-line utility to execute it in a greater manner. The Linux stat command is a command-line software used to show detailed details about a file. In this information, we spotlight Eight stat command usages in Linux. This works throughout all Linux distributions.

Linux stat command

Think of stat command as a greater model of the ls -l command. While the -l flag gives extra particulars about recordsdata comparable to file possession and permissions, The stat command goes deeper underneath the hood and gives a wealth of details about a file.

The syntax for Linux stat command is as proven:

$ stat [OPTION] filename

1) Stat command with no arguments

In its easiest type – with none parameters – the stat command shows the default output. This contains file measurement and sort, gadget kind, inode quantity, UID, GID, variety of hyperlinks and entry/modification dates of the file.

For instance, to view the file particulars of a file residing within the present residence listing, execute:

$ stat file1.txt

Stat-command-default-output

Let’s flesh out the output:

  • File : This exhibits the title of the file.
  • Size : Size of the file in bytes.
  • Block : Number of blocks allotted to the file.
  • IO Block : This is the byte measurement of each block.
  • Device :  The gadget quantity in hexadecimal or decimal format.
  • Inode : This is the inode variety of the file.
  • Links : Number of exhausting hyperlinks related to the file.
  • Access : File permissions both in symbolic or numeric format.
  • Uid :  User ID & title of the proprietor.
  • Gid :  Group ID & title of the proprietor.
  • Context : SeLinux safety context
  • File kind : Shows what kind the file is (Whether a daily file, symbolic hyperlink and so forth).
  • Access : Shows the final time the file was accessed.
  • Modify : Shows the final time the contents of the file have been modified.
  • Change : Shows the final time a file’s metadata e.g permissions & possession was modified.

2) View details about a number of recordsdata

You can view an in depth report on a number of recordsdata by specifying the recordsdata on the command line one after the opposite as proven.

$ stat file1.txt file2.pdf

Stat-command-with-multiple-files

3) Display file system standing

You can examine the filesystem standing the place the file is sitting on by utilizing the -f possibility as proven. This provides you the block measurement, whole & out there reminiscence to say only a few attributes.

$ stat -f /residence

Stat-command-filesystem-linux

4) Display data in terse type

The -t possibility is used to show data in a terse format as proven:

$ stat -t file1.txt

Stat-command-with-terse-form

5) Enable following of symbolic hyperlinks

Usually, if you happen to run the stat command on a symbolic hyperlink, it should solely offer you details about the hyperlink, and never the file that the hyperlink factors to. Take for instance the /usr/share/zoneinfo/America/Cayman symbolic hyperlink.

$ stat /usr/share/zoneinfo/America/Cayman

stat-command-symlink-file

In the instance above, the symbolic hyperlink /usr/share/zoneinfo/America/Cayman factors to ( ->)  Panama. The symbolic hyperlink is barely 6 bytes.

To get data on the file that the hyperlinks factors to, use the -L possibility also referred to as the dereference possibility.

$ stat -L /usr/share/zoneinfo/America/Cayman

This now shows details about the file and never the hyperlink, though the output suggests it’s the hyperlink. This is as a result of we handed it as an argument with the stat command.

stat-command-with-derefernce

6) Format sequencing

From earlier examples, we’ve seen that stat command prints out a barrage of knowledge on the terminal. If you need particular data, you’ll be able to customized the output utilizing a format sequence to offer precisely what you want and go away different particulars.

Popular expressions used to customized the output embody –printf  or –format possibility

For instance, to show inode of a file solely, use the %i format sequence as proven. The n operand print a brand new line.

$ stat --printf="%in" file1.txt

Format-Stat-Command-output

To show entry rights and uid (User ID) use the %a and %u format sequences.

$ stat --printf="%a:%un" file1.txt

Stat-access-rights-userid-linux

The –format possibility prints out a brand new line with out requiring a further operand.

$ stat --format="%a:%F" file1.txt

Additional-operand-stat-command

Here’s a whole checklist of the format sequences that you need to use:

  •        %a     Displays the entry rights in octal format.
  •        %A     Displays the entry rights in a human readable format.
  •        %b     This is the variety of blocks allotted (see %B).
  •        %B     the scale in bytes of every block reported by %b.
  •        %C     Shows the SELinux safety context string.
  •        %d    Displays the gadget quantity in a decimal format.
  •        %D     The gadget quantity in hexadecimal format.
  •        %f     Displays the uncooked mode in hexadecimal.
  •        %F    Displays the file kind.
  •        %g     Prints the group ID of proprietor.
  •        %G     Prints the group title of proprietor.
  •        %h    Displays the variety of exhausting hyperlinks.
  •        %i     Prints out the inode quantity.
  •        %m    Prints the mount level.
  •        %n     Displays the file title of the file
  •        %N     Shows quoted file title with dereference if symbolic hyperlink
  •        %o     Prints the optimum I/O switch measurement trace.
  •        %s     whole measurement, in bytes.
  •        %t     main gadget kind in hex, for character/block gadget particular recordsdata
  •        %T     minor gadget kind in hex, for character/block gadget particular recordsdata
  •        %u    Shows the person ID of proprietor.
  •        %U     Prints the username of proprietor.
  •        %w     Reveals the time of file beginning, human-readable; – if unknown.
  •        %W     Prints the time of file beginning, seconds since Epoch; zero if unknown.
  •        %x     The time of final entry, human-readable.
  •        %X     The time of final entry, seconds since Epoch.
  •        %y     Displays the final time of final modification, human-readable.
  •        %Y     Prints the time of final modification, seconds since Epoch.
  •        %z     This is the time of final change, human-readable.
  •        %Z     The time of final change, seconds since Epoch.

7) Getting assist with stat command

For extra command choices , use the –assist possibility with stat command as proven.

$ stat --help

Stats-Command-help

You may also go to the person pages of stat command, run

$ man stat

man-page-stat-command

8) Checking the model of stat

Finally to examine the model of stat command, run the command:

$ stat --version

stat-command-version

That’s what we had in retailer for you on this information. As you’ll be able to see, the stat command goes over and above what the ls command provides you and is good in gathering detailed details about a file or file system.

Also Read : 14 Useful ‘ls’ Command Examples in Linux



Source hyperlink

Tags: linux stat commandlinux stat command output explainedstat command date formatstat command examplesusage of stat command
Previous Post

How to Share Screen with Zoom on Mac

Next Post

Tips to Select the Right Pair of Over-Ear Headphones

3S NEWS

3S NEWS

Related Posts

3S
Linux

How to Fix “Repository does not have a release file” Error in Ubuntu

by 3S NEWS
January 1, 2021
LG’s New Tone Free True Wireless Earphones Come With Meridian Audio Technology, Self-Cleaning Charging Case
Gadget

LG’s New Tone Free True Wireless Earphones Come With Meridian Audio Technology, Self-Cleaning Charging Case

by 3S NEWS
June 28, 2020
Google has a new shortcut to start a Meet call
Gadget

Google has a new shortcut to start a Meet call

by 3S NEWS
June 28, 2020
Chinese Apps: Government Denies Passing Order to Ban TikTok, CamScanner, Others From Google Play, App Store
Gadget

Chinese Apps: Government Denies Passing Order to Ban TikTok, CamScanner, Others From Google Play, App Store

by 3S NEWS
June 28, 2020
Next Post
3S

Tips to Select the Right Pair of Over-Ear Headphones

Please login to join discussion
  • Moto G 5G Plus Specifications Spotted on Geekbench, US FCC, and TUV Rheinland Sites

    Moto G 5G Plus Specifications Spotted on Geekbench, US FCC, and TUV Rheinland Sites

    551 shares
    Share 220 Tweet 138
  • You Need To Clean The Junk Right Now

    550 shares
    Share 220 Tweet 138
  • The Best Series on Disney+ Hotstar [June 2020]

    550 shares
    Share 220 Tweet 138
  • TCL 55C715 4K QLED Android TV Review

    549 shares
    Share 220 Tweet 137
  • Zomato Employees Burn Company T-Shirts to Protest Chinese Investment in Firm

    549 shares
    Share 220 Tweet 137

About Us

3S COMPUTERS Technology Updates Live

We bring you the best and updated technological news which will blow your mind.

Follow Us

Categories

  • Android
  • Apps
  • Camera
  • Desktop
  • Gadget
  • Hardware
  • Laptop
  • Linux
  • OS
  • Redhat
  • Technology
  • Windows

Recent News

3S

Tips to Select the Right Pair of Over-Ear Headphones

January 3, 2021
3S

8 Stat Command Examples in Linux

December 31, 2020
  • About
  • Advertise
  • Privacy Policy
  • Contact

© 2020 3S COMPUTERS.

No Result
View All Result
  • Home
  • Computer
    • Desktop
    • Laptop
    • Hardware
  • Mobile
    • Apps
  • Gadget
  • Operating System
    • Android
    • Linux
    • Windows
    • OS
  • Technology
  • Coronavirus
  • Contact

© 2020 3S COMPUTERS.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.