Tuesday, November 30, 2010

Linux command name: stat

The stat command can be use to check the single file status ( like file properties on Windows) or check the filesystem status on Linux machine. The example below show the step by step on using the stat command to check file status and check filesystem status.
Command Description:
Display file or filesystem status.
Command Type:
file.

[root@fedora ~]# type -t stat
file
[root@fedora ~]# type -p stat
/usr/bin/stat

The stat command will gather the information about a file or filesystem status. This command is useful for checking file permission, inode and symbolic link, for example:
[root@fedora ~]# stat install.log
File: `install.log'
Size: 61891 Blocks: 144 IO Block: 4096 regular file
Device: 900h/2304d Inode: 910338 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2005-05-05 12:50:11.000000000 +0800
Modify: 2005-05-05 15:44:16.000000000 +0800
Change: 2005-05-05 15:44:16.000000000 +0800
The output of this command show size, filetype, permission, user id, group id and so on… for the install.log file.
The following are some of the flags and arguments that can be used for the stat command:
-f, --filesystem display filesystem status instead of file status
-c --format=FORMAT use the specified FORMAT instead of the default
-L, --dereference follow links
-Z, --context print the security context
-t, --terse print the information in terse form
--help display this help and exit
--version output version information and exit

No comments:

Post a Comment