Function Description: displays inode content.
Syntax: stat [file or directory]
Note: stat displays inode content in text format.
The LS command and many parameters provide some useful file information. Another unfamiliar command, stat, provides more useful information.
The following shows how to use this command for the executable file "oracle" (located in the $ ORACLE_HOME/bin directory.
# Cd $ ORACLE_HOME/bin
# Stat Oracle
Size: 93300148 blocks: 182424 Io block: 4096 regular file
Device: 343 H/835d inode: 12009652 links: 1
Access: (6751/-rwsr-s -- X) uid :( 500/Oracle) gid :( 500/DBA)
Access: 04:30:52. 000000000-0400
Modify: 11:49:47. 000000000-0500
Change: 11:55:24. 000000000-0500
Note the information obtained by using this command: in addition to the normal file size (you can also use the LS-l command), you also get the number of blocks occupied by this file. Generally, Linux blocks are 512 bytes in size. Therefore, a 93,300,148-byte file occupies (93300148/512 =) 182226.85 blocks. Because all blocks are fully occupied, this file uses some integer blocks. You can obtain the exact number of blocks without guessing.
You can also obtain the GID and uid of the file ownership from the above output, as well as the octal representation of the permission (6751 ). To restore a file to the same permissions that it currently has, you can use chmod 6751 Oracle instead of explicitly spelling these permissions.
The most useful part of the above output is the file access timestamp information. The output shows that the file was accessed at 04:30:52, August 4, 2006 (displayed next to "Access:"), that is, 4:30:52, January 1. This is the time someone started to use the database. Date.html 'target = '_ blank'> the modification time is 11:49:47 (displayed next to "Modify ). Finally, the timestamp next to "change:" shows the time when the file status changes.
The modifier-F of the STAT command displays information about the file system rather than the file:
# Stat-F Oracle
ID: 0 namelen: 255 type: ext2/ext3
Blocks: Total: 24033242 free: 15419301 available: 14198462 size: 4096
Inodes: Total: 12222464 free: 12093976
The other option-T displays identical information, but is displayed in a row:
# Stat-T Oracle
Oracle 93300148 182424 8de9 500 500 343 12009652 1 0 0 1154682061
1130950187 1130950524 4096
Everything in UNIX is treated as files. This includes des devices, directories and sockets-all of these are files. STAT command displays file or filesystem status as explained in this article.
File stat-display information about file
For example, to find out more information about 101hacks.txt file, execute the STAT command as shown below.
$ stat 101hacks.txt File: `/home/sathiyamoorthy/101hacks.txt' Size: 854 Blocks: 8 IO Block: 4096 regular fileDevice: 801h/2049dInode: 1058122 Links: 1Access: (0600/-rw-------) Uid: ( 1000/ sathiya) Gid: ( 1000/ sathiya)Access: 2009-06-28 19:29:57.000000000 +0530Modify: 2009-06-28 19:29:57.000000000 +0530Change: 2009-06-28 19:29:57.000000000 +0530
Details of Linux STAT command output
- File: '/home/sathiyamoorthy/101hacks.txt'-absolute path name of the file.
- Size: 854-file size in bytes.
- Blocks: 8-Total number of blocks used by this file.
- Io block: 4096-io block size for this file.
- Regular file-indicates the file type. This indicates that this is a regular file. Following are available file types.
- Regular file. (EX: All normal files ).
- Directory. (EX: directories ).
- Socket. (EX: sockets ).
- Symbolic Link. (EX: symbolic links .)
- Block special file (ex: Hard Disk ).
- Character special file. (EX: terminal device file ).
- Device: 801 H/2049d-device number in Hex and device number in decimal
- Inode: 1058122-inode number is a unique number for each file which is used for the internal maintenance by the file system.
- Links: 1-Number of links to the file
- Access: (0600/-RW ---): Access specifier displayed in both octal and character format. Let us see explanation about both the format.
- UID: (1000/sathiya)-file owner's user ID and user name are displayed.
- GID: (1000/sathiya)-file owner's group ID and group name are displayed.
- Access: 19:29:57. 000000000 + 0530-last access time of the file.
- Modify: 19:29:57. 000000000 + 0530-last modification time of the file.
- Change: 19:29:57. 000000000 + 0530-last change time of the inode data of that file.
Dir stat-display information about directory
You can use the same command to display the information about a directory as shown below.
$ stat /home/rameshFile: `/home/ramesh'Size: 4096 Blocks: 8 IO Block: 4096 directoryDevice: 803h/2051d Inode: 5521409 Links: 7Access: (0755/drwxr-xr-x) Uid: ( 401/ramesh) Gid: ( 401/ramesh)Access: 2009-01-01 12:17:42.000000000 -0800Modify: 2009-01-01 12:07:33.000000000 -0800Change: 2009-01-09 12:07:33.000000000 -0800
Details of File Permission:
File Permission In octal format
This information about the file is displayed in the access field when you execute STAT command. Following are the values for read, write and execute permission in UNIX.