Linux stat Command Tutorial With Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-stat-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

Linux stat command used to display files and file system information like permission, size etc. In this tutorial we will look various usage examples.

Show File Information

All information about a file can be get without providing any parameter. We will only provide the file name.

Show File Information
Show File Information

As we can see from screenshot there is information about file name , size, blocks, inode, device, access,modify,change dates, user and group id and access rights.

Show File System Information

We can get information about the file system too. But we need some rights to read these file system attributes. This right can  be provided with sudo command or root user.

Show File System Information
Show File System Information

As we can see from screenshot there is information about file name , size, blocks, inode, device, access,modify,change dates, user and group id and access rights.

Show File Permissions

File permissions about a file can be get like below. First command will output humen readable format, second will print octal format.

OR

Show SELinux Security Context

SELinux is security implementation about Linux operating systems. Files are restricted according to this security context. This context information can be get like below.

Show File Type

File type like regular, block, link etc. can be printed with the following command. First command will show in human readable format. Second command will show octal format.

LEARN MORE  How To Add New User With Home Directory To Linux

OR

Show File Type
Show File Type

Show User

Every file in Linux have a owner user. This user information can be get with stat command. First command will show human readable format, second command will show in decimal number of the user id.

OR

Show User
Show User

Show Group

Every file in Linux have a owner group. This group information can be get with stat command. First command will show human readable format, second command will show in decimal number of the group id.

OR

Show Group
Show Group

Show Inode Number

Inode numbers are used to specify files in file systems. this inode number can be printed with stat command like below.

Show Inode Number
Show Inode Number

Show Number Of Hard Links

Linux provides ability to link existing files. Those are two type soft link and hard link. The hard link count can be printed like below.

$ stat –format %h a.txt

Show Number Of Hard Links
Show Number Of Hard Links

Show Total Size

The total size of the provided file can be printed like below with stat command.

Show Last Modification

Las modification time can be printed like below. First will print in  a human readable format and second command will print epoch time.

OR

Show Last Modification
Show Last Modification

Show Last Change

Last change time can be printed like below. First will print in  a human readable format and second command will print epoch time.

LEARN MORE  Security Roles and Responsibilities In Security Governance

OR

Show Last Change
Show Last Change

Show Last Access

Last access time can be printed like below. First will print in  a human readable format and second command will print epoch time.

OR

Show Last Access
Show Last Access
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-stat-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.