5 Easy ways to free up space (Remove unwanted or junk files) on Ubuntu

Most of us will free up the disk space whenever we face out of disk space on Linux system.

It should be performed frequently, to make space for installing any new application and dealing with other important files.

Housekeeping is one of the routine task of Linux administrator, which allows them to maintain the disk utilization which is  under threshold.

There are several ways to clean up our system space.

There is no need to clean up your system when you have enough  storage capacity.

But if your have limited space then freeing up disk space becomes a necessity.

In this article, I’ll show you some of the easiest or simple ways to clean up your Ubuntu system and get more space.

How to check Free Space on Ubuntu systems?

Use df Command to check current disk utilization on your system.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            975M     0  975M   0% /dev
tmpfs           200M  1.7M  198M   1% /run
/dev/sda1        30G   16G   13G  55% /
tmpfs           997M     0  997M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           997M     0  997M   0% /sys/fs/cgroup

GUI users can use “Disk Usage Analyzer tool” to view current usage.

1) Remove the unwanted packages that are no longer required

The following command removes the dependency libs and packages that are no longer required by the system.

These packages were installed automatically to satisfy the dependencies of an installed package.

Also, it removes old Linux kernels that were installed in the system.

It removes orphaned packages which are not longer needed from the system, but not purges them.

$ sudo apt-get autoremove
[sudo] password for daygeek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  apache2-bin apache2-data apache2-utils galera-3 libaio1 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libconfig-inifiles-perl libdbd-mysql-perl
  libdbi-perl libjemalloc1 liblua5.2-0 libmysqlclient20 libopts25
  libterm-readkey-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
  mariadb-server-10.1 mariadb-server-core-10.1 mysql-common sntp socat
0 upgraded, 0 newly installed, 25 to remove and 23 not upgraded.
After this operation, 189 MB disk space will be freed.
Do you want to continue? [Y/n]

To purge them, use the --purge option together with the command for that.

$ sudo apt-get autoremove --purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  apache2-bin* apache2-data* apache2-utils* galera-3* libaio1* libapr1* libaprutil1*
  libaprutil1-dbd-sqlite3* libaprutil1-ldap* libconfig-inifiles-perl*
  libdbd-mysql-perl* libdbi-perl* libjemalloc1* liblua5.2-0* libmysqlclient20*
  libopts25* libterm-readkey-perl* mariadb-client-10.1* mariadb-client-core-10.1*
  mariadb-common* mariadb-server-10.1* mariadb-server-core-10.1* mysql-common* sntp*
  socat*
0 upgraded, 0 newly installed, 25 to remove and 23 not upgraded.
After this operation, 189 MB disk space will be freed.
Do you want to continue? [Y/n]

2) Empty the Trash Can

There might a be chance, that you may have a large amount of useless data residing in your trash.It takes up your system space. This is one of the best way to clean up those and get some free space on your system.

To clean up this, simply use the file manager to empty your trash can.

3) Clean up the APT cache

Ubuntu uses APT Command (Advanced Package Tool) for package management like installing, removing, searching, etc,.

By default every Linux operating system keeps a cache of downloaded and installed packages on their respective directory.

Ubuntu also does the same, it keeps every updates it downloads and installs in a cache on your disk.

Ubuntu system keeps a cache of DEB packages in /var/cache/apt/archives directory.

Over time, this cache can quickly grow and hold a lot of space on your system.

Run the following command to check the current utilization of APT cache.

$ sudo du -sh /var/cache/apt
147M	/var/cache/apt

It cleans obsolete deb-packages. I mean to say, less than clean.

$ sudo apt-get autoclean

It removes all packages kept in the apt cache.

$ sudo apt-get clean

4) Uninstall the unused applications

I would request you to check the installed packages and games on your system and delete them if you are using rarely.

This can be easily done via “Ubuntu Software Center”.

5) Clean up the thumbnail cache

The cache folder is a place where programs stored data they may need again, it is kept for quick access but is not essential to keep. It can be generated again or downloaded again.

If it’s really filling up your hard drive then you can delete things without worrying.

Run the following command to check the current utilization of APT cache.

$ du -sh ~/.cache/thumbnails/
412K	/home/daygeek/.cache/thumbnails/

Run the following command to delete them permanently from your system.

$ rm -rf ~/.cache/thumbnails/*

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

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