fdupes - Linux'ta Yinelenen Dosyaları Bulmak ve Silmek için Bir Komut Satırı Aracı


Çoğu bilgisayar kullanıcısı için yinelenen dosyaları bulmak ve değiştirmek ortak bir gerekliliktir. Yinelenen dosyaları bulmak ve kaldırmak, zaman ve sabır gerektiren yorucu bir iştir. Makineniz GNU/Linux tarafından destekleniyorsa 'fdupes' yardımcı programı sayesinde yinelenen dosyaları bulmak çok kolay olabilir.

fdupes nedir?

Fdupes, Adrian Lopez tarafından MIT Lisansı altında yayınlanan C programlama dilinde yazılmış bir Linux yardımcı programıdır. Uygulama, verilen dizin ve alt dizin kümesindeki yinelenen dosyaları bulabilir. Fdupes, dosyaların MD5 imzasını karşılaştırıp ardından bayttan bayta karşılaştırma yaparak kopyaları tanır. Dosyaları listelemek, silmek ve kopyalara sabit bağlantılarla değiştirmek için Fdupes ile birçok seçenek aktarılabilir.

Karşılaştırma şu sırayla başlar:

boyut karşılaştırması > Kısmi MD5 İmza Karşılaştırması > Tam MD5 İmza Karşılaştırması > Bayt-Byte Karşılaştırması.

Linux'a fdupes yükleyin

fdupes'in en son sürümünün (fdupes sürüm 1.51) kurulumu, Ubuntu ve Linux Mint gibi Debian tabanlı sistemlerde aşağıdaki komutu çalıştırmak kadar kolaydır.

sudo apt-get install fdupes

CentOS/RHEL ve Fedora tabanlı sistemlerde fdupes paketini yüklemek için epel deposunu açmanız gerekir.

yum install fdupes
dnf install fdupes    [On Fedora 22 onwards]

Not: Varsayılan paket yöneticisi yum, Fedora 22'den dnf ile değiştirilmiştir. ileriye doğru…

Fdupes komutu nasıl kullanılır?

1. Gösterim amacıyla, bir dizin altında (tecmint diyelim) birkaç kopya dosya oluşturalım:

mkdir /home/"$USER"/Desktop/tecmint && cd /home/"$USER"/Desktop/tecmint && for i in {1..15}; do echo "I Love Tecmint. Tecmint is a very nice community of Linux Users." > tecmint${i}.txt ; done

Yukarıdaki komutu çalıştırdıktan sonra ls komutunu kullanarak kopya dosyaların oluşturulup oluşturulmadığını doğrulayalım.

$ ls -l

total 60
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint10.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint11.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint12.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint13.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint14.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint15.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint1.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint2.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint3.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint4.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint5.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint6.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint7.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint8.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9.txt

Yukarıdaki komut dosyası, tecmint1.txt, tecmint2.txt…tecmint15.txt olmak üzere 15 dosya oluşturur ve her dosya aynı verileri içerir; yani,

"I Love Tecmint. Tecmint is a very nice community of Linux Users."

2. Şimdi tecmint klasöründe yinelenen dosyaları arayın.

$ fdupes /home/$USER/Desktop/tecmint 

/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

3. -r seçeneğini kullanarak, alt dizinleri de dahil olmak üzere her dizinde yinelenen kopyaları arayın.

Tüm dosya ve klasörleri yinelemeli olarak arar, dosya ve klasör sayısına bağlı olarak kopyaları taramak biraz zaman alır. Bu arada terminaldeki toplam ilerleme size sunulacak, bunun gibi bir şey.

$ fdupes -r /home

Progress [37780/54747] 69%

4. -S seçeneğini kullanarak bir klasörde bulunan kopyaların boyutunu görün.

$ fdupes -S /home/$USER/Desktop/tecmint

65 bytes each:                          
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

5. -S ve -r seçeneklerini aynı anda kullanarak, karşılaşılan her dizin ve alt dizin için yinelenen dosyaların boyutunu görebilirsiniz. , gibi:

$ fdupes -Sr /home/avi/Desktop/

65 bytes each:                          
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt

107 bytes each:
/home/tecmint/Desktop/resume_files/r-csc.html
/home/tecmint/Desktop/resume_files/fc.html

6. Tek bir klasörde veya tüm klasörleri yinelemeli olarak aramanın dışında, gerektiği gibi iki klasör veya üç klasör arasından seçim yapmayı seçebilirsiniz. Gerekirse -S ve/veya -r seçeneğini kullanabileceğinizden bahsetmiyorum bile.

fdupes /home/avi/Desktop/ /home/avi/Templates/

7. Bir kopyasını korurken yinelenen dosyaları silmek için '-d' seçeneğini kullanabilirsiniz. Bu seçeneği kullanırken ekstra dikkatli olunmalıdır, aksi takdirde gerekli dosyaları/verileri kaybedebilirsiniz ve işlemin kurtarılamaz olduğunu unutmayın.

$ fdupes -d /home/$USER/Desktop/tecmint

[1] /home/tecmint/Desktop/tecmint/tecmint13.txt
[2] /home/tecmint/Desktop/tecmint/tecmint8.txt
[3] /home/tecmint/Desktop/tecmint/tecmint11.txt
[4] /home/tecmint/Desktop/tecmint/tecmint3.txt
[5] /home/tecmint/Desktop/tecmint/tecmint4.txt
[6] /home/tecmint/Desktop/tecmint/tecmint6.txt
[7] /home/tecmint/Desktop/tecmint/tecmint7.txt
[8] /home/tecmint/Desktop/tecmint/tecmint9.txt
[9] /home/tecmint/Desktop/tecmint/tecmint10.txt
[10] /home/tecmint/Desktop/tecmint/tecmint2.txt
[11] /home/tecmint/Desktop/tecmint/tecmint5.txt
[12] /home/tecmint/Desktop/tecmint/tecmint14.txt
[13] /home/tecmint/Desktop/tecmint/tecmint1.txt
[14] /home/tecmint/Desktop/tecmint/tecmint15.txt
[15] /home/tecmint/Desktop/tecmint/tecmint12.txt

Set 1 of 1, preserve files [1 - 15, all]: 

Tüm kopyaların listelendiğini ve tek tek, belirli bir aralıkta veya hepsini tek seferde silmenizin istendiğini fark edebilirsiniz. Belirli bir aralıktaki dosyaları silmek için aşağıdaki gibi bir aralık seçebilirsiniz.

Set 1 of 1, preserve files [1 - 15, all]: 2-15

   [-] /home/tecmint/Desktop/tecmint/tecmint13.txt
   [+] /home/tecmint/Desktop/tecmint/tecmint8.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint11.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint3.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint4.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint6.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint7.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint9.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint10.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint2.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint5.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint14.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint1.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint15.txt
   [-] /home/tecmint/Desktop/tecmint/tecmint12.txt

8. Güvenlik açısından, 'fdupes' çıktısını dosyaya yazdırmak ve ardından hangi dosyayı sileceğinize karar vermek için metin dosyasını kontrol etmek isteyebilirsiniz. Bu, dosyanızın yanlışlıkla silinme olasılığını azaltır. Şunları yapabilirsiniz:

fdupes -Sr /home > /home/fdupes.txt

Not: '/home''u istediğiniz klasörle değiştirebilirsiniz. Yinelemeli olarak arama yapmak istiyorsanız sırasıyla '-r' ve '-S' seçeneğini ve Baskı Boyutu'nu kullanın.

9. '-f' seçeneğini kullanarak her eşleşme grubundan ilk dosyayı hariç tutabilirsiniz.

Dizinin İlk Liste dosyaları.

$ ls -l /home/$USER/Desktop/tecmint

total 20
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (3rd copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (4th copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (another copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9 (copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug  8 11:22 tecmint9.txt

ve ardından her eşleşme grubundan ilk dosyayı çıkarın.

$ fdupes -f /home/$USER/Desktop/tecmint

/home/tecmint/Desktop/tecmint9 (copy).txt
/home/tecmint/Desktop/tecmint9 (3rd copy).txt
/home/tecmint/Desktop/tecmint9 (another copy).txt
/home/tecmint/Desktop/tecmint9 (4th copy).txt

10. fdupes'in yüklü sürümünü kontrol edin.

$ fdupes --version

fdupes 1.51

11. Fdupes konusunda yardıma ihtiyacınız olursa '-h' anahtarını kullanabilirsiniz.

$ fdupes -h

Usage: fdupes [options] DIRECTORY...

 -r --recurse     	for every directory given follow subdirectories
                  	encountered within
 -R --recurse:    	for each directory given after this option follow
                  	subdirectories encountered within (note the ':' at
                  	the end of the option, manpage for more details)
 -s --symlinks    	follow symlinks
 -H --hardlinks   	normally, when two or more files point to the same
                  	disk area they are treated as non-duplicates; this
                  	option will change this behavior
 -n --noempty     	exclude zero-length files from consideration
 -A --nohidden    	exclude hidden files from consideration
 -f --omitfirst   	omit the first file in each set of matches
 -1 --sameline    	list each set of matches on a single line
 -S --size        	show size of duplicate files
 -m --summarize   	summarize dupe information
 -q --quiet       	hide progress indicator
 -d --delete      	prompt user for files to preserve and delete all
                  	others; important: under particular circumstances,
                  	data may be lost when using this option together
                  	with -s or --symlinks, or when specifying a
                  	particular directory more than once; refer to the
                  	fdupes documentation for additional information
 -N --noprompt    	together with --delete, preserve the first file in
                  	each set of duplicates and delete the rest without
                  	prompting the user
 -v --version     	display fdupes version
 -h --help        	display this help message

Şimdilik bu kadar. Şu ana kadar Linux'ta yinelenen dosyaları nasıl bulup sildiğinizi bana bildirin. ve ayrıca bana bu yardımcı program hakkındaki düşüncelerinizi söyleyin. Değerli geri bildirimlerinizi aşağıdaki yorum bölümüne yazın ve bizi beğenmeyi/paylaşmayı ve yayılmamıza yardımcı olmayı unutmayın.

Yinelenen dosyaları kaldırmak için fslint adında başka bir yardımcı program üzerinde çalışıyorum, yakında yayınlayacağım ve siz de okumayı seveceksiniz.