目录大小为零的原因 [英] Reason of a directory size being zero

查看:63
本文介绍了目录大小为零的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在Linux机器上执行一些复制操作,以将目录复制到Director/misc.而且效果不佳.挖掘后才知道/misc的大小为0.日志:

Was doing some copy operation on a linux machine to the director /misc. and it did not perform well. After digging came to know that size of /misc is 0. Logs:

[root@gd911-linux-host1 misc]# ls -lrt
total 0
[root@gd911-linux-host1 misc]#

但是我自己创建了一个目录,该目录仅空&检查其大小,显示4个字节.日志:

But created a directory myself which empty only & checked its size, showing 4 bytes. Logs:

[root@gd911-linux-host1 random]# du -sk
4       .
[root@gd911-linux-host1 random]#

请让我知道这是什么原因.

Please let me know what is the reason of this.

推荐答案

这两个命令都可以100%正常运行.创建目录时,例如:

Both commands are functioning 100% correctly. When you create a directory, for example:

mkdir -p misc

目录为空.如果使用 ls 列出目录中的文件,它将按预期报告:

The directory is empty. If you use ls to list the files in the directory, it reports as expected:

$ ls -lrt misc
total 0

因为目录中有 0 个文件.现在,当您查看 du 时,目录本身所占用的磁盘使用情况,它会正确记录代表磁盘上目录的文件(索引节点,链接等)的大小.示例:

Because there are 0 files in the directory. Now when you look at du the disk usage taken by the directory itself, it correctly notes the size of the file (inode, links, etc.) that represents the directory on disk. Example:

$ du -sk misc
4       misc

请放心,两者都可以在您的系统上正常工作. ls 报告目录中包含的文件数,而 du 报告目录本身在磁盘上的实际大小.

Rest assured both are working correctly on your system. ls reporting the number of files contained within the directory, and du reporting the actual size that the directory itself takes on disk.

这篇关于目录大小为零的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆