Ich habe nicht mehr genügend Speicherplatz auf meiner Rhel-Box. Ich versuche zu findenalleDateien in /dev/sda2
. Haben wir einen Befehl, der geben kannalleDateien (idealerweise mit Größe) im Dateisystem /dev/sda2
?
/dev/sda2
31297508 28615356 1092292 97% /
mybox > df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 31297508 28615356 1092292 97% /
Antwort1
Svens Antwort beantwortete zwar die wörtliche Frage „Wie listet man alle Dateien einer Partition unter Linux auf?“, aber ich denke, die implizite Frage ist interessanter: „Wie findet man heraus, was die Laufwerke füllt?“.
Ich beginne im Stammdateisystem und verwende den du
Befehl. Dadurch erfahre ich, was der „Top Talker“ ist. Dann gehe ich in dieses Verzeichnis und mache es noch einmal, bis ich tiefer eingestiegen bin. Sie können den --max-depth=1
Teil auch entfernen, und dann werden alle Unterverzeichnisse auf einmal aufgeschlüsselt. Ich finde diese Ausgabe etwas überwältigend, aber das ist eine Stilsache.
Im folgenden Beispiel ist das Verzeichnis /etc das dicke. (Ich habe die Ausgabe etwas gekürzt.)
$ cd /
$ sudo du -amDx --max-depth=1|sort -nk1
0 ./bin
0 ./lib
0 ./lib64
0 ./sbin
1 ./lost+found
1 ./media
1 ./mnt
1 ./.rnd
1 ./srv
7 ./root
40 ./etc
46 .
$ cd etc/
$ sudo du -amDx --max-depth=1|sort -nk1
0 ./cron.deny
0 ./crypttab
0 ./environment
...
1 ./wpa_supplicant
1 ./X11
1 ./xdg
1 ./xinetd.d
1 ./yum
1 ./yum.conf
1 ./yum.repos.d
2 ./csf
2 ./pki
8 ./udev
24 ./selinux
40 .
Im folgenden Beispiel nehme ich aus derselben Box Folgendes heraus --max-depth=1
:
$ sudo du -amDx |sort -nk1
0 ./bin
0 ./etc/alternatives/cifs-idmap-plugin
0 ./etc/alternatives/ld
0 ./etc/alternatives/libnssckbi.so.x86_64
0 ./etc/alternatives/libwbclient.so.0.13-64
0 ./etc/alternatives/mta
0 ./etc/alternatives/mta-aliasesman
0 ./etc/alternatives/mta-mailq
0 ./etc/alternatives/mta-mailqman
0 ./etc/alternatives/mta-newaliases
...
1 ./etc/services
1 ./etc/sestatus.conf
1 ./etc/setuptool.d
1 ./etc/setuptool.d/98netconfig
1 ./etc/setuptool.d/98system-config-authentication
1 ./etc/setuptool.d/98system-config-display
1 ./etc/setuptool.d/98system-config-keyboard
1 ./etc/setuptool.d/99authconfig
1 ./etc/setuptool.d/99kbdconfig
1 ./etc/setuptool.d/99mouseconfig
1 ./etc/setuptool.d/99ntsysv
1 ./etc/setuptool.d/99printconf-tui
1 ./etc/setuptool.d/99sndconfig
1 ./etc/setuptool.d/99system-config-firewall-tui
1 ./etc/setuptool.d/99system-config-network-tui
1 ./etc/setuptool.d/99timeconfig
1 ./etc/setuptool.d/99Xconfigurator
1 ./etc/shadow
1 ./etc/shadow-
1 ./etc/shells
1 ./etc/skel
1 ./etc/skel/.bash_logout
1 ./etc/skel/.bash_profile
1 ./etc/skel/.bashrc
1 ./etc/smartmontools
1 ./etc/smartmontools/smartd.conf
1 ./etc/smartmontools/smartd_warning.d
1 ./etc/smartmontools/smartd_warning.sh
1 ./etc/sos.conf
1 ./etc/ssh
1 ./etc/ssh/moduli
1 ./etc/ssh/ssh_config
1 ./etc/ssh/sshd_config
1 ./etc/ssh/ssh_host_ecdsa_key
1 ./etc/ssh/ssh_host_ecdsa_key.pub
1 ./etc/ssh/ssh_host_ed25519_key
1 ./etc/ssh/ssh_host_ed25519_key.pub
1 ./etc/ssh/ssh_host_rsa_key
1 ./etc/ssh/ssh_host_rsa_key.pub
1 ./etc/ssl
1 ./etc/statetab
1 ./etc/statetab.d
1 ./etc/sudo.conf
1 ./etc/sudoers
1 ./etc/sudoers.d
1 ./etc/sudoers.d/waagent
1 ./etc/sudo-ldap.conf
1 ./etc/sysconfig
1 ./etc/sysconfig/anaconda
1 ./etc/sysconfig/atd
1 ./etc/sysconfig/authconfig
1 ./etc/sysconfig/cbq
1 ./etc/sysconfig/cbq/avpkt
1 ./etc/sysconfig/cbq/cbq-0000.example
1 ./etc/sysconfig/certbot
1 ./etc/sysconfig/chronyd
1 ./etc/sysconfig/console
1 ./etc/sysconfig/cpupower
1 ./etc/sysconfig/crond
1 ./etc/sysconfig/ebtables-config
1 ./etc/sysconfig/firewalld
1 ./etc/sysconfig/htcacheclean
1 ./etc/sysconfig/httpd
1 ./etc/sysconfig/init
1 ./etc/sysconfig/ip6tables
1 ./etc/sysconfig/ip6tables-config
1 ./etc/sysconfig/iptables
1 ./etc/sysconfig/iptables-config
1 ./etc/sysconfig/irqbalance
1 ./etc/sysconfig/kdump
1 ./etc/sysconfig/kernel
1 ./etc/sysconfig/man-db
1 ./etc/sysconfig/modules
1 ./etc/sysconfig/netconsole
1 ./etc/sysconfig/ntpdate
1 ./etc/sysconfig/raid-check
1 ./etc/sysconfig/rdisc
1 ./etc/sysconfig/readonly-root
1 ./etc/sysconfig/rpcbind
1 ./etc/sysconfig/rpc-rquotad
1 ./etc/sysconfig/rsyncd
1 ./etc/sysconfig/rsyslog
1 ./etc/sysconfig/samba
1 ./etc/sysconfig/smartmontools
1 ./etc/sysconfig/sshd
1 ./etc/sysconfig/sysstat
1 ./etc/sysconfig/sysstat.ioconf
1 ./etc/sysconfig/wpa_supplicant
1 ./etc/sysctl.conf
1 ./etc/sysctl.d
1 ./etc/systemd
1 ./etc/systemd/bootchart.conf
1 ./etc/systemd/coredump.conf
1 ./etc/systemd/journald.conf
1 ./etc/systemd/logind.conf
1 ./etc/systemd/system
1 ./etc/systemd/system/basic.target.wants
1 ./etc/systemd/system.conf
1 ./etc/systemd/system/default.target.wants
1 ./etc/systemd/system/getty.target.wants
1 ./etc/systemd/system/multi-user.target.wants
1 ./etc/systemd/system/sockets.target.wants
1 ./etc/systemd/system/sysinit.target.wants
1 ./etc/systemd/system/system-update.target.wants
1 ./etc/systemd/user
1 ./etc/systemd/user.conf
1 ./etc/system-release-cpe
1 ./etc/terminfo
1 ./etc/tmpfiles.d
1 ./etc/trusted-key.key
1 ./etc/tuned
1 ./etc/tuned/active_profile
1 ./etc/tuned/bootcmdline
1 ./etc/tuned/tuned-main.conf
1 ./etc/udev/rules.d
1 ./etc/udev/rules.d/66-azure-storage.rules
1 ./etc/udev/rules.d/99-azure-product-uuid.rules
1 ./etc/udev/udev.conf
1 ./etc/.updated
1 ./etc/updatedb.conf
1 ./etc/usb_modeswitch.conf
1 ./etc/vconsole.conf
1 ./etc/vimrc
1 ./etc/virc
1 ./etc/waagent.conf
1 ./etc/wgetrc
1 ./etc/wpa_supplicant
1 ./etc/wpa_supplicant/wpa_supplicant.conf
1 ./etc/X11
1 ./etc/X11/applnk
1 ./etc/X11/fontpath.d
1 ./etc/X11/xorg.conf.d
1 ./etc/X11/xorg.conf.d/00-keyboard.conf
1 ./etc/xdg
1 ./etc/xdg/autostart
1 ./etc/xdg/systemd
1 ./etc/xinetd.d
1 ./etc/yum
1 ./etc/yum.conf
1 ./etc/yum/fssnap.d
1 ./etc/yum/pluginconf.d
1 ./etc/yum/pluginconf.d/fastestmirror.conf
1 ./etc/yum/pluginconf.d/langpacks.conf
1 ./etc/yum/protected.d
1 ./etc/yum/protected.d/systemd.conf
1 ./etc/yum.repos.d
1 ./etc/yum.repos.d/CentOS-Base.repo
1 ./etc/yum.repos.d/CentOS-CR.repo
1 ./etc/yum.repos.d/CentOS-Debuginfo.repo
1 ./etc/yum.repos.d/CentOS-fasttrack.repo
1 ./etc/yum.repos.d/CentOS-Media.repo
1 ./etc/yum.repos.d/CentOS-Sources.repo
1 ./etc/yum.repos.d/CentOS-Vault.repo
1 ./etc/yum.repos.d/epel.repo
1 ./etc/yum.repos.d/epel-testing.repo
1 ./etc/yum.repos.d/OpenLogic.repo
1 ./etc/yum/vars
1 ./etc/yum/vars/infra
1 ./etc/yum/version-groups.conf
1 ./lost+found
1 ./media
1 ./mnt
1 ./mnt/cdrom
1 ./mnt/cdrom/secure
1 ./.rnd
1 ./root/anaconda-ks.cfg
1 ./root/.bash_history
1 ./root/.bash_logout
1 ./root/.bash_profile
1 ./root/.bashrc
1 ./root/.cache/abrt
1 ./root/.cache/abrt/lastnotification
1 ./root/.cache/pip/http/0
1 ./root/.cache/pip/http/0/2
1 ./root/.cache/pip/http/0/2/c
1 ./root/.cache/pip/http/0/2/c/7
1 ./root/.cache/pip/http/0/2/c/7/2
1 ./root/.cache/pip/http/9
1 ./root/.cache/pip/http/9/4
1 ./root/.cache/pip/http/9/4/f
1 ./root/.cache/pip/http/9/4/f/3
1 ./root/.cache/pip/http/9/4/f/3/2
1 ./root/.cache/pip/http/9/e
1 ./root/.cache/pip/http/9/e/6
1 ./root/.cache/pip/http/9/e/6/1
1 ./root/.cache/pip/http/9/e/6/1/9
1 ./root/.cache/pip/http/a
1 ./root/.cache/pip/http/a/6
1 ./root/.cache/pip/http/a/6/9
1 ./root/.cache/pip/http/a/6/9/b
1 ./root/.cache/pip/http/a/6/9/b/d
1 ./root/.cache/pip/http/a/6/d
1 ./root/.cache/pip/http/a/6/d/a
1 ./root/.cache/pip/http/a/6/d/a/3
1 ./root/.cache/pip/http/b
1 ./root/.cache/pip/http/b/9
1 ./root/.cache/pip/http/b/9/2
1 ./root/.cache/pip/http/b/9/2/d
1 ./root/.cache/pip/http/b/9/2/d/5
1 ./root/.cache/pip/http/b/b
1 ./root/.cache/pip/http/b/b/b
1 ./root/.cache/pip/http/b/b/b/e
1 ./root/.cache/pip/http/b/b/b/e/e
1 ./root/.cache/pip/http/d
1 ./root/.cache/pip/http/d/b
1 ./root/.cache/pip/http/d/b/c
1 ./root/.cache/pip/http/d/b/c/4
1 ./root/.cache/pip/http/d/b/c/4/0
1 ./root/.cache/pip/http/d/f
1 ./root/.cache/pip/http/d/f/6
1 ./root/.cache/pip/http/d/f/6/b
1 ./root/.cache/pip/http/d/f/6/b/4
1 ./root/.cache/pip/http/e
1 ./root/.cache/pip/http/e/7
1 ./root/.cache/pip/http/e/7/9
1 ./root/.cache/pip/http/e/7/9/4
1 ./root/.cache/pip/http/e/7/9/4/7
1 ./root/.cache/pip/http/e/e
1 ./root/.cache/pip/http/e/e/d
1 ./root/.cache/pip/http/e/e/d/f
1 ./root/.cache/pip/http/e/e/d/f/d
1 ./root/.cache/pip/http/e/f
1 ./root/.cache/pip/http/e/f/e
1 ./root/.cache/pip/http/e/f/e/f
1 ./root/.cache/pip/http/e/f/e/f/5
1 ./root/.cache/pip/http/f/4
1 ./root/.cache/pip/http/f/4/6
1 ./root/.cache/pip/http/f/4/6/d
1 ./root/.cache/pip/http/f/4/6/d/d
1 ./root/.cache/pip/http/f/7
1 ./root/.cache/pip/http/f/7/6
1 ./root/.cache/pip/http/f/7/6/f
1 ./root/.cache/pip/http/f/7/6/f/f
1 ./root/.cache/pip/http/f/8
1 ./root/.cache/pip/http/f/8/a
1 ./root/.cache/pip/http/f/8/a/c
1 ./root/.cache/pip/http/f/8/a/c/9
1 ./root/.cache/pip/http/f/c
1 ./root/.cache/pip/http/f/c/9
1 ./root/.cache/pip/http/f/c/9/f
1 ./root/.cache/pip/http/f/c/9/f/0
1 ./root/.cache/pip/http/f/e
1 ./root/.cache/pip/http/f/e/d
1 ./root/.cache/pip/http/f/e/d/0
1 ./root/.cache/pip/http/f/e/d/0/e
1 ./root/.cache/pip/selfcheck.json
1 ./root/.cache/pip/wheels
1 ./root/.cache/pip/wheels/8d
1 ./root/.cache/pip/wheels/8d/05
1 ./root/.cache/pip/wheels/8d/05/e9
1 ./root/.cache/pip/wheels/95
1 ./root/.cache/pip/wheels/95/14
1 ./root/.cache/pip/wheels/95/14/9a
1 ./root/.cache/pip/wheels/d7
1 ./root/.cache/pip/wheels/d7/6b
1 ./root/.cache/pip/wheels/d7/6b/69
1 ./root/.config
1 ./root/.config/abrt
1 ./root/.lesshst
1 ./root/.pki
1 ./root/.pki/nssdb
1 ./root/.rnd
1 ./root/tall epel-release
1 ./root/.tcshrc
1 ./root/.viminfo
1 ./srv
2 ./etc/csf
2 ./etc/csf/ui
2 ./etc/csf/ui/images
2 ./root/.cache/pip/http/2
2 ./root/.cache/pip/http/2/3
2 ./root/.cache/pip/http/2/3/b
2 ./root/.cache/pip/http/2/3/b/7
2 ./root/.cache/pip/http/2/3/b/7/9
3 ./root/.cache/pip/http/f
3 ./root/.cache/pip/http/f/f
3 ./root/.cache/pip/http/f/f/f
3 ./root/.cache/pip/http/f/f/f/e
3 ./root/.cache/pip/http/f/f/f/e/a
6 ./root/.cache
6 ./root/.cache/pip
6 ./root/.cache/pip/http
7 ./root
8 ./etc/udev
8 ./etc/udev/hwdb.bin
11 ./etc/selinux/targeted/active/modules
11 ./etc/selinux/targeted/active/modules/100
18 ./etc/selinux/targeted/active
24 ./etc/selinux
24 ./etc/selinux/targeted
40 ./etc
46 .
Jetzt müssen Sie nur noch in ls
die fetten Verzeichnisse gehen und herausfinden, was sich dort befindet.
Antwort2
find / -mount -type f -ls
listet alle Dateien auf, mit einer Ausgabe ähnlich zu ls -dils
.
find / -mount -type f -printf "%s %h/%f\n"
druckt nur die Größe und den Namen.
Die Option -mount
(oder -xdev
) weist find an, nicht in andere gemountete Dateisysteme einzusteigen (von denen es /
normalerweise mindestens einige gibt) und type -f
stellt sicher, dass nur Dateien und keine Verzeichnisse oder Links aufgelistet werden.
man find
Weitere Informationen finden Sie unter.
Antwort3
cd /
ls -lR > lists.txt
alle Dateien mit Verzeichnissen auflisten