1

System: Red Hat Enterprise Linux Server release 7.6 (Maipo), 3.10.0-957.12.1.el7.x86_64

GOAL: Find files that are large in size to see how they can be remediated.

Note: Folders with "application" in the name are an abstraction I chose for privacy.

What I've identified so far:

[... /] sudo du -sch * 2> /dev/null | grep -E "opt|total"
34G     opt
39G     total
[... opt] sudo du -sch * 2> /dev/null | grep -E "applicationname|total"
0       applicationsymlinkfolder
34G     applicationfolder
34G     total

What Doesn't Work:

When I try to run this command on the identified folders, the total is different than what is shown in parent folders. Can someone explain why my method of attack isn't working? (ie. 34 Gigabyte vs 1.3Gigabyte)

[... applicationfolder]$ sudo du -sch *
685M    apps
136K    bin
124K    conf
4.0K    domains
8.0K    etl_error_logs
105M    lib
4.0K    LICENSE.txt
320M    logs
4.0K    MIGRATION.txt
4.0K    application.java.status
4.0K    application.pid
4.0K    application.status
0       policies
4.0K    README.txt
36M     server-plugins
91M     services
52M     tools
1.3G    total
[... applicationfolder]$ ls -alh
total 52K
drwxr-xr-x. 14 root root 4.0K May 17 15:27 .
drwxr-xr-x.  6 root root  102 Apr 29 12:19 ..
drwxr-xr-x. 11 root root  227 May 17 15:28 apps
drwxr-xr-x.  2 root root  171 Jan  3 15:41 bin
drwxr-xr-x.  2 root root 4.0K May 17 15:27 conf
drwxr-xr-x.  3 root root   47 May 17 15:27 domains
drwxrwxrwx.  2 root root  104 May 10 06:15 etl_error_logs
drwxr-xr-x.  8 root root   84 Dec  5 14:47 lib
-rwxr-xr-x.  1 root root  519 Dec  5 14:47 LICENSE.txt
drwxr-xr-x.  2 root root 8.0K May 17 15:27 logs
-rwxr-xr-x.  1 root root 1.2K Dec  5 14:47 MIGRATION.txt
drwxr-xr-x. 23 root root 4.0K May 17 15:27 .application
-rw-r--r--.  1 root root    9 May 17 15:27 application.java.status
-rw-r--r--.  1 root root    5 May 17 15:27 application.pid
-rw-r--r--.  1 root root    9 May 17 15:27 application.status
drwxr-xr-x.  4 root root   54 Dec  5 14:47 policies
-rwxr-xr-x.  1 root root 3.6K Dec  5 14:47 README.txt
drwxr-xr-x.  3 root root   31 Dec  5 14:47 server-plugins
drwxr-xr-x.  2 root root 4.0K Dec  5 14:47 services
drwxr-xr-x.  2 root root   45 Dec  5 14:47 tools
1
  • How big is .application?
    – Kusalananda
    May 17, 2019 at 23:08

1 Answer 1

1

When using *, the pattern will by default not match hidden names. Therefore, when you run du * inside applicationfolder, the name .application will not be counted.

It is safer to use du . when wanting to find the size of the current directory.

In the bash shell, you may set the shell option dotglob using

shopt -s dotglob

Doing so will make * match hidden names (the two special directories . and .. will not be matched by * if dotglob is active).

You must log in to answer this question.

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