GGshow reloaded GGshow reloaded

December 27, 2012

Linux command – 1.6 – File size & disk space

df – report file system disk space usage

Show information about the file system on which each FILE resides, or all file systems by default.

Usage:

df [OPTION]... [FILE]...

Options:

-a, --all include dummy file systems
-B, --block-size=SIZE use SIZE-byte blocks
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si likewise, but use powers of 1000 not 1024
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
-P, --portability use the POSIX output format
 --sync invoke sync before getting usage info
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

Example: display available disk space

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vzfs 30G 21G 9.3G 70% /
none 512M 4.0K 512M 1% /dev
/dev/vzfs 30G 21G 9.3G 70% /var/named/run-root/var/run/dbus

du – estimate file space usage

Summarize disk usage of each FILE, recursively for directories.

Usage:

du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F

Options:

-a, --all
write counts for all files, not just directories

--apparent-size
print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in (`sparse') files, internal fragmentation, indirect blocks, and the like

-B, --block-size=SIZE
use SIZE-byte blocks

-b, --bytes
equivalent to `--apparent-size --block-size=1'
-c, --total
produce a grand total

-D, --dereference-args
dereference FILEs that are symbolic links

--files0-from=F
summarize disk usage of the NUL-terminated file names specified in file F

-H
like --si, but also evokes a warning; will soon change to be equivalent to --dereference-args (-D)

-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)

--si
like -h, but use powers of 1000 not 1024

-k
like --block-size=1K

-l, --count-links
count sizes many times if hard linked

-m
like --block-size=1M

-L, --dereference
dereference all symbolic links

-P, --no-dereference
don't follow any symbolic links (this is the default)

-0, --null
end each output line with 0 byte rather than newline

-S, --separate-dirs
do not include size of subdirectories

-s, --summarize
display only a total for each argument

-x, --one-file-system
skip directories on different file systems

-X FILE, --exclude-from=FILE
Exclude files that match any pattern in FILE.

--exclude=PATTERN
Exclude files that match PATTERN.

--max-depth=N
print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize

--time
show time of the last modification of any file in the directory, or any of its subdirectories

--time=WORD
show time as WORD instead of modification time: atime, access, use, ctime or status

--time-style=STYLE
show times using style STYLE: full-iso, long-iso, iso, +FORMAT FORMAT is interpreted like `date'

--help
display this help and exit

--version
output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

Examples: display size of a directory

$ du -hs /path/to/dir
9.2G	/path/to/dir

stat – display file or file system status

Usage:

stat [OPTION]... FILE...

Options:

-L, --dereference
follow links

-f, --file-system
display file system status instead of file status

-c --format=FORMAT
use the specified FORMAT instead of the default; output a newâ line after each use of FORMAT

--printf=FORMAT
like --format, but interpret backslash escapes, and do not outâ put a mandatory trailing newline. If you want a newline, include n in FORMAT

-t, --terse
print the information in terse form

--help
display this help and exit

--version
output version information and exit

The valid format sequences for files (without --file-system):
%a Access rights in octal
%A Access rights in human readable form
%b Number of blocks allocated (see %B)
%B The size in bytes of each block reported by %b
%C SELinux security context string
%d Device number in decimal
%D Device number in hex
%f Raw mode in hex
%F File type
%G Group name of owner
%h Number of hard links
%i Inode number
%m Mount point
%n File name
%N Quoted file name with dereference if symbolic link
%o I/O block size
%s Total size, in bytes
%t Major device type in hex
%T Minor device type in hex
%u User ID of owner
%U User name of owner
%w Time of file birth, human-readable; - if unknown
%W Time of file birth, seconds since Epoch; 0 if unknown
%x Time of last access, human-readable
%X Time of last access, seconds since Epoch
%y Time of last modification, human-readable
%Y Time of last modification, seconds since Epoch
%z Time of last change, human-readable
%Z Time of last change, seconds since Epoch

Valid format sequences for file systems:
%a Free blocks available to non-superuser
%b Total data blocks in file system
%c Total file nodes in file system
%d Free file nodes in file system
%f Free blocks in file system
%i File System ID in hex
%l Maximum length of filenames
%n File name
%s Block size (for faster transfers)
%S Fundamental block size (for block counts)
%t Type in hex
%T Type in human readable form

Example: display file system status

$ stat -f /
  File: "/"
    ID: 2b6896ea6511332f Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 2090580    Free: 1663166    Available: 1558309
Inodes: Total: 524288     Free: 421462

Alternative way to display file size using ls command

$ ls -lah filename | awk '{ print $5}'
Filed under: Linux — Tags: , , , , — GG @ 8:53 pm

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

© 2024 GGSHOW | Powered by WordPress