0

First here is the size of /usr :

$ sudo du -sh /usr
6.2G    /usr
$

When doing a du on the directories at the / and selecting /usr, I get this :

$ sudo du -sh /*/ | grep /usr
du: cannot access '/proc/1800845/task/1800845/fd/4': No such file or directory
du: cannot access '/proc/1800845/task/1800845/fdinfo/4': No such file or directory
du: cannot access '/proc/1800845/fd/3': No such file or directory
du: cannot access '/proc/1800845/fdinfo/3': No such file or directory
2.5G    /usr/
$

EDIT0 : Expanding /*/ :

$ sudo du -sh /bdd/ /bin/ /boot/ /data/ /dev/ /etc/ /home/ /lib/ /lib32/ /lib64/ /libx32/ /lost+found/ /media/ /mnt/ /opt/ /proc/ /root/ /run/ /sbin/ /snap/ /srv/ /sys/ /tmp/ /usr/ /var/ / | grep /usr
du: cannot access '/proc/1807041/task/1807041/fd/4': No such file or directory
du: cannot access '/proc/1807041/task/1807041/fdinfo/4': No such file or directory
du: cannot access '/proc/1807041/fd/3': No such file or directory
du: cannot access '/proc/1807041/fdinfo/3': No such file or directory
2.5G    /usr/
$ \ls -ld /lib /lib32 /lib64 /libx32
lrwxrwxrwx 1 root root  7 Mar 17  2023 /lib -> usr/lib
lrwxrwxrwx 1 root root  9 Mar 17  2023 /lib32 -> usr/lib32
lrwxrwxrwx 1 root root  9 Mar 17  2023 /lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Mar 17  2023 /libx32 -> usr/libx32
$ \ls -ld /lib/ /lib32/ /lib64/ /libx32/
drwxr-xr-x 98 root root 4096 Jan 30 06:25 /lib/
drwxr-xr-x  2 root root 4096 Mar 17  2023 /lib32/
drwxr-xr-x  2 root root 4096 Jan 11 06:22 /lib64/
drwxr-xr-x  2 root root 4096 Mar 17  2023 /libx32/
$ sudo du -xsh /lib/
3.5G    /lib/
$

Why is du output inconsistent ?

1 Answer 1

1

du only counts each file once, even if it's found multiple times.

The first command selects /bin, which is these days generally a symlink to /usr/bin and therefore /bin contents are also /usr contents. Because it goes first in the list, those files are accounted to /bin when they're found first, and ignored when /usr is being measured next.

Example – note how the total is 23G either way:

# du -hsc /usr/
23G     /usr/
23G     total

# du -hsc /bin/ /usr/
2.6G    /bin/
20G     /usr/
23G     total

# ls -ld /bin /usr
lrwxrwxrwx 1 root root   7 Jan 19 19:10 /bin -> usr/bin/
drwxr-xr-x 1 root root 112 Feb 20 07:23 /usr/
2
  • I added EDIT0 to my question.
    – SebMa
    Commented Feb 21 at 13:26
  • Yeah, the answer is still the same whether you have /bin or /lib or both. They're still symlinks to inside /usr in your case. Commented Feb 21 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .