Get and display the size of file and directory in Linux system using du command 获取和现实linux文件大小(三)
2009-09-01 10:58
1226 查看
<!--
google_ad_client = "pub-3039790253816126";
google_alternate_ad_url = "http://www.labtestproject.com/google_adsense_script.html";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_ad_channel = "3116685387";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "333333";
google_color_url = "CCCCCC";
google_ui_features = "rc:0";
//-->
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
Get and display the file
The du command ( disk
usage ) gather and summarize about how much your disk
space being used by your file and the disk space being use by directory in the Linux system
The du command can be use to find the size of file and the size of
directory in Linux system. The example below show the step to use
the du command to get the size of file and the size of directory in
Linux Fedora Core system.
Using du command to get
The du command
below show the files size in the current directory in MB or K.
[root@fedora ~]#
du -h
4.0K ./.rhopenoffice1.1/program/addin
108K ./.gnome2
28K ./.nautilus/metafiles
32K ./.nautilus
6.0M ./.mozilla/firefox/1wvl2gwo.default/Cache
12K ./.mozilla/firefox/1wvl2gwo.default/chrome
12M .
The output from above command show the size of each file, directory and with the total size
used in your system in human readable size ( -h ).
Get the total size of
The du command can be use
to determine the total size of file in current directory. The
example below show the du command use with -s (summarize) and -h
(human readable format) option to summaries the size of disk space
taken by current directory.
[root@fedora ~]#
du
-s
768096 .
[root@fedora ~]#
du -sh
751M .
[root@fedora ~]#
To get the size of file
and directory in current directory.
[root@fedora ~]#
du -sh
*
14M 20060524-033-x86.exe
85M labu-punyer
8.0K libjmti.odt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K yumex-0-1.0.1-1.0.fc5.html
408K yumex-1.0.1-1.0.fc5.noarch.rpm
8.0K yum install
11M zope-2.8.5-1.fc5.i386.rpm
[root@fedora ~]#
Display the size of
The example below show du
command execute with -c option to get the size of each file that
have filename ending with .txt
and then display grand total of
all files
in human readable format.
[root@fedora ~]#
du -ch
*.txt
4.0K create.drupal-2.txt
4.0K create.drupal.db.txt
4.0K drupal-pass.txt
4.0K joomla-bazz.txt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K msql-bazz.txt
4.0K setup_mysql_mambo.txt
4.0K simple.txt
40K total
[root@fedora ~]#
Check the size of home
The example below show
the use of du command to get the disk usage of each user home
directory on the system.
[root@fedora home]#
pwd
/home
[root@fedora home]#
du -sh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
[root@fedora home]#
To produce grand total of
the /home
directory size.
[root@fedora home]#
pwd
/home
[root@fedora home]#
du -csh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
23M total
[root@fedora home]#
The following are some of the flags and arguments that can be used for the
du command:
· -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-siz
e=1
'
· -c, --total
produce a grand total
· -D, --dereference-args
dereference FILEs that are symbolic links
· -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
· -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 filesystems
· -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
· --help
display this help and exit
· --version
output version information and exit
NAME
du - estimate file space usage
Usage: du [OPTION]... [FILE]...
Summarize disk usage of each FILE, recursively for directories.
More information on du
command:
# info du
# man du
# du --help
Keywords:
du command, check file size, check directory size, file size, directory size, file space usage, directory
space usage, size of file, size of directory, get directory size, get file size.
google_ad_client = "pub-3039790253816126";
google_alternate_ad_url = "http://www.labtestproject.com/google_adsense_script.html";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_ad_channel = "3116685387";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "333333";
google_color_url = "CCCCCC";
google_ui_features = "rc:0";
//-->
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
Get and display the file
size and the directory size using du command.
The du command ( disk usage ) gather and summarize about how much your disk
space being used by your file and the disk space being use by directory in the Linux system
The du command can be use to find the size of file and the size of
directory in Linux system. The example below show the step to use
the du command to get the size of file and the size of directory in
Linux Fedora Core system.
Using du command to get
file size.
The du command below show the files size in the current directory in MB or K.
[root@fedora ~]#
du -h
4.0K ./.rhopenoffice1.1/program/addin
108K ./.gnome2
28K ./.nautilus/metafiles
32K ./.nautilus
6.0M ./.mozilla/firefox/1wvl2gwo.default/Cache
12K ./.mozilla/firefox/1wvl2gwo.default/chrome
12M .
The output from above command show the size of each file, directory and with the total size
used in your system in human readable size ( -h ).
Get the total size of
current directory.
The du command can be use to determine the total size of file in current directory. The
example below show the du command use with -s (summarize) and -h
(human readable format) option to summaries the size of disk space
taken by current directory.
[root@fedora ~]#
du
-s
768096 .
[root@fedora ~]#
du -sh
751M .
[root@fedora ~]#
To get the size of file
and directory in current directory.
[root@fedora ~]#
du -sh
*
14M 20060524-033-x86.exe
85M labu-punyer
8.0K libjmti.odt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K yumex-0-1.0.1-1.0.fc5.html
408K yumex-1.0.1-1.0.fc5.noarch.rpm
8.0K yum install
11M zope-2.8.5-1.fc5.i386.rpm
[root@fedora ~]#
Display the size of
specific file extension.
The example below show du command execute with -c option to get the size of each file that
have filename ending with .txt
and then display grand total of
all files
in human readable format.
[root@fedora ~]#
du -ch
*.txt
4.0K create.drupal-2.txt
4.0K create.drupal.db.txt
4.0K drupal-pass.txt
4.0K joomla-bazz.txt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K msql-bazz.txt
4.0K setup_mysql_mambo.txt
4.0K simple.txt
40K total
[root@fedora ~]#
Check the size of home
directory.
The example below show the use of du command to get the disk usage of each user home
directory on the system.
[root@fedora home]#
pwd
/home
[root@fedora home]#
du -sh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
[root@fedora home]#
To produce grand total of
the /home
directory size.
[root@fedora home]#
pwd
/home
[root@fedora home]#
du -csh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
23M total
[root@fedora home]#
The following are some of the flags and arguments that can be used for the
du command:
· -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-siz
e=1
'
· -c, --total
produce a grand total
· -D, --dereference-args
dereference FILEs that are symbolic links
· -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
· -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 filesystems
· -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
· --help
display this help and exit
· --version
output version information and exit
NAME
du - estimate file space usage
Usage: du [OPTION]... [FILE]...
Summarize disk usage of each FILE, recursively for directories.
More information on du
command:
# info du
# man du
# du --help
Keywords:
du command, check file size, check directory size, file size, directory size, file space usage, directory
space usage, size of file, size of directory, get directory size, get file size.
相关文章推荐
- How to get the size of file in C++ - 在C++中如何获取文件的大小
- Directory.GetFileSystemEntries获取文件方法
- Describe the process of opening a file in Linux system, what actions the operating system w
- 基于POSIX在Linux下C语言实现读取整个目录文件[Get a List of Files in a Directory with C]
- 在移动端获取服务端文件的大小 this.fileSize = conn.getContentLength();
- Linux - fsck命令修复文件系统 | Using command fsck to repair file system
- BI Java 补丁错误处理 :Cannot login to the SAP J2EE Engine using user and password as provided in the Filesystem Secure Store. Enter va
- Linux系统中的文件目录介绍——Linux system files in the directory structure is introduced
- TDirectory.GetFileSystemEntries获取指定目录下的目录和文件
- 每日一命令(13)free - (Display amount of free and used memory in the system)
- 使用Win API 获取文件大小(可获取正在使用的文件,包括独占方式打开的文件GetFileSize)
- vb.net DirectoryNotFoundException UnauthorizedAccessException FileSystem.GetFiles获取文件 异常 权限解决
- “System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 错误
- How to Take Ownership of a File/Folder Using Command-Line in Windows 7 or newer version System
- How to get the file's icon using C++ - 用C++如何获取文件的图标
- How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:)
- How to Mount and Unmount Filesystem / Partition in Linux (Mount/Umount Command Examples)
- Time, Clocks, and the Ordering of Events in a Distributed System
- Get the command parameters in Win app and Console app
- Get the content of an Iframe in Javascript – crossbrowser solution for both IE and Firefox