如何在Linux上找出并删除重复的文件:FSlint

大家好,今天我们会学习如何在Linux PC或者服务器上找出和删除重复文件。这里有一款工具你可以工具自己的需要使用。

无论你是否正在使用Linux桌面或者服务器,有一些很好的工具能够帮你扫描系统中的重复文件并删除它们来释放空间。图形界面和命令行界面的都有。重复文件是磁盘空间不必要的浪费。毕竟,如果你的确需要在不同的位置享有同一个文件,你可以使用软链接或者硬链接,这样就可以在磁盘的一个地方存储数据了。

FSlint

FSlint 在不同的Linux发行版二进制仓库中都有,包括Ubuntu、Debian、Fedora和Red Hat。只需你运行你的包管理器并安装“fslint”包就行。这个工具默认提供了一个简单的图形化界面,同样也有包含各种功能的命令行版本。

不要担心FSlint的图形化界面太复杂。默认情况下,它会自动选中Duplicate窗格,并以你的家目录作为搜索路径。

要安装fslint,若像我这样运行的是Ubuntu,这里是默认的命令:

  1. <span class="pln">$ sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install fslint</span>

这里还有针对其他发行版的安装命令:

Debian:

  1. <span class="pln">svn checkout http</span><span class="pun">:</span><span class="com">//fslint.googlecode.com/svn/trunk/ fslint-2.45</span>
  2. <span class="pln">cd fslint</span><span class="pun">-</span><span class="lit">2.45</span>
  3. <span class="pln">dpkg</span><span class="pun">-</span><span class="pln">buildpackage </span><span class="pun">-</span><span class="pln">I</span><span class="pun">.</span><span class="pln">svn </span><span class="pun">-</span><span class="pln">rfakeroot </span><span class="pun">-</span><span class="pln">tc</span>
  4. <span class="pln">sudo dpkg </span><span class="pun">-</span><span class="pln">i </span><span class="pun">../</span><span class="pln">fslint_2</span><span class="pun">.</span><span class="lit">45</span><span class="pun">-</span><span class="lit">1</span><span class="pln">_all</span><span class="pun">.</span><span class="pln">deb</span>

Fedora:

  1. <span class="pln">sudo yum install fslint</span>

OpenSUSE:

  1. <span class="pun">[</span><span class="pun">-</span><span class="pln">f </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">mandrake</span><span class="pun">-</span><span class="pln">release </span><span class="pun">]</span><span class="pun">&&</span><span class="pln"> pkg</span><span class="pun">=</span><span class="pln">rpm</span>
  2. <span class="pun">[</span><span class="pun">-</span><span class="pln">f </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="typ">SuSE</span><span class="pun">-</span><span class="pln">release </span><span class="pun">]</span><span class="pun">&&</span><span class="pln"> pkg</span><span class="pun">=</span><span class="pln">packages</span>
  3. <span class="pln">wget http</span><span class="pun">:</span><span class="com">//www.pixelbeat.org/fslint/fslint-2.42.tar.gz</span>
  4. <span class="pln">sudo rpmbuild </span><span class="pun">-</span><span class="pln">ta fslint</span><span class="pun">-</span><span class="lit">2.42</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz</span>
  5. <span class="pln">sudo rpm </span><span class="pun">-</span><span class="typ">Uvh</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">src</span><span class="pun">/</span><span class="pln">$pkg</span><span class="pun">/</span><span class="pln">RPMS</span><span class="pun">/</span><span class="pln">noarch</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">-</span><span class="lit">2.42</span><span class="pun">-</span><span class="lit">1.</span><span class="pun">*.</span><span class="pln">noarch</span><span class="pun">.</span><span class="pln">rpm</span>

对于其他发行版:

  1. <span class="pln">wget http</span><span class="pun">:</span><span class="com">//www.pixelbeat.org/fslint/fslint-2.44.tar.gz</span>
  2. <span class="pln">tar </span><span class="pun">-</span><span class="pln">xzf fslint</span><span class="pun">-</span><span class="lit">2.44</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz</span>
  3. <span class="pln">cd fslint</span><span class="pun">-</span><span class="lit">2.44</span>
  4. <span class="pun">(</span><span class="pln">cd po </span><span class="pun">&&</span><span class="pln"> make</span><span class="pun">)</span>
  5. <span class="pun">./</span><span class="pln">fslint</span><span class="pun">-</span><span class="pln">gui</span>

要在Ubuntu中运行fslint的GUI版本fslint-gui, 使用Alt+F2运行命令或者在终端输入:

  1. <span class="pln">$ fslint</span><span class="pun">-</span><span class="pln">gui</span>

默认情况下,它会自动选中Duplicate窗格,并以你的家目录作为搜索路径。你要做的就是点击Find按钮,FSlint会自动在你的家目录下找出重复文件列表。

如何在Linux上找出并删除重复的文件:FSlint

点击按钮来删除任何你要删除的文件,并且可以双击预览。

完成这一切后,我们就成功地删除你系统中的重复文件了。

注意 ,命令行工具默认不在环境的路径中,你不能像典型的命令那样运行它。在Ubuntu中,你可以在/usr/share/fslint/fslint下找到它。因此,如果你要在一个单独的目录运行fslint完整扫描,下面是Ubuntu中的运行命令:

  1. <span class="pln">cd </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">/</span><span class="pln">fslint</span>
  2. <span class="pun">./</span><span class="pln">fslint </span><span class="pun">/</span><span class="pln">path</span><span class="pun">/</span><span class="pln">to</span><span class="pun">/</span><span class="pln">directory</span>

这个命令实际上并不会删除任何文件。它只会打印出重复文件的列表-你需要自己做接下来的事。

  1. <span class="pln">$ </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">/</span><span class="pln">findup </span><span class="pun">--</span><span class="pln">help</span>
  2. <span class="pln">find dUPlicate files</span><span class="pun">.</span>
  3. <span class="typ">Usage</span><span class="pun">:</span><span class="pln"> findup </span><span class="pun">[[[-</span><span class="pln">t </span><span class="pun">[-</span><span class="pln">m</span><span class="pun">|-</span><span class="pln">d</span><span class="pun">]]</span><span class="pun">|</span><span class="pun">[--</span><span class="pln">summary</span><span class="pun">]]</span><span class="pun">[-</span><span class="pln">r</span><span class="pun">]</span><span class="pun">[-</span><span class="pln">f</span><span class="pun">]</span><span class="pln"> paths</span><span class="pun">(</span><span class="pln">s</span><span class="pun">)</span><span class="pun">...]</span>
  4. <span class="typ">If</span><span class="kwd">no</span><span class="pln"> path</span><span class="pun">(</span><span class="pln">s</span><span class="pun">)</span><span class="pln"> specified </span><span class="kwd">then</span><span class="pln"> the current directory </span><span class="kwd">is</span><span class="pln"> assumed</span><span class="pun">.</span>
  5. <span class="typ">When</span><span class="pun">-</span><span class="pln">m </span><span class="kwd">is</span><span class="pln"> specified any found duplicates will be merged </span><span class="pun">(</span><span class="kwd">using</span><span class="pln"> hardlinks</span><span class="pun">).</span>
  6. <span class="typ">When</span><span class="pun">-</span><span class="pln">d </span><span class="kwd">is</span><span class="pln"> specified any found duplicates will be deleted </span><span class="pun">(</span><span class="pln">leaving just </span><span class="lit">1</span><span class="pun">).</span>
  7. <span class="typ">When</span><span class="pun">-</span><span class="pln">t </span><span class="kwd">is</span><span class="pln"> specfied</span><span class="pun">,</span><span class="pln"> only report what </span><span class="pun">-</span><span class="pln">m </span><span class="kwd">or</span><span class="pun">-</span><span class="pln">d would </span><span class="kwd">do</span><span class="pun">.</span>
  8. <span class="typ">When</span><span class="pun">--</span><span class="pln">summary </span><span class="kwd">is</span><span class="pln"> specified change output format to include file sizes</span><span class="pun">.</span>
  9. <span class="typ">You</span><span class="pln"> can also pipe </span><span class="kwd">this</span><span class="pln"> summary format to </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">/</span><span class="pln">fslint</span><span class="pun">/</span><span class="pln">fstool</span><span class="pun">/</span><span class="pln">dupwaste</span>
  10. <span class="pln">to </span><span class="kwd">get</span><span class="pln"> a total of the wastage due to duplicates</span><span class="pun">.</span>

如何在Linux上找出并删除重复的文件:FSlint

相关推荐