سؤال

Windirstat/ Kdirstat/ Disk Inventory X has been nothing short of revolutionary in file managment. Why is there no text-only command line equivalent? I'd need it for SSH administration of my file servers.

We have all the building blocks: du, tree etc.

Is there one? Why not? Can someone please write one? :)

EDIT: du does ALMOST what I want. What I want is something that sorts each subdirectory by size (rather than full path) and indents so that it's easier to avoid double-counting. du would give me this:

cd a
du . -h

1G  b
2G  c
1K  c/d
1K  c/e
2G  c/f

It's not immediately obvious that c and c/f are overlapping. What I want is this:

cd a
dir_stats .

1G  b
2G  c
    |
    +---- 2G  f
    |
    +---- 1K  d
    |
    +---- 1K  e

in which it is clear that the 2G from f is because of the 2G from c. I can find all the info not related to c more easily (i.e. by just scanning the first column).

هل كانت مفيدة؟

المحلول 4

Don't bother trying to do disk space management with ascii art visializations. Du follows Unix's elegant philosophy in all respects and so gives you sorting etc for free.

Get comfortable with du and you'll have much more power in finding disk hogs remotely

نصائح أخرى

I'd recommend using ncdu, which stands for NCurses Disk Usage. Basically it's a collapsible version of du, with a basic command line user interface.

One thing worth noting is that it runs a bit slower than du on large amounts of data, so I'd recommend running it in a screen or using the command line options to first scan the directory and then view the results. Note the q option, it reduces the refresh rate from 1/10th of a second to 2 seconds, recommended for SSH connections.

Viewing total root space usage:

ncdu -xq /

Generate results file and view later:

ncdu -1xqo- / | gzip > export.gz
# ...some time later:
zcat export.gz | ncdu -f-

You can use KDirStat (or the new QDirStat) together with the perl script that comes along with either one to collect data on your server, then copy that file to your desktop machine and view it with KDirStat / QDirStat.

See also

https://github.com/shundhammer/qdirstat/tree/master/scripts

or

https://github.com/shundhammer/kdirstat/blob/master/kdirstat/kdirstat-cache-writer

The script does not seem to be included with the KDE 4 port K4DirStat, but it can still read and write the same cache files.

-- HuHa (Stefan Hundhammer - author of the original KDirStat)

As mentioned here: https://unix.stackexchange.com/questions/45828/print-size-of-directory-content-with-tree-command-in-tree-1-5

tree --du -h -L 2

is very much in the right spirit of my goal. The only problem is, I don't think it supports sorting so is not suitable for huge file system hierarchies :(

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top