When the directory size displayed by the du command does not match between the parent directory and child directory in Linux. How to solve the problem? The parent directory is “
du command does not match directory size displayed
Folder devopsroles with 12M size as below
[huupv@server01 ~]$ du -sh devopsroles
12M devopsroles
Contain files and folders in devopsroles as below
[huupv@server01 devopsroles]$ ls -la
total 16
drwxr-xr-x 3 huupv huupv 4096 Feb 13 16:29 .
drwxr-xr-x 16 huupv huupv 4096 Feb 13 16:29 ..
drwxr-xr-x 2 huupv huupv 4096 Feb 13 16:07 .delete
-rw-r--r-- 1 huupv huupv 17 Feb 13 16:29 note.txt
-rw-r--r-- 1 huupv huupv 0 Feb 13 16:29 tmp.txt
In folder devopsroles different size with du -sh command.
[huupv@server01 ~]$ cd devopsroles/
[huupv@server01 devopsroles]$ pwd
/home/huupv/devopsroles
[huupv@server01 devopsroles]$ du -sh ./* | sort -hr
4.0K ./note.txt
0 ./tmp.txt
12M=4.0K + 0? Why does not it match?
Cause: du command does not show hidden directory size.
If you do the following, the file size including the hidden directory is displayed as the command below.
[huupv@server01 devopsroles]$ du -sh .[^.]*/ ./* | sort -hr
12M .delete/
4.0K ./note.txt
0 ./tmp.txt
Conclusion
In this tutorial, you can solve the problem “directory size displayed by du does not match between the parent directory and child directory” in Linux. Thank you for reading the DevopsRoles page!