Pinterest Stumbleupon Whatsapp
Ads by Google

So you decided to dive into the not-so-scary world of Linux 5 Lies Linux-Haters Like To Tell 5 Lies Linux-Haters Like To Tell Linux may have been a scary operating system before, but all of that has changed in recent years. These myths, which are more accurately called lies, are now dead. Read More and, as it turns out, you’re actually having a blast. That’s usually how it goes, and many people find that Linux is much easier than they expected 7 Things That Are Easier To Do In Ubuntu Than In Windows 7 Things That Are Easier To Do In Ubuntu Than In Windows Read More .

But one problem that every newbie eventually faces — although not until they’ve used Linux for a while Considering Linux? 10 Common Questions Answered Considering Linux? 10 Common Questions Answered Here are the most common questions that Windows users have about Linux. After going through this list of questions and answers, you should feel much more confident with trying out Linux. Read More — is how to free up used space. After installing so many cool apps and packages, it’s easy to find your disk partition clogged to its limit Linux Disk Space: How to Visualize Your Usage Linux Disk Space: How to Visualize Your Usage Even with terabyte drives becoming the norm, it's amazing just how fast all of that space can fill up. What if you could see your entire disk space usage at a glance? Read More .

sudo-aptget-autoremove-clean

Fortunately, there are two easy commands that you can run that instantly clean up disk space. To begin, open up a terminal and type in the first one:

sudo apt-get autoremove

When you install new packages, sometimes they have prerequisite packages that must be installed beforehand. These are called dependencies. The thing is, when you uninstall packages, dependencies aren’t always removed and they end up taking up space for no reason.

Ads by Google

The autoremove command deletes all dependencies that are no longer needed on your system.

sudo apt-get clean

When you install new packages, you actually download package files to your system (kind of like installer files on Windows), but even after packages are installed, they remain on your system (in case you need to install them again, you won’t have to re-download them). Obviously, this takes up a lot of space.

The clean command deletes all of these cached package files. There’s no risk in doing this. If you ever need to re-install a package, the package manager will just re-download it as necessary.

Note that these exact commands only work on systems using the apt-get package manager. Other package managers may have similar commands that do the same thing, but it’ll be up to you to find out what they are.

Got any other tips for quickly cleaning Linux disk space? Share with us in the comments below!

Image Credit: Linux on a Laptop by fatmawati achmad zaenuri via Shutterstock

  1. ken
    December 27, 2015 at 5:31 am

    Another variant of the clean command is sudo apt-get autoclean, same as clean just less steps. I find it tends to be more new user friendly on debian based distros.

  2. bill
    November 17, 2015 at 10:15 pm

    put log files in ramdisk :-) or the bit bucket
    good for embedded systems.

    /var/cache/apt/archives? ramdisk too

    /var/lib/apt/lists? if on embedded system, sure, ramdisk (saves the wear and tear on eMMC / SD)

    tune2fs -m0 $device
    set root-reserved percentage to 0%

  3. Ptrix
    November 17, 2015 at 5:37 pm

    Are these commands safe to use on Mac OSX?

    • John Smith
      December 5, 2015 at 11:33 pm

      No. Mac OSX does not use apt.

  4. Ihatewindows522
    November 16, 2015 at 3:39 pm

    BleachBit is a GUI frontend to do that and more. I know firsthand this is one of the best tools, and unlike what this article suggests, it works for most any distro.

    • Joel Lee
      November 18, 2015 at 3:04 am

      BleachBit is nice, thanks for bringing it up. Like CCleaner for Linux!

  5. fcd76218
    November 16, 2015 at 2:36 pm

    "sudo apt-get clean"
    If you use Synaptic Package Manager (GUI front end for apt), you can have it automatically delete downloaded packages after they are installed.

    Settings->Preferences->Files Check off "Delete downloaded packages after installation"
    On the same screen there is a button "Delete cached package files"

    • Joel Lee
      November 18, 2015 at 3:03 am

      Oh, really nice! Too bad Ubuntu's Software Center doesn't have that option. Quite useful.

      • fcd76218
        November 18, 2015 at 1:26 pm

        Ubuntu Software Center doesn't have a few other of Synaptic's useful options. Synaptic can be installed in any Debian-based distro. Even PCLinuxOS, which uses a combination of 'rpm' and 'deb' packages, uses Synaptic to manage them. Yes, I am a fan of Synaptic so you may take what I say with a pound of salt. :-)

        I mean, wouldn't you rather have Software Center's pretty looking "modern" interface and a its package-rating than Synaptic's old-fashioned functionality? /sarcasm

Leave a Reply

Your email address will not be published. Required fields are marked *