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.
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
Here is a second example which may help clarify the issues with blocks and size of file.
Size: 1114 Blocks: 8 IO Block: 4096 regular file
Device: 824h/2084d Inode: 12456570 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ mike) Gid: ( 1000/ mike)
Access: 2011-05-09 08:25:11.049624485 -0600
Modify: 2011-04-10 07:04:35.495650374 -0600
Change: 2011-04-10 07:07:46.631150468 -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 harddrive.
* IO Block–This is the size of the IO block.
* Device–The number of your storage device (harddrive, 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
If you want to see information on a particular directory, use the “-f” switch.
stat -f /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
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.