LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.





Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.



stat

stat [options] files

Print out the contents of an inode as they appear to the stat system call in a human-readable format. The error messages "Can't stat file" and "Can't lstat file" usually mean the file doesn't exist. "Can't readlink file" generally indicates that something is wrong with a symbolic link.

Options

-c format, --format=format

Display the output as specified by format.

-f, --filesystem

Display information about the filesystem where the file is located, not about the file itself.

--help

Display help information and exit.

-L, --dereference

Follow links and display information about the files found.

-t

Print the output tersely, in a form suitable for parsing by other programs.

--version

Print version information and exit.

Output

stat and stat -L display the following:

Device number

Inode number

Access rights

Number of hard links

Owner's user ID and name, if available

Owner's group ID and name, if available

Device type for inode device

Total size, in bytes

Number of blocks allocated

I/O block size

Last access time

Last modification time

Last change time

Security context for SELinux

If -f is specified, stat displays the following information about the filesystem:

Filesystem type

Filesystem block size

Total blocks in the filesystem

Number of free blocks

Number of free blocks for nonroot users

Total number of inodes

Number of free inodes

Maximum filename length

Format

The printf(3) flag characters #, 0, -, +, and space can be used in format. In addition, the field width and precision options can be used.

If -c format is specified, the following sequences can be used for format:

%a

Access rights in octal.

%A

Access rights in human-readable form.

%b

Number of blocks allocated.

%B

Size in bytes of each block reported by %b.

%d

Device number in decimal.

%D

Device number in hex.

%f

Raw mode in hex.

%F

File type.

%g

Owner's group ID.

%G

Owner's group name.

%h

Number of hard links.

%i

Inode number.

%n

Filename.

%N

Quoted filename. If file is a symbolic link, include path to original.

%o

I/O block size.

%s

Total size, in bytes.

%t

Major device type in hex.

%T

Minor device type in hex.

%u

Owner's user ID.

%U

Owner's username.

%x

Last access time.

%X

Last access time as seconds since the Epoch.

%y

Last modification time (modification of the file contents).

%Y

Last modification time as seconds since the Epoch.

%z

Time of last change (modification of the inode).

%Z

Time of last change as seconds since the Epoch.

If both -c format and -f are specified, the following sequences can be used for format:

%a

Free blocks available to nonroot user.

%b

Total data blocks in filesystem.

%c

Total file nodes in filesystem.

%d

Free file nodes in filesystem.

%f

Free blocks in filesystem.

%i

Filesystem ID, in hex.

%l

Maximum filename length.

%n

Filename.

%s

Optimal transfer block size.

%t

Type in hex.

%T

Type in human-readable form.

Examples

Sample output from the command stat /:

stat / File: "/" Size: 4096 Blocks: 8 IO Block: 4096 Directory Device: 303h/771d Inode: 2 Links: 19 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: Thu Jan 2 04:02:40 2003 Modify: Wed Jan 1 23:03:20 2003 Change: Wed Jan 1 23:03:20 2003

Sample output with -f, displaying information about the filesystem:

stat -f / File: "/" ID: 0 0 Namelen: 255 Type: ext2/ext3 Blocks: Total: 2612475 Free: 1869472 Available: 1736735 Size: 4096 Inodes: Total: 1329696 Free: 1150253