Stat Utility
The stat utility allows you to see all
information about either a file or a directory. You can use wildcards if
you want to see info for more than one object at a time.
stat process.sh
File: `process.sh'
Size: 158 Blocks: 16 IO Block: 4096 regular file
Device: 305h/773d Inode: 98134 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-08-18 11:16:37.000000000 -0600
Modify: 2010-08-16 09:44:57.000000000 -0600
Change: 2010-08-16 09:44:57.000000000 -0600
Most of this should be self-explanatory, but a
few items bear explaining.
* Blocks–Each file occupies a certain number of
filesystem blocks on the hard drive. Here, we see that this file occupies
eight blocks.
* IO Block–This is the size of the IO block.
* Device–The number of your storage device (hard drive, etc.)
* Inode–The inode number that the file or directory is linked to.
* Times–Note that the timestamps also include which time zone that accesses or modifications took place in. The “-0500″ signifies the Eastern Standard time zone.
* IO Block–This is the size of the IO block.
* Device–The number of your storage device (hard drive, etc.)
* Inode–The inode number that the file or directory is linked to.
* Times–Note that the timestamps also include which time zone that accesses or modifications took place in. The “-0500″ signifies the Eastern Standard time zone.
You can use the “-c” switch, along with the
appropriate option, if you only want to look at one particular piece of
information. For example, if you only want to look at the file’s permissions
setting, you can enter:
stat -c%A process.sh
-rw-r--r—
-rw-r--r—
To see information on a particular directory, use
the “-f” switch.
stat -f /etc
File: "/etc"
ID: 0 Namelen: 255 Type: reiserfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 1977922 Free: 1272318 Available: 1272318
Inodes: Total: 0 Free: 0
File: "/etc"
ID: 0 Namelen: 255 Type: reiserfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 1977922 Free: 1272318 Available: 1272318
Inodes: Total: 0 Free: 0
Here, you see the size of the filesystem blocks
in bytes, and how many blocks are free. Don’t worry about having zero
inodes, since this drive is formatted with reiserfs filesystem. That’s
just how reiserfs reports things. In reality, there are plenty of inodes
left for use. For comparison, here’s how it would look on an ext3
filesystem.
stat -f /etc
File: "/etc"
ID: 0 Namelen: 255 Type: ext2/ext3
Blocks: Total: 9466244 Free: 7530719 Available: 7049849 Size: 4096
Inodes: Total: 4816896 Free: 4586664
File: "/etc"
ID: 0 Namelen: 255 Type: ext2/ext3
Blocks: Total: 9466244 Free: 7530719 Available: 7049849 Size: 4096
Inodes: Total: 4816896 Free: 4586664
With ext2 or ext3, you can see both the total and
the available number of inodes. Since Linux uses an inode for each file,
it appears that we can place 4,586,664 more files on this harddrive.
Comments
Post a Comment