Que es Du?
El comando du es una utilidad de línea de comando para informar el uso del espacio en disco del sistema de archivos. Se puede utilizar para averiguar el uso del disco para archivos y carpetas y para mostrar qué está ocupando espacio. Admite mostrar solo directorios o todos los archivos, mostrando un gran total, con salida en formato legible para humanos y se puede combinar con otras herramientas UNIX para generar una lista ordenada de los archivos más grandes de carpetas en un sistema.
Man PageDU(1) User Commands DU(1)
NAME
du - estimate file space usage
SYNOPSIS
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
DESCRIPTION
Summarize disk usage of each FILE, recursively for directories.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
write counts for all files, not just directories
--apparent-size
print apparent sizes, rather than disk usage; although the
apparent size is usually smaller, it may be larger due to holes
in (`sparse') files, internal fragmentation, indirect blocks,
and the like
-B, --block-size=SIZE
use SIZE-byte blocks
-b, --bytes
equivalent to `--apparent-size --block-size=1'
-c, --total
produce a grand total
-D, --dereference-args
dereference only symlinks that are listed on the command line
--files0-from=F
summarize disk usage of the NUL-terminated file names specified
in file F; If F is - then read names from standard input
-H equivalent to --dereference-args (-D)
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
--si like -h, but use powers of 1000 not 1024
-k like --block-size=1K
-l, --count-links
count sizes many times if hard linked
-m like --block-size=1M
-L, --dereference
dereference all symbolic links
-P, --no-dereference
don't follow any symbolic links (this is the default)
-0, --null
end each output line with 0 byte rather than newline
-S, --separate-dirs
do not include size of subdirectories
-s, --summarize
display only a total for each argument
-x, --one-file-system
skip directories on different file systems
-X, --exclude-from=FILE
exclude files that match any pattern in FILE
--exclude=PATTERN
exclude files that match PATTERN
--max-depth=N
print the total for a directory (or file, with --all) only if it
is N or fewer levels below the command line argument;
--max-depth=0 is the same as --summarize
--time show time of the last modification of any file in the directory,
or any of its subdirectories
--time=WORD
show time as WORD instead of modification time: atime, access,
use, ctime or status
--time-style=STYLE
show times using style STYLE: full-iso, long-iso, iso, +FORMAT
FORMAT is interpreted like `date'
--help display this help and exit
--version
output version information and exit
SIZE may be (or may be an integer optionally followed by) one of fol‐
lowing: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T,
P, E, Z, Y.
PATTERNS
PATTERN is a shell pattern (not a regular expression). The pattern ?
matches any one character, whereas * matches any string (composed of
zero, one or multiple characters). For example, *.o will match any
files whose names end in .o. Therefore, the command
du --exclude='*.o'
will skip all files and subdirectories ending in .o (including the file
.o itself).
AUTHOR
Written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim
Meyering.
REPORTING BUGS
Report du bugs to [email protected]
GNU coreutils home page:
General help using GNU software:
COPYRIGHT
Copyright © 2009 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for du is maintained as a Texinfo manual. If
the info and du programs are properly installed at your site, the com‐
mand
info coreutils 'du invocation'
should give you access to the complete manual.
GNU coreutils 7.4 September 2010 DU(1)
http://linuxcommand.org/lc3_man_pages/du1.html (http://linuxcommand.org/lc3_man_pages/du1.html)
Output de comando DU en una carpeta o directorioroot@darkstar /home# du ~/
0 /root/.kde
4 /root/.ssh
4 /root/.config/fish
0 /root/.config/lftp
4 /root/.config/oxygen-gtk
4 /root/.config/gslapt
20 /root/.config/neofetch
4 /root/.config/lockdoor
40 /root/.config
276 /root/.anydesk
4 /root/.cache/pip/http/6/0/6/2/6
4 /root/.cache/pip/http/6/0/6/2
4 /root/.cache/pip/http/6/0/6
4 /root/.cache/pip/http/6/0
4 /root/.cache/pip/http/6
16 /root/.cache/pip/http/a/1/9/5/3
16 /root/.cache/pip/http/a/1/9/5
16 /root/.cache/pip/http/a/1/9
16 /root/.cache/pip/http/a/1
16 /root/.cache/pip/http/a
40 /root/.cache/pip/http/d/f/2/5/c
40 /root/.cache/pip/http/d/f/2/5
40 /root/.cache/pip/http/d/f/2
40 /root/.cache/pip/http/d/f
40 /root/.cache/pip/http/d
60 /root/.cache/pip/http
4 /root/.cache/pip/selfcheck
64 /root/.cache/pip
4 /root/.cache/dconf
5 /root/.cache/mesa_shader_cache
73 /root/.cache
20 /root/.gnupg
15442 /root/.local/share/fish/generated_completions
15458 /root/.local/share/fish
517 /root/.local/share/lftp
15974 /root/.local/share
15974 /root/.local
16415 /root/
Cómo ver un total general para un directorioPara ver un total general de un directorio, pase la opción -c. Esto mostrará la salida completa y agregará una línea total.
du -c /home/m3rsy/Pictures/
961 /home/m3rsy/Pictures/
961 total
Cómo ver el uso del disco en formato legible para humanosCómo ver el uso del disco en formato legible para humanos
Para ver el uso del disco en formato legible para humanos, pase la opción -h. En lugar de mostrar el tamaño del archivo en kilobytes para todos los archivos y carpetas, la salida se modifica a un formato legible por humanos.
root@darkstar /home# du -h ~/
0 /root/.kde
4.0K /root/.ssh
4.0K /root/.config/fish
0 /root/.config/lftp
4.0K /root/.config/oxygen-gtk
4.0K /root/.config/gslapt
20K /root/.config/neofetch
4.0K /root/.config/lockdoor
40K /root/.config
276K /root/.anydesk
4.0K /root/.cache/pip/http/6/0/6/2/6
4.0K /root/.cache/pip/http/6/0/6/2
4.0K /root/.cache/pip/http/6/0/6
4.0K /root/.cache/pip/http/6/0
4.0K /root/.cache/pip/http/6
16K /root/.cache/pip/http/a/1/9/5/3
16K /root/.cache/pip/http/a/1/9/5
16K /root/.cache/pip/http/a/1/9
16K /root/.cache/pip/http/a/1
16K /root/.cache/pip/http/a
40K /root/.cache/pip/http/d/f/2/5/c
40K /root/.cache/pip/http/d/f/2/5
40K /root/.cache/pip/http/d/f/2
40K /root/.cache/pip/http/d/f
40K /root/.cache/pip/http/d
60K /root/.cache/pip/http
4.0K /root/.cache/pip/selfcheck
64K /root/.cache/pip
4.0K /root/.cache/dconf
5.0K /root/.cache/mesa_shader_cache
73K /root/.cache
20K /root/.gnupg
16M /root/.local/share/fish/generated_completions
16M /root/.local/share/fish
517K /root/.local/share/lftp
16M /root/.local/share
16M /root/.local
17M /root/
Cómo ver el tamaño del archivo de un directorioPara ver el tamaño del archivo de un directorio, pase la opción -s al comando du seguido de la carpeta. Esto imprimirá un gran tamaño total para la carpeta a la salida estándar.
root@darkstar /home# du -sh /home/m3rsy/
19G /home/m3rsy/
Cómo ordenar por tamaño de archivo o carpetaPara ordenar por tamaño de archivo, pase la salida de du para ordenar y use las opciones -n (numérico) y -r (inverso).
root@darkstar /home# du ~/ | sort -n -r | less
40 /root/.cache/pip/http/d
20 /root/.gnupg
20 /root/.config/neofetch
16 /root/.cache/pip/http/a/1/9/5/3
16 /root/.cache/pip/http/a/1/9/5
16 /root/.cache/pip/http/a/1/9
16 /root/.cache/pip/http/a/1
16 /root/.cache/pip/http/a
5 /root/.cache/mesa_shader_cache
4 /root/.ssh
4 /root/.config/oxygen-gtk
4 /root/.config/lockdoor
4 /root/.config/gslapt
4 /root/.config/fish
4 /root/.cache/pip/selfcheck
4 /root/.cache/pip/http/6/0/6/2/6
4 /root/.cache/pip/http/6/0/6/2
4 /root/.cache/pip/http/6/0/6
4 /root/.cache/pip/http/6/0
4 /root/.cache/pip/http/6
4 /root/.cache/dconf
0 /root/.kde
0 /root/.config/lftp
lines 16-38/38 (END)
Cómo encontrar los archivos o carpetas más grandes en un sistema de archivosCómo encontrar los archivos o carpetas más grandes en un sistema de archivos
Para encontrar las carpetas más grandes en un sistema de archivos, pase la opción -a. Esto cambiará el comportamiento de du para escribir recuentos de tamaño para archivos y carpetas. Ejecute lo siguiente como root para ver los diez archivos o carpetas más grandes en un sistema. Esto puede ser útil si se trata de problemas de falta de espacio en disco en un sistema.
root@darkstar /home# du ~/ | sort -n -r |head -n 10
16415 /root/
15974 /root/.local/share
15974 /root/.local
15458 /root/.local/share/fish
15442 /root/.local/share/fish/generated_completions
517 /root/.local/share/lftp
276 /root/.anydesk
73 /root/.cache
64 /root/.cache/pip
60 /root/.cache/pip/http