DEV Community

Robertopaolo Ramirez
Robertopaolo Ramirez

Posted on

Free up storage space in Linux

This month of October I had the experience of almost completely populating my 500GB SSD.

As the money still wasn't falling, I thought I'd start removing things that might be unnecessary on my computer.

Currently, my SSD is dual-booted and is:

  • 300GB for Linux (Manjaro)
  • 200GB for Windows (win11)

Tools

  • Disk Usage Analyzer
  • npkill
  • pactree
  • yay

Disk Usage Analyzer is an app from the Linux world to visualize the distribution of your disk with better aesthetics, where you can see the paths, sizes, and more. I used it for these things.

Disk usage analyzer

In my work as a Software Engineer, I use a lot of javascript and as a result, I have spread many node_modules folders around.

You've probably seen some of his memes haha, here are some!

example-one

example-two

example-three

Guys don't waste time making memes! đŸ˜„

Well, with those in mind, I thought I'd start removing it to get a good space. However, obviously, I wouldn't go from folder to folder to remove them, there are too many and I'm very lazy about that, so I found a script that can help with this and that helped me a lot, it's called npkill. Basically, it lists all the node_modules you have according to the folder you are in, that is, if you are in the root of your computer, (~), it will list them all, and so on.

npkill-example

It's very intuitive, so it was easy to apply, after a few minutes of reading, I saw that there really was a lot to remove, so I went with it.

It certainly saved me a lot of time, see the documentation here.

One interesting thing that I didn't mention was that in addition to viewing it through Disk Manager, I saw that a large part of the space was being consumed by installations that I made using yay.

So, to free up more space I also needed to clean up the apps and libs that I don't use, I currently only use pacman and yay as package managers, certainly in my opinion, they are the best!

a clear example of things that I installed and then forgot to remove and that was taking up a lot of space was the electro20 so I wanted to remove it, but first You need to ensure that removing it would not break any app, as it could possibly be dependent on something. With this point in mind, I used pactree which helps us in this regard and is simple to use, we just need to type:

pactree -r nome_do_pacote
Enter fullscreen mode Exit fullscreen mode

If the mentioned package has any connection with another app, it will list it for you.

And since there wasn't, I removed every unnecessary dependency with the following command:

yay -Rsn nome_do_pacote
Enter fullscreen mode Exit fullscreen mode

And so on with all packages!

One last tip is how to list the packages installed by yay:

yay -Qe
Enter fullscreen mode Exit fullscreen mode

Now, if you want to list the name and size, type:

yay -Qe | awk '{print $1}' | xargs expac -H M "%n %m"
Enter fullscreen mode Exit fullscreen mode

So guys, this is how I managed to free up more space on my computer, I hope it helps you in some way, if you have more tools, tell me in the comments how you do it and what tools you know. Strong hug!

Top comments (3)

Collapse
 
stacy-roll profile image
Stacy Roll

Rust is better & lightweight. I mean, JS is good for web development, but if you look for systems development, ha, dont think twice. Enjoy the article!

Collapse
 
guima profile image
Thiago GuimarĂ£es

Very good! Did you have to kindle with your local cache ? Ive currently been having this kind of problem in my setup as well and handling cache folders in linux has become kind of a routine to me rn

Collapse
 
ramirezmz profile image
Robertopaolo Ramirez

I removed the things that were in the /tmp folder, but the ideal is to remove it file by file to know what you are removing!