Linux is an incredibly powerful system that works well for
both server and desktop environments. But like any platform, Linux is
prone to end user mistakes and neglect. One area of neglect many users
are guilty of is folder clutter. This may sound innocuous, but it can
lead to lost data and (in worst case scenarios) even insecure/unstable
systems. Fortunately, folder clutter is something you can easily avoid
or remedy. With just a little care and maintenance, you can have a
directory structure, clean of cruft, which will serve your needs for a
very long time.
Let’s first take a look at how you can avoid clutter and then we’ll follow up with how you can cure the clutter.
Avoiding the clutter
Most all modern Linux systems go a long way to help you
avoid cluttered folders. That doesn’t, in any way, mean they handle the
issue for you. You must be pro-active in order to avoid a landslide of
files and folders from crushing your system. The good news is, from the
start, you’ll find the folder hierarchy set up in such a way as to help
you avoid the clutter.
Open up your file manager and look in your home directory. What do you see? You should see the following sub-directories:
-
Documents
-
Downloads
-
Music
-
Pictures
-
Public
-
Templates
-
Videos.
Every user created on the system will have those folders in
their home directory. There’s a reason for these folders -- for users
to place their data. Though simplistic, this folder hierarchy is
perfectly suited for the average desktop user. Save documents in
Documents, music in Music...you get the idea.
However (there’s always an “however”)...don’t just dump
every document you create, download, or are sent into the Documents
folder. Plan out a strategy. Create sub-folders within Documents, such
as:
-
Work
-
School
-
Creative
-
Schedules
The more specific you can get with your folders the better.
As for Pictures -- this is one of the folders that is most
prone to chaos. If you fancy yourself a photographer (amateur or pro),
consider using a tool like Shotwell to
do all of the image importing for you. By default, when Shotwell
imports images, it places them in a dated folder structure. This means
all of your images taken in 2014, 2013, 2012, 2011, 2010… will be saved
in folders labeled by date. If you just insert the SD card into a reader
and move all of those files into ~/Picture folder, any hope of
organization will be tossed out the window.
I tend to take this idea even further. Instead of saving
all of my crucial data on the same drive that holds the operating
system, I add a secondary drive and use it to store all of my data. I
then create links from the folders in the home directory to the folders
in the secondary drive. This does a couple of things:
-
Prevents your operating system drive from filling up
-
Allows you to reinstall your OS without worrying about losing data.
The first issue is crucial when employing smaller,
solid-state drives to house your operating system. You will want to make
sure to house your data on a secondary drive. When adding that drive,
pay very close attention to how you structure the folder hierarchy. Do
not just randomly save files and folders or you create chaos.
If you’re keen on adding extra drives, you have the
hardware, and you have large collections of multimedia, considering
adding separate drives for Documents, Music, and Videos.
Curing the clutter
But what happens when you’ve not really paid the best
attention to your directory structure and you find yourself constantly
searching for needles in an ever growing haystack? What can you to cure
your system of the clutter? Fortunately, there are a few apps and tools
out there that can help you. I want to bring to light a few of these
tools.
The first tool is Bleachbit. This system cleaner does a great job of cleaning up:
-
Cache
-
Backup files
-
Temp files
-
Cookies
-
Crash reports
-
and much more.
If you’re looking for a tool to help rid your system of:
-
Duplicate files
-
Problematic file names
-
Temp files
-
Bad symlinks
-
Empty directories
-
Nonstripped binaries.
FSlint is
what you need. The duplicate files search alone is worth getting to know
this app. With a quick search, FSlint will display all of the duplicate
files in a folder structure (image below).
Depending upon the size and the contents of the folders to
be searched, FSlint can take a while to search for duplicates, so make
sure to give it plenty of time. On a two-terabyte drive (with 73% of its
space in use), FSlint took nearly an hour to report duplicate files.
What about files and folders taking up space? You might
have left a bunch of downloaded ISO files somewhere on your drive. How
do you find them? You can try a tool like Graphical Disk Map
(or GdMap). Install this app from your default repositories and, with a
quick click, you can see what is gobbling up that disk space and just
where those large files are (image below).
Of course, if you’re on a headless or GUI-less server,
you’ll want to know how to do such things as search for duplicate files
from the command line. Thankfully, there’s regular expressions (or
regex) to help with that task. Regular expressions are an immensely
powerful tool that can do just about anything you want -- at a price.
The price? Regular expressions commands a steep learning curve. How
challenging and powerful are regular expressions? You could use the
following command to find duplicate files on your Linux drive:
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate | cut -f3-100 -d ' ' | tr '\n.' '\t.' | sed 's/\t\t/\n/g'| cut -f2-100 | tr '\t' '\n' | perl -i -pe 's/([ (){}-])/\\$1/g' | perl -i -pe 's/'\''/\\'\''/g' | xargs -pr rm -v
With just a little planning and care, you can keep your
Linux desktop free from clutter. Even if it does get out of control,
there are tools to help you out. If you know which tools to turn to, and
how best to organize your file system, gaining control of that chaos
can be quite simple.
Sign up here with your email
ConversionConversion EmoticonEmoticon