Linux'ta Dosya ve Dizinlerin Disk Kullanımı Nasıl Bulunur?


Linux 'du' (Disk Kullanımı), bir makinedeki dosya ve dizinlerin disk kullanım bilgilerini kontrol etmek için kullanılan standart bir Unix/Linux komutudur.

du komutu, sonuçları birçok biçimde almak için kullanılabilecek birçok parametre seçeneğine sahiptir. du komutu ayrıca dosyaları ve dizin boyutlarını yinelemeli bir şekilde görüntüler.

Bu makalede, Linux'taki dosya ve dizinlerin boyutlarını belirlemenize yardımcı olabilecek faydalı 'du' komutları örneklerle açıklanmaktadır. Bu makalede verilen bilgiler 'du' komutunun man sayfalarından alınmıştır.

Linux'ta Bir Dizinin Boyutu Nasıl Bulunur?

1. '/home/tecmint' dizin ağacı ve onun alt dizinleri için disk kullanımının bir özetini elde etmek için aşağıdaki komutu kullanın.

du /home/tecmint

4       /home/tecmint/bin
4       /home/tecmint/.ffbinaries-cache
672     /home/tecmint/.openjfx/cache/17.0.3-ea
676     /home/tecmint/.openjfx/cache
680     /home/tecmint/.openjfx
36      /home/tecmint/.ssh
92      /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96      /home/tecmint/.config/xfce4/xfconf
12      /home/tecmint/.config/xfce4/desktop
...
56758808	/home/tecmint

Yukarıdaki komutun çıktısı, /home/tecmint dizinindeki disk bloklarının sayısını alt dizinleriyle birlikte görüntüler.

İnsan Tarafından Okunabilir Formatta Dizin Boyutu Nasıl Bulunur?

2. 'du' komutuyla birlikte '-h' seçeneğini kullanarak, 'İnsan Tarafından Okunabilir' sonuçlar elde edebilirsiniz Boyutları Bayt, Kilobayt, Megabayt, Gigabayt vb. birimler halinde görüntülemenizi sağlayan Biçim'.

du -h /home/tecmint

4.0K    /home/tecmint/bin
4.0K    /home/tecmint/.ffbinaries-cache
672K    /home/tecmint/.openjfx/cache/17.0.3-ea
676K    /home/tecmint/.openjfx/cache
680K    /home/tecmint/.openjfx
36K     /home/tecmint/.ssh
92K     /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K     /home/tecmint/.config/xfce4/xfconf
12K     /home/tecmint/.config/xfce4/desktop
...
55G	/home/tecmint

Linux'ta Bir Dizinin Toplam Boyutu Nasıl Bulunur?

3. Bir dizinin toplam disk kullanım boyutunun bir özetini elde etmek için '-s' seçeneğini aşağıdaki gibi kullanın.

du -sh /home/tecmint

55G	/home/tecmint

4. 'du' komutuyla '-a' bayrağının kullanılması, tüm dosya ve dizinlerin disk kullanımını görüntüler.

du -a /home/tecmint

4       /home/tecmint/fix-deb-src-error-ubuntu
4       /home/tecmint/tecmint.py
0       /home/tecmint/bin/FoxitReader
4       /home/tecmint/bin
4       /home/tecmint/.ffbinaries-cache
52      /home/tecmint/Eclipse-with-PyDev.jpg
300     /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16      /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28      /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20      /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64      /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512     /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
...
56759528	/home/tecmint

5. '-a' bayrağının '-h' ile birlikte kullanılması, tüm dosya ve klasörlerin disk kullanımını insan tarafından okunabilir bir biçimde görüntüler biçim. Dosya boyutlarını Kilobayt, Megabayt vb. birimler halinde sunduğundan, ortaya çıkan çıktının anlaşılması daha kolaydır.

du -ah /home/tecmint

4.0K    /home/tecmint/fix-deb-src-error-ubuntu
4.0K    /home/tecmint/tecmint.py
28K     /home/tecmint/download.php?file=%2Foomph%2Fepp%2F2023-06%2FR%2Feclipse-inst-jre-linux64.tar.gz.1
0       /home/tecmint/bin/FoxitReader
4.0K    /home/tecmint/bin
4.0K    /home/tecmint/.ffbinaries-cache
52K     /home/tecmint/Eclipse-with-PyDev.jpg
300K    /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K     /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K     /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K     /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K     /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K    /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
...
55G	/home/tecmint

6. Bir dizin ağacının ve onun alt dizinlerinin disk kullanımını Kilobayt bloklar halinde belirlemek için '-k' seçeneğini kullanın (boyutları 1024 bayt birim).

du -k /home/tecmint

4       /home/tecmint/bin
4       /home/tecmint/.ffbinaries-cache
672     /home/tecmint/.openjfx/cache/17.0.3-ea
676     /home/tecmint/.openjfx/cache
680     /home/tecmint/.openjfx
8       /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12      /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36      /home/tecmint/.ssh
92      /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96      /home/tecmint/.config/xfce4/xfconf
12      /home/tecmint/.config/xfce4/desktop
4       /home/tecmint/.config/xfce4/xfwm4
8       /home/tecmint/.config/xfce4/panel/launcher-18
8       /home/tecmint/.config/xfce4/panel/launcher-17
8       /home/tecmint/.config/xfce4/panel/launcher-14
8       /home/tecmint/.config/xfce4/panel/launcher-3
8       /home/tecmint/.config/xfce4/panel/launcher-16
8       /home/tecmint/.config/xfce4/panel/launcher-5
...
56769128	/home/tecmint

7. Bir dizin ağacının, alt dizinleri de dahil olmak üzere disk kullanımının yalnızca Megabayt (MB) cinsinden bir özetini almak için '-mh' kullanın seçeneği aşağıdaki gibidir. '-m' bayrağı, blokları MB birimleri cinsinden sayar ve '-h', insan tarafından okunabilir format anlamına gelir.

du -mh /home/tecmint

4.0K    /home/tecmint/bin
4.0K    /home/tecmint/.ffbinaries-cache
672K    /home/tecmint/.openjfx/cache/17.0.3-ea
676K    /home/tecmint/.openjfx/cache
680K    /home/tecmint/.openjfx
8.0K    /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12K     /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36K     /home/tecmint/.ssh
92K     /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K     /home/tecmint/.config/xfce4/xfconf
12K     /home/tecmint/.config/xfce4/desktop
4.0K    /home/tecmint/.config/xfce4/xfwm4
8.0K    /home/tecmint/.config/xfce4/panel/launcher-18
8.0K    /home/tecmint/.config/xfce4/panel/launcher-17
8.0K    /home/tecmint/.config/xfce4/panel/launcher-14
8.0K    /home/tecmint/.config/xfce4/panel/launcher-3
...
55G	/home/tecmint

8. '-c' bayrağı, son satırdaki disk alanı kullanımının genel toplamını sağlar. Dizininiz 55GB yer kaplıyorsa çıktının son iki satırı aşağıdaki gibi görünecektir.

du -ch /home/tecmint

4.0K    /home/tecmint/bin
4.0K    /home/tecmint/.ffbinaries-cache
672K    /home/tecmint/.openjfx/cache/17.0.3-ea
676K    /home/tecmint/.openjfx/cache
680K    /home/tecmint/.openjfx
8.0K    /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12K     /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36K     /home/tecmint/.ssh
92K     /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K     /home/tecmint/.config/xfce4/xfconf
12K     /home/tecmint/.config/xfce4/desktop
4.0K    /home/tecmint/.config/xfce4/xfwm4
8.0K    /home/tecmint/.config/xfce4/panel/launcher-18
8.0K    /home/tecmint/.config/xfce4/panel/launcher-17
8.0K    /home/tecmint/.config/xfce4/panel/launcher-14
8.0K    /home/tecmint/.config/xfce4/panel/launcher-3
8.0K    /home/tecmint/.config/xfce4/panel/launcher-16
...
55G	/home/tecmint
55G	total

du Komutu ile Dosyalar Nasıl Hariç Tutulur

9. Aşağıdaki komut, verilen kalıpla eşleşen dosyalar hariç tüm dosya ve dizinlerin disk kullanımını hesaplar ve görüntüler.

Verilen örnekte komut, bir dizinin toplam boyutunu hesaplarken '.txt' dosyalarını hariç tutar. Bu yaklaşım, '--exclude' işaretini kullanarak belirli dosya formatlarını hariç tutmanıza olanak tanır.

Çıktıyı inceledikten sonra '.txt' dosyalarına ilişkin girişlerin olmadığını fark edeceksiniz.

du -ah --exclude="*.txt" /home/tecmint

4.0K    /home/tecmint/fix-deb-src-error-ubuntu
4.0K    /home/tecmint/tecmint.py
0       /home/tecmint/bin/FoxitReader
4.0K    /home/tecmint/bin
4.0K    /home/tecmint/.ffbinaries-cache
52K     /home/tecmint/Eclipse-with-PyDev.jpg
300K    /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K     /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K     /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K     /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K     /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K    /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
28K     /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_freetype.so
672K    /home/tecmint/.openjfx/cache/17.0.3-ea
...
55G	/home/tecmint

Değişiklik Zamanına Göre Dizin Kullanımı Nasıl Bulunur?

10. Disk kullanımını değişiklik zamanına göre görüntülemek için aşağıda gösterildiği gibi '--time' işaretini kullanın.

du -ha --time /home/tecmint

4.0K    2023-07-06 13:15        /home/tecmint/fix-deb-src-error-ubuntu
4.0K    2023-06-14 12:50        /home/tecmint/tecmint.py
0       2021-12-07 12:26        /home/tecmint/bin/FoxitReader
4.0K    2021-12-07 12:26        /home/tecmint/bin
4.0K    2022-10-10 11:02        /home/tecmint/.ffbinaries-cache
52K     2023-05-12 12:09        /home/tecmint/Eclipse-with-PyDev.jpg
300K    2023-07-27 14:02        /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K     2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K     2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K     2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K     2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K    2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
28K     2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_freetype.so
672K    2022-10-01 12:41        /home/tecmint/.openjfx/cache/17.0.3-ea
676K    2022-10-01 12:41        /home/tecmint/.openjfx/cache
...
55G	2023-08-14 10:22	/home/tecmint

du komutu çok yönlüdür ve çeşitli seçenekler ve işaretler kullanılarak ihtiyaçlarınıza göre uyarlanabilir. Seçenekleri ve kullanımı hakkında daha detaylı bilgi için terminalde man du komutunu kullanın.