I am working on a Debian server where I have only console access without sudo. The main folder called applications includes subfolders with all the projects I have.

However, when I create a new project through my admin panel, the folder name is a nonsense string and you can rename it by creating a symlink to a new folder.

So, of example, the applications folder is like that:


I want to check how much space each of the applications use. Since I don't have a lot of experience in Unix, I googled and I found that I can do it with du -sh *.

However, the output is like that:

91M     abuwryjbrb
201M    evharjqgxj
0       MyCustomProjectName1
0       MyCustomProjectName2

As a result, it is too time consuming for me to check one by one the names and see which folder is which.

Is there any way to get an output with the disk usage for the symlinks instead?

Using du -sh -L * instead, I don't get duplicated folders for both original and symlinked, but I get a mixed output like this:

91M     abuwryjbrb
201M    MyCustomProjectName1

Where some of the folders have the original name and some the symlink name

2 Answers 2


You can get usage of symlinks using -L flag along with du command. du -sh -L * should help you.

  • I get a list of all folders without duplicates, but some are with the symlinks name and others with the original name.
    – Tasos
    Jun 25, 2017 at 9:00
  • @Tasos I didn't get you, you cannot create duplicates? so du will list all the directories inside applications directory. When you use -L flag it should show size of original directory as well as size of symlink . But for directories which are not linked, it should show only original name and size. If you have hard links too, then using -l flag will help, so try du -sh -l -L * .
    – Chetna C
    Jun 25, 2017 at 9:04
  • 1
    That's did the work. As I said, the symlink is created automatically from my admin dashboard, so I didn't know the difference on the links. Thank you a lot
    – Tasos
    Jun 25, 2017 at 9:12
du -sh -l -- */

The trailing slash causes the wildcard to match directories and symbolic links to directories. For symbolic links to directories, the command acts on the target.

-l (a GNU extension like -h) disables du's behaviour whereby disk usage of a given file/dir is only counted once. Note that it can also affect the reported disk usage for each project if there are hard links within them.

Your projects will be listed twice, once for each directory and once for its symbolic link. You can avoid that if there's an easy way to make a wildcard pattern that only matches your own names. For example, if you always capitalize your own names and the automatic ones are always lowercase, you can use

du -sh [[:upper:]]*/

Alternatively, you can use

du -shHl -- *

This lists regular files as well. The option -H (also known as -D in GNU du, -H being the standard one) tells du to dereference symbolic links passed on the command line. Symbolic links inside each directory tree are not traversed (unlike -L, which is not a good idea here).

In zsh, you can use

du -shH -- *(@-/)

to act only on symbolic links to directories, or du -shH -- *(@) to act only on symbolic links whatever their target. This time, we can omit -l, unless there are several symlinks for the same directory.

In any shell (and with GNU find), you can use

find . -maxdepth 1 -type l -xtype d -exec du -shH {} +

to act only on symbolic links to directories.

You must log in to answer this question.

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