This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

Clean up your filesystems with fslint

By Ben Martin on October 06, 2008 (9:00:00 AM)

Share    Print    Comments   

Maintaining filesystems can be a real administration burden. Over time you might start getting multiple copies of the same file, soft links that point to files that no longer exist, temporary files that have been hanging around longer than they should, and binaries that have been installed and not had their debugging information stripped out. fslint can help you find these troublesome files so you can clean up your filesystem.

Packages for fslint are available in Ubuntu Hardy universe and in the Fedora 9 repositories. There are currently no packages for openSUSE. I built it from source using version 2.28 of fslint on a 32-bit Fedora 9 machine. fslint is written in Python and uses GTK+2 and libglade2, so you'll need these and the Python bindings for them installed first.

You can execute fslint directly from the expanded tarball as shown below or install it onto your system manually as shown in the lower half of the below commands. The fslint-gui command brings up a GTK+2 graphical user interface. Other commands include fslint and a collection of commands starting with the find prefix (for example, findup to find duplicates), which are all command-line tools.

$ tar xzf /home/ben/Download/fslint-2.28.tar.gz $ cd ./fslint* $ ./fslint-gui $ su -l # prefix=/usr/local # sharedir=$prefix/share/fslint # mkdir -p $sharedir # chmod o+rx $sharedir # cp -av doc $sharedir # chown root.root $sharedir # chown -R root.root $sharedir # chmod o=rx $sharedir # chmod o=r $sharedir # install -m 444 fslint.desktop $prefix/applications # install -pm 644 fslint.glade fslint_icon.png $sharedir # ln -s $sharedir/fslint_icon.png $prefix/share/pixmaps/fslint.png # install -m 444 man/fslint* $prefix/man/man1 # make -C po install # install -m 755 fslint-gui $prefix/bin # cp -av fslint $sharedir # chmod -R 555 $sharedir/fslint # cd $prefix/bin # perl -pi -e 's|^liblocation=.*$|liblocation="/usr/local/share/fslint" |' fslint-gui # perl -pi -e 's|^locale_base=.*$|locale_base=None |' fslint-gui

The first block of installation commands create a new directory in /usr/local/share/fslint and install the documentation files. The desktop, glade, icon, and manual pages are then installed, and make is used to install the localization files. The final two perl commands change two hard-coded paths in the fslint-gui Python code so that the glade file and other commands are sought in the correct paths. By default fslint-gui looks for the glade file in the same directory that it is executed from. This default allows you to execute fslint-gui directly in the expanded tarball, but you normally will not want to have the glade file in the same directory as the command itself.

The main window of fslint is shown below. The top part of the window lets you restrict what paths are searched and specify whether fslint will recurse into those directories. The Advanced search parameters tab lets you set paths to exclude as well as any extra parameters to pass directly to the invocation of the find command. By default /tmp, .svn, CVS, .git, /dev, /sys, and /proc are included in the list of paths to be ignored.

The body of the window contains a number of tabs vertically ordered, each of which defines a particular lint test that you can execute. You have to remember to click on the Find button to rerun the search when you change lint tabs. This can be a trap if you have already executed Find while viewing a particular lint tab, then change lint tabs and expect that the results of the previous search has had any effect on the current tab.

The Duplicates tab lets you find if you have multiple copies of any files. Duplicate file detection first checks that two files have the same size, then that the files are not hardlinks, then computes the MD5 for both files to see if they are identical. When one or more duplicates of the same file are found, for each group of identical files, the utility displays a header line telling you how many duplicates exist and how many bytes are being wasted by storing the multiple copies. In the screenshot above you can see fslint showing duplicate results for a small collection of test files that I created. When you select a duplicate, the context menu lets you open, copy, or rename the file. fslint opens files with xdg-open, so you should see a familiar application open up for most common file types.

If you have the Installed packages tab shown and click on Find, fslint will show you all the packages you have installed on your machine. There is no context menu for the packages shown in the Installed packages list. If you are running fslint as root, you can click on the delete button to remove the selected packages.

The Bad names tab allows you to find files where the file name has an invalid UTF-8 encoding. The Name clashes tab lets you find all the aliases for a file or files -- files that have the same name but are located in different directories. The aliases of a file will include all the soft or hard links to the file. Finding files that have the same name but are in different directories can be handy if you are planning to copy files to a single directory or onto a filesystem that is not case-sensitive. Unfortunately the -c option from the command-line findsn utility, which performs the Name clash search, is not exposed through the GUI, because with the -c option you can restrict the search to only showing files that are in the same directory and that have the same file name which differs only in the case of the name. Such files will cause issues when you copy them to case-insensitive filesystems. Anyone who has copied a directory tree into a flat structure on a flash drive will appreciate the name clash detection in fslint.

The Temp files tab lets you find temporary files that have been left around. You can restrict the search to only core files, and also specify the number of days old that the temporary file must be for fslint to report it. Normally, fslint checks the file name to detect if something is a temporary file -- such as files ending in ~, .swp, .v, or .bak or those starting with the # character. Although the core file test also matches on filenames first, checking whether the word core is contained anywhere in the filename, there is a subsequent test to try to make sure the file is actually a core debug file.

The Bad symlinks tab lets you find dangling links (symlinks to files where the file being linked to has been deleted); suspect links, which are absolute links to paths within or below the directory containing the link; redundant links (containing "/./" or "///," for example); or simply find all absolute or relative links.

The Bad IDs tab lets you find files or directories that have a user or group ID that is not known to your system. Such files are might exist on NFS shares or where a tarball has been expanded and you do not have the same user names and group information on your machine as the person who created the tarball. However, I could not get the Bad IDs lint test to run in the GUI -- I always got an exceptions.NameError.

The Empty directories tab sums up its own functionality. The Redundant whitespace search lets you find files that are not properly indented or which contain white space at the end of lines.

The Non stripped binaries tab lets you search the paths you have nominated or the directories in your $PATH looking for executable files that have not had their debugging information stripped out. While you might like to have binaries which include debugging information if you are developing an application, you can save on RAM and obtain faster startup times if you strip the debugging information from your binaries.

fslint also provides a command-line utility that corresponds with each of the lint tabs.

Finding duplicate files and those with bad user and group IDs can help you help clean out the lint from your filesystem. The bad link detection ranges from the generally useful dangling link detection through to the more perfectionist case of finding links that include redundant portions in their definition. It would be a great addition if fslint could also automatically remove the redundancy from these links and recreate them in their most efficient manner.

Ben Martin has been working on filesystems for more than 10 years. He completed his Ph.D. and now offers consulting services focused on libferris, filesystems, and search solutions.

Share    Print    Comments   

Comments

on Clean up your filesystems with fslint

Note: Comments are owned by the poster. We are not responsible for their content.

Clean up your filesystems with fslint

Posted by: Anonymous [ip: 75.168.82.133] on October 06, 2008 01:21 PM
It seems that Debian Lenny has fslint but not fslint-gui in its repositories...

#

Re: Clean up your filesystems with fslint

Posted by: Anonymous [ip: 84.203.137.218] on October 06, 2008 04:40 PM
fslint-gui is the command to start the GUI and is included in the fslint package

#

Clean up your filesystems with fslint

Posted by: Anonymous [ip: 70.15.192.37] on October 06, 2008 01:29 PM
it worked for me just now.
Unpacking fslint (from .../archives/fslint_2.26-2_all.deb) ...
Filename: pool/main/f/fslint/fslint_2.26-2_all.deb
Size: 106336
MD5sum: bc1acbe3a6141acd1927af129571c000
SHA1: ca8b7eefcca2c67f88044fe4e0c7a6885a7bc1a6
SHA256: 78f73ce96a2faf28e2e5f27f864445982c7826bbf8559ddeff74a672dccbf5ed
Description: A utility to fix problems with filesystems' data, like duplicate files
FSlint is a toolkit to clean filesystem lint. It includes a GTK+ GUI
as well as a command line interface and can be used to reclaim disk space.
It has an interface for uninstalling packages, and it can find things like:

#

Great!

Posted by: Anonymous [ip: 80.213.231.8] on October 06, 2008 01:49 PM
Hi,

This was a great tip. I have just cleaned out tons of old, duplicated files.

In Ubuntu, it was easily installed: "sudo aptitude install fslint".

I got the GUI by running "fslint-gui".

#

fslint in debian

Posted by: Anonymous [ip: 91.43.154.76] on October 06, 2008 02:36 PM
from aptitude show fslint:
FSlint is a toolkit to clean filesystem lint. It includes a GTK+ GUI as well as a command line interface [..]

So there is one package to rule them all ;-)

#

adding lint :)

Posted by: Anonymous [ip: 84.203.137.218] on October 06, 2008 04:46 PM
Hi I'm the author of FSlint. Thanks for the review!

It's quite ironic that the article discusses manually installing fslint, which I consider adding lint to a system :)
The fslint homepage linked above has instructions for installing packages on most linux distributions (including suse).
There are also thirdparty packages available for gentoo and arch linux at least.

Note official ubuntu/debian packages always lag behind a bit as it's ridiculously slow to get packages updated through debian (mentors).

#

Great work

Posted by: Anonymous [ip: 80.213.231.8] on October 06, 2008 05:31 PM
Hi, You have saved me a ton of disk-space. Thanks!

#

Clean up your filesystems with fslint

Posted by: Anonymous [ip: 76.74.193.182] on October 06, 2008 06:41 PM
fslint is a good program, but it definitely needs interface improvements. i'll file some suggestions...

#

Clean up your filesystems with fslint

Posted by: Anonymous [ip: 12.46.139.200] on October 06, 2008 06:56 PM
What are the actual advantages of using this over using sudo apt-get autoclean and sudo apt-get autoremove ???

#

Re: Clean up your filesystems with fslint

Posted by: JackieBrown on October 06, 2008 08:55 PM
autoclean clears your apt cache and autoremove removes packages installed due to dependency issue that no long exist (such as removing the original package that brought in extra packages.)

#

run it out of your home folder

Posted by: Anonymous [ip: 12.217.56.11] on October 06, 2008 10:13 PM
been running this nice little tool for some time now without "installing" anything. grabed the source, untar'd, & ran it out of my home folder. simple. really nice tool, even use the bash in some other scripts I have.

#

Clean up your filesystems with fslint

Posted by: Anonymous [ip: 70.15.192.37] on October 07, 2008 02:56 AM
i only ran it on my home dir and it effectivly deleted all my firefox bookmarks history and certs... so be careful with this. its generally better to run a clean system

#

Mac interface

Posted by: Anonymous [ip: 67.183.231.13] on October 07, 2008 06:01 PM
A Mac GUI with FSlint might be a good idea, possibly a good way to learn Cocoa.

#

Bill

Posted by: Anonymous [ip: 84.105.255.207] on October 07, 2008 06:31 PM
Might there come a Windows version of this? A reliable duplicate filechecker would be nice.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya