linux不自动创建sda1,Linux: Find Out Directory Size Command

I

am a new Linux user. How do I find out size of a directory on Linux operating systems using command line options?

You need to use the du command:

[a] Find and estimate file space usage.

[b] Summarize disk usage of each FILE/Directory/Folder.

[c] Shows the sizes of directories and files.

Syntax

The basic syntax is:

du

du dirName

du [options] dirName

Examples

Without any options, du command shows the names and used space for each directories including all sub-directories in the current directory:

du

Sample outputs:

d59e8f6f7f24202c213131cd3ea8606f.png

Fig.01: du command in action

To find information about /etc and /home/nixcraft directory, enter:

du /path/to/dir

du /etc

du /home/nixcraft

du /root /home/nixcraft

Pass the -h option to get output in human readable format i.e. show output in kilobytes (K), megabytes (M) and gigabytes (G):

du -h /etc

du -h /dir1/file2

du -h /root

du -h

Sample outputs:

8.0K./.vim

24K./scripts

48K./.ssh

16K./.keychain

2.2M./.lftp

2.4M.

Pass the -s option to see the total disk space used by a directory:

du -sh

du -sh /etc/

du -sh /etc /home/ /securebackup/

Sample outputs:

4.1M/etc

152K/home/

902M/securebackup/

Pass the -c to see a grand total for all of the files, type:

du -csh /root/ /etc/ /home/

Sample outputs:

2.4M/root/

4.1M/etc/

152K/home/ 6.6Mtotal

SEE ALSO

UNIX disk usage command examples - include command line tool such as du, df, ncdu, and GUI tools.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值