- Essential Guide: 5 Simple Ways To Free Up Space on Ubuntu
- 1. Clean the APT Cache (And Do It Regularly)
- 2. Remove Old Kernels (If No Longer Required)
- 3. Uninstall Apps & Games You Never Use (And Be Honest!)
- 4. Use A System Cleaner like BleachBit
- 5. Stay up to date (seriously, do it!)
- Summary
- How To Clear .Cache Folders and Free Up Space On Your Linux PC
- Cache File Location
- Installation
- Clear Cache files and folders
- WARNING!
- 7 Simple Ways to Free Up Space on Ubuntu and Linux Mint
- Check free space on Ubuntu
- How to free up disk space in Ubuntu and Linux Mint
- 1. Get rid of packages that are no longer required [Recommended]
- 2. Uninstall unnecessary applications [Recommended]
- 3. Clean up APT cache in Ubuntu
- 4. Clear systemd journal logs [Intermediate knowledge]
- 5. Remove older versions of Snap applications [Intermediate knowledge]
- 6. Clean the thumbnail cache [Intermediate knowledge]
- 7. Find and remove duplicate files
- 4. Remove old Linux kernels that were manually installed [For Experts]
- 5. Remove orphaned packages [For Experts]
- Bonus Tip: Using GUI tools to free space in Ubuntu
- Wrapping up
Essential Guide: 5 Simple Ways To Free Up Space on Ubuntu
Let’s say you need to free up space on Ubuntu — how do you go about it?
Unlike Windows, which comes with built-in defrag and disk clean-up tools, Ubuntu doesn’t make it immediately obvious how you go about trying to free up space.
So what do you do once you’ve emptied the trash and deleted those sizeable .ISO downloads? How do you recover more space?
Below, we show you 5 super simple (and in some cases blindingly obvious yet easily forgotten) steps you can take to get back GBs, materialise MBs, and clean out the KB cruft!
Next time you need more space — and heck: even if you don’t — here are 5 simple ways to free up disk space on Ubuntu.
1. Clean the APT Cache (And Do It Regularly)
It sounds so obvious yet chances are you haven’t done this for a while.
By default Ubuntu keeps every update it downloads and installs in a cache on your disk, just in case you ever need it again.
This is useful if you regularly add and remove apps, find yourself needing to reconfigure/reinstall a specific package, or simply have a poor connection.
But the flip side is that the apt package cache can quickly swell to several hundred MBs. This command tells you how big your apt cache is:
To clean the apt cache on Ubuntu simply run the following command.
The apt clean command removes ALL packages kept in the apt cache, regardless of age or need. If you’re on a slow, capped or intermittent connection you may want to consider skipping this step.
2. Remove Old Kernels (If No Longer Required)
Now, admittedly, this step is one you want to approach with caution.
Having a choice of kernels to boot up is, honestly, quite handy, especially if you notice something has gone awry while using the latest one.
Unless you’re in the throes of constant hardware woes there’s little need to hoard kernels.
It’s easy to remove old kernels in Ubuntu. You can do it from the command line using the following command:
Note that this command will only remove kernels that a) are no longer needed and b) were installed from the Ubuntu archive through system updates. If you install kernels manually or using a third-party PPA you’ll need to roll up your sleeves and remove those manually.
3. Uninstall Apps & Games You Never Use (And Be Honest!)
Chances are you have a number of apps installed that you never use. Maybe you installed them on the back of an awesome review, out of nosiness, or to tackle a specific task.
Whatever the excuse, if you no longer need an app, and it’s taking up space, don’t be afraid to uninstall it.
Typical apps you may wish to expunge include web browsers (are you ever going to use Opera, Epiphany, Midori and Min?), music players (heck knows there’s enough of ’em) and games that sounded good in the Steam Store blurb but were as much fun as a Windows 10 update combo!
And everyone has LibreOffce Draw knocking about doing nothing! 😅
Don’t lie to yourself about might-needs and could-dos, either. The beauty of most software is that it’s not going away anytime soon. This is never truer than on Linux, where apps remain an apt install command away.
To remove apps from the command line run:
To remove excess packages and dependencies that are no longer required (because you’ve uninstalled other packages or newer versions have replaced them) run the following command:
4. Use A System Cleaner like BleachBit
Writing a “to-do” list on system cleaning would end up 10x longer if we listed every app, cache, log and system process hiding in every nook and cranny of your OS.
BleachBit saves us from doing that.
It’s like CCleaner for Linux; a byte scouring beast. The app can find and clean pretty much every fluff file there is and, as a result, should only ever be used with caution.
BleachBut can wipe the caches of more than 70 popular desktop applications (including most web browsers); hoover up old file, browser and bash histories; and makes light work of those crash logs you’ll never get around to reading.
No surprise that we recommend installing it as one of our top things to do after installing Ubuntu.
You can install BleachBit on Ubuntu 16.04 LTS (and above) straight from Ubuntu Software.
Run the app as root for maximum cleaning power. Check the boxes beside the things you’d like to clean. Click Preview to see an estimate of how much space they currently take up, and click Clean to remove them.
5. Stay up to date (seriously, do it!)
The most obvious step on this list is also the one few people would think to recommend. See, unlike Windows, where every new update adds more overhead and bloat, package updates on Linux often free space rather than use it.
So next time you put off that 156MB librandom-package102 update cos you’re running low on space, maybe think again!
Summary
That just about covers it. If you only remember two steps from this list make it the first and last.
- Clean your apt cache from time-to-time
- Install patches, updates, and fixes
Now go forth and free space!
Let us know how much space you manage to claw back or share your own top space-saving tips in the comments!
Home » How To » 5 Simple Ways To Free Up Space on Ubuntu
Источник
How To Clear .Cache Folders and Free Up Space On Your Linux PC
Clean up your cache in a few easy steps!
GNU/Linux has implemented efficient storage management for its users. But have you noticed your Linux system running out of space, filled with unused packages you installed months or years ago? How do find them and remove them? Here are a few valuable tips!
Cache File Location
Cache files are stored in /home/username/.cache which mostly consists of your browser’s data, IDE’s (if you use any ) and other software. Each user has its own data and this can build up exponentially . In order to clear it all it’s recommended to have Disk usage analyzer installed.
Disk Usage Analyzer
Disk Usage Analyzer, formerly known as Baobab, is a graphical disk usage analyzer for the GNOME desktop environment. It was part of gnome-utils, but has been a standalone application since GNOME 3.4.
The software gives the user a graphical representation of a disk drive’s contents. The interface allows for selection of specific parts of filesystem so a single folder, the entire filesystem, and even remote folders and filesystems can be scanned and listed at the folder level.
The graphical representation can be switched between a ‘Rings’ chart and a ‘Treemap’ chart to better suit the content being viewed.
Installation
If you don’t already have Disk Usage Analyzer installed, you first need to install the baobab package:
Clear Cache files and folders
Click on home for your user data .
Click on your second disk i.e Vostro-14-3468 as shown in the image below .
Note: Names will be different on your own computer.
Here, the other disks shown as New Volume / 262 GB volume are formatted disks for a dual boot system, in my case Ubuntu 20.10 and Windows 10.
As you click on it, the Disk Usage Analyzer will start to scan your directory for files and folders. Be patient and allow it to finish. After Disk Usage Analyzer is done scanning your Linux PC for files it shows the live illustration of Linux disk usage as the form of a pie chart.
To see updated changes in your filesystem, you’ll need to refresh the scan as it won’t track these storage changes “live.”
Look in the folder tree structure for .cache, and click on it .
Once you click on the .cache folder, the disk usage analyzer will show you the space it’s consuming graphically on the right side .
- Find the sub folders inside it which you wish to delete .
- Right-click each one
- Select Move to trash / bin
- Now empty your trash / bin
And you are done!
Do not worry about deleting these folders. It is totally safe and the software will recreate them if and when it needs to.
WARNING!
Do not delete anything from your usr and var directories. usr is used for “user programs”. Usually your package manager installs all the binaries, shared files etc. from all programs here (except config files, which go to /etc).
You can check /usr/bin for binaries, /usr/share for shared files (media, etc), /usr/share/doc for documentation.
There is also an /opt folder, where there are “other” binary programs or programs installed from sources other than the default package manager. Some programs like that (usually compiled) also go to usr/local
/var is usually used for log files, ‘temporary’ files (like mail spool, printer spool, etc), databases, and all other data not tied to a specific user.
Logs are usually in /var/log databases in var/lib (mysql — var/lib/mysql ), etc.
If you liked this article, please follow the author on medium !
Источник
7 Simple Ways to Free Up Space on Ubuntu and Linux Mint
Last updated January 26, 2021 By Abhishek Prakash 168 Comments
Brief: Running out of space on your Linux system? Here are several ways you can clean up your system to free up space on Ubuntu and other Ubuntu based Linux distributions.
Over time, any operating system can become cluttered as programs are added and removed. If you have like a TB of storage capacity, you might not bother to clean up Ubuntu to make some disk space. But if your hard disk has limited space, like I have a 128 GB SSD laptop, freeing up disk space becomes a necessity.
In this article, I’ll show you some of the easiest tricks to clean up your Ubuntu system and get more space. I’ll also share some advanced tricks so that you’ll have choice.
But before that, let’s see how to find the free space remaining on Ubuntu.
Check free space on Ubuntu
It’s always a good idea to check the free disk space in Linux first. This is rather easy on Ubuntu. Just use Disk Usage Analyzer tool. Search it in the menu and run the tool. You should see the disk space used and the free space remaining in here:
Once you know the state of free space on your disk, it’s time to clean up your system and make some more free space here.
How to free up disk space in Ubuntu and Linux Mint
There are several ways you clean up disk space in Ubuntu and other Ubuntu based system. I have discussed several command line tricks here followed by some GUI options.
While I have mentioned several ways here, if you are a beginner, avoid the ones marked as ‘expert’. Not that you cannot use them, but it’s better to avoid if you don’t know what you are doing.
I am using Ubuntu 16.04 while writing this tutorial but you can use the same steps for Ubuntu 18.04 and other Ubuntu versions, Linux Mint, elementary OS and other Ubuntu-based Linux distributions.
If you prefer videos, I have made a video to show you how to clean Ubuntu.
1. Get rid of packages that are no longer required [Recommended]
If you read the apt-get commands guide, you might have come across the apt-get command option ‘autoremove’.
This option removes libs and packages that were installed automatically to satisfy the dependencies of an installed package. If that package is removed, these automatically installed packages are useless in the system.
It also removes old Linux kernels that were installed from automatically in the system upgrade.
It’s a no-brainer command that you can run from time to time to make some free space on your Ubuntu system:
As you can see, this command is going to free up 300 Mb of free space in my system.
2. Uninstall unnecessary applications [Recommended]
We all have a few games and/or applications that we hardly use. Don’t trust me? Go and find all the installed software on your Ubuntu system.
Chances are that you have a number of apps installed that you seldom use. Maybe you installed them on the back of an awesome review, out of nosiness, or to handle a particular task.
If you need space more getting rid of the unused or lesser used applications is always a good idea.
You can remove a program in Ubuntu from the software centre or using the command below with particular app name:
3. Clean up APT cache in Ubuntu
Ubuntu uses APT (Advanced Package Tool) for installing, removing and managing software on the system, and in doing so it keeps a cache of previously downloaded and installed packages even after they’ve been uninstalled.
The APT package management system keeps a cache of DEB packages in /var/cache/apt/archives. Over time, this cache can grow quite large and hold a lot of packages you don’t need.
You can see the size of this cache with the du command below:
As you can see, I have over 500 Mb of cache storage. When you are almost out of space, this 500 Mb can make a lot of difference.
Either remove only the outdated packages, like those superseded by a recent update, making them completely unnecessary.
Or delete apt cache in its entirety (frees more disk space):
4. Clear systemd journal logs [Intermediate knowledge]
Every Linux distribution has a logging mechanism that help you investigate what’s going on your system. You’ll have kernel logging data, system log messages, standard output and errors for various services in Ubuntu.
The problem is that over the time, these logs take a considerable amount of disk space. You can check the log size with this command:
Now, there are ways to clean systemd journal logs. The easiest for you is to clear the logs that are older than a certain days.
Here’s an example:
5. Remove older versions of Snap applications [Intermediate knowledge]
You probably already know that Snap packages are bigger in size. On top of that, Snap stores at least two older versions of the application (in case, you want to go back to the older version). This eats up huge chunk of space. In my case, it was over 5 GB.
Alan Pope, part of Snapcraft team at Canonical, has created a small script that you can use and run to clean all the older versions of your snap apps.
What you have to do here is to create a new shell script and use the following lines in your script:
Give it execute permission, run the shell script with sudo and see the magic. The script removed the older Snap packages and freed over half of the 5 GB space used by Snap.
6. Clean the thumbnail cache [Intermediate knowledge]
Ubuntu automatically creates a thumbnail, for viewing in the file manager. It stores those thumbnails in a hidden directory in your user account at the location
Over time, the number of thumbnails would increase dramatically. Moreover, the thumbnail cache will eventually contain many superfluous thumbnails of pictures that don’t exist anymore.
You can check the size of thumbnail cache with the command below:
For my system, the thumbnail cache is over 300 Mb in size.
So it’s a good practice to clear the thumbnail cache every few months or so. The quickest way is to use the terminal (please copy paste the commands to avoid mistakes):
7. Find and remove duplicate files
Sometimes you may have duplicate files in different places in your system. Getting rid of the duplicates will certainly free up some space and clean your Ubuntu system.
You can use a GUI tool like FSlint or a command line tool like FDUPES for this task. I recommend reading this article to see how to use these tools to remove duplicate files.
4. Remove old Linux kernels that were manually installed [For Experts]
The command discussed in the point 1 removes old Linux kernel. But it won’t work if you manually installed the kernel in Ubuntu. But removing old, unused Linux kernels will still save you plenty of space.
So, if you manually installed a Linux kernel, perhaps you can manually uninstall it as well.
List all installed Linux kernels first:
Removing the old kernels is the same as removing any other package. I’m using shell expansion for the version numbers to save typing. It will prompt you with a list of packages that will be removed, so you can double check the list before continuing.
Note: Replace VERSION with the version of the kernel you want to remove.
My recommendation is to keep at least two or preferably three kernels including the latest. This way, you will have at least one/two other kernels to boot with, if for whatever reason the latest kernel you are unable to boot with.
5. Remove orphaned packages [For Experts]
This step is best avoided if you are a beginner. I am not a fan of this method and I advise you to avoid it.
First, let’s see what is an orphaned package in Ubuntu.
Suppose you installed a package ‘myprogram’. But this package has a dependency on the library ‘mylib’. This lib will be usually installed automatically with ‘myprogram’. When you delete ‘myprogram’, mylib might still remain in the system. Thus mylib, in this case, becomes an orphaned package.
Now, the command listed in point 1 removes such orphaned packages. But imagine the case where you had manually installed mylib before installing myprogram. The command ‘apt autoremove’ might not remove the orphaned package in this case. And hence you’ll have to manually delete it.
You’ll have to find all the orphaned packages first and then remove them. Thankfully, we have a GUI tool to do that: gtkorphan, a graphical frontend for deborphan.
Install gtkorphan via the terminal:
And to remove orphaned packages, search for Removed Orphaned Package tool and run it to find all the orphaned packages in your system:
Honestly, I won’t go for this option unless you really need every Mb of free space.
Bonus Tip: Using GUI tools to free space in Ubuntu
We saw a number of command line options to make space in Linux system but I understand if you don’t want to use the commands.
Remembering all the commands or using them all one by one may not be convenient for you. And this is why we have a number of GUI tools that will help you do that in a few clicks with an easy to use interface.
Stacer is one such tool that you could use. You can read this article to know how to use Stacer in Ubuntu.
You can check out more tools to clean up Ubuntu and make some free space easily.
Wrapping up
So, you saw a number of ways to clean up Ubuntu system. Personally, I use apt-get autoremove more often than any other commands here. Regularly using this command keeps the system free from unnecessary files.
I hope this article helped you to make free space in Ubuntu, Linux Mint and other such distributions. Do let me know if this worked for you or if you have some other tip to share.
Like what you read? Please share it with others.
Источник