Most people may perform this operation when the system disk storage is low, or when the Linux system disk storage is full.

It should be performed frequently to make up disk storage space for installing a new application and processing other files. Keeping free space is a daily task for Linux administrators to allow disk utilization to stay below the threshold.

Here are some ways we can clean up our system space.

When you have terabytes of storage capacity, you probably don’t need to clean up your system. However, if you have limited space, freeing up disk space becomes unavoidable.

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 do I check available space on Ubuntu?

Use the df command on your system to check the current disk utilization.

$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/cgroupCopy the code

Graphical user interface (GUI) Users can use disk Usage Analyzer tool to view the current disk usage.

1) Remove software packages no longer needed

The following commands remove dependent libraries and packages that are no longer needed by the system. These packages are automatically installed so that an installed package satisfies dependencies. It also removes the old Linux kernel installed on the system. It removes orphan packages that are no longer needed by the system, but does not purge them.

$ sudo apt-get autoremove
[sudo] password fordaygeek: 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 Upgrade, 0 newly installed, 25 to remove and 23 not upgraded. After this operation, 189 MB disk space will be freed. Do you want tocontinue? [Y/n]
Copy the code

To clear them up, use the –purge option with the command.

$ 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* libopts25* libterm-readkey-perl* mariadb-client-core-10.1* mariadb-common* mariadb-server-10.1* Mariadb-server-core-10.1 * mysql-common* SNTP * socat* 0 Upgrade, 0 newly installed, 25 to remove and 23 not upgraded. After this operation, 189 MB disk space will be freed. Do you want tocontinue? [Y/n]
Copy the code

2) Empty the recycle bin

Chances are there’s a lot of useless data in your recycle bin. It takes up space on your system. One of the best solutions is to clean up the useless data on your system to get some free space.

To clean this up, simply use file Manager to empty your recycle bin.

3) Clean APT cache files

Ubuntu uses the APT command (advanced package tools) for package management, such as installation, removal, search, and so on.

Generally, the Linux operating system saves the downloaded and installed software package buffer files in their respective directories.

The same goes for Ubuntu, which keeps every update it downloads and installs on your disk as a buffer. Ubuntu keeps a cache of DEB packages in /var/cache/apt/archives. Over time, these caches can grow rapidly and take up a lot of space on your system.

Run the following command to check the current APT cache file usage.

$ sudo du -sh /var/cache/apt
147M    /var/cache/apt
Copy the code

The following command cleans up obsolete DEB packages. I mean, it’s not clean at all.

$ sudo apt-get autoclean
Copy the code

The following command will remove all packages from the APT cache.

$ sudo apt-get clean
Copy the code

4) Uninstall unused applications

This requires you to check the packages and games installed on your system and remove them if you rarely use them.

This can be easily done through the Ubuntu Software Center.

5) Clear thumbnail cache

The cache folder is where programs store data they may need again, reserved for speed, not necessity. It can be generated again or downloaded again. If it does fill up your hard drive, then you can delete something without worrying.

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

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

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

$ rm -rf ~/.cache/thumbnails/*
Copy the code

Via: www.2daygeek.com/linux-remov…

Magesh Maruthamuthu (Lujun9972

This article is originally compiled by LCTT and released in Linux China