Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu 11.04 and I want to free up some space in my root directory, which is overloaded. I especially want to change the path used for installing applications (they are getting installed directly to the root drive).

Another consideration is that I'm working on a MySQL database server. The server is installed in the root directory itself, so I don't want to risk losing any data.

Please give me some tips to help sort out this problem.

share|improve this question

Recently I faced similar situation. Too many applications got installed and they started using my root mount space. I am listing out few steps which I followed and hoping that you could also use the same.

  1. Clean apt-get cache. Following command will remove all downloaded deb files from apt-get cache directory.

    sudo apt-get clean

  2. Move /home mount point to different drive. Previously, my home folder was situated on root drive. So I moved my home folder to separate drive. This helped me to release lot of stress from root mount because most of applications store their data in /home/user_name/ folder. Read how to move home folder to separate drive.

  3. Increase size of root partition I know it is very obvious answer. But believe me, our data need changes over the time. I thought 20 GB /root mount would suffice but withing a year I have re-sized my root mount and increased to 50 GB.

share|improve this answer
sudo apt-get clean freed up more space than expected, +1 – btk Mar 1 '14 at 2:46
Beware that apt-get clean removes even installed packages. You may want to keep those in case an upgrade fails. – timss Jul 12 '15 at 13:56
I cleaned my cache and it cleared up 10 Gb! +1 – Numeri Feb 9 at 16:55

I successfully cleared 3.5 GB by removing old headers and images, using the following command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

WARNING: Back up your system, I don't fully understand what this command does, but it messes with kernel headers and the bootloader! You can check what packages will be purged executing the first part of the command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'


share|improve this answer
Other tips didn't help, but this saved me around 5G. Thanks. – baltasvejas Apr 14 '15 at 8:07
sudo apt-get autoclean  // clean /var/cache/apt/archives folder witch save packages while install.
sudo apt-get autoremove //this command remove unused lib packages.

sudo shutdown -rf // it will restart your pc immediately and check filesystem in next boot.
share|improve this answer
You provide no explanations. If someone was to just copy/paste your code, then the system would shut down with no warning, possibly causing a loss of data. Please don't provide commands without any explanation of what they do. -1 – Jo-Erlend Schinstad Aug 20 '11 at 19:14
Why the need to check the filesystem? – Nathan Osman Aug 20 '11 at 21:46

Use dpkg-query to find the largest packages and remove the ones you don't need anymore.

dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'


share|improve this answer

In Ubuntu, each folder can have its own filesystem. That means you can move any folder onto its own partition, another disk or even on a remote network. This is particularly popular for home directories, since that means you can reinstall Ubuntu without changing your personal settings or loosing any files. It's also popular in networks where users should be able to log onto different machines and still get their personal settings and files. But it is useful in many different cases, such as yours.

Applications aren't installed into a specific folder, like you seem to suggest. Different parts of the application is placed in different parts of the filesystem. The main program is usually placed in /usr/bin, whereas configuration files are placed in /etc, for instance. In your case, MySQL, the databases themselves are placed somewhere in /var. I think /var/mysql.

Since /usr and /var are both directories in the root filesystem, they will use the root filesystems space. But as I said, you can move them to different filesystems. In the case of MySQL, you can configure where databases are stored. You could easily move databases to /home/username/.mysql/databases for instance.

share|improve this answer

You cannot change the path where the package manager install applications. Most application files are saved to /usr. If you want to recover space on the root partition, moving /usr to a different partition is a possible solution.

From comments:

  • Preserve the permissions when copying, i.e. better use the command line if you are unsure what your file manager will do.

  • The right way to this, is to mount a new filesystem to /usr or use mount --bind. It's not clear how well a symlink would work.

share|improve this answer
careful about move /usr. use cp command to copy usr folder with same permission. then delete original /usr folder and create a link of usr folder on / . – shantanu Aug 20 '11 at 19:04
It should have a mount point. Not a link. – Jo-Erlend Schinstad Aug 20 '11 at 19:12
Small note: a lot of applications also install binaries and application data into /opt. – Nathan Osman Aug 20 '11 at 21:45
@george-edison Well, some applications install stuff in /opt against "the rules". – Jan Aug 20 '11 at 21:57

Following the instructions on the Ubuntu community docs I discovered a massive trash file -- it looked like a backup of /var/log/syslog.1, presumably something was spewing loads of output to syslog...

The command that found it was:

sudo find / -size +1G

And then any large file in a folder called .Trash is probably good to delete...

share|improve this answer

When I need make more free space on servers I use this command. It find all files bigger then 50 MB and "du -h" make berret list of files and "sort -n" after pipe make list numericcaly sorted by file size.

find / -type f -size +50M -exec du -h {} \; | sort -n
share|improve this answer

If you have a lot of seperate filesystems, the following trick might prove handy: Mount / another time, but this time under /mnt. Now all of your searching for large or many files can be done, without traversing wrong fileystems.

It can also help you find the files that are hidden under another mount.

share|improve this answer
Down voter care to explain? – steviethecat May 18 at 9:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.