Free up storage space in Linux
Tags: tutorial, linux, javascript, programming
Published: 2023-10-21 22:21:12

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi9iy8ezr450cv8tvttc.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lb3a0ev48t1tch03ixs.png)



![example-two](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rc9q4lxpx4b33536qt8.png)


![example-three](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nfaahvoxrtaxvaifdq7.png)




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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8vowum6bo48tjm67bsbd.png)



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](https://github.com/voidcosmos/npkill).

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
```

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
```

And so on with all packages!

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

```
yay -Qe
```

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

```bash
yay -Qe | awk '{print $1}' | xargs expac -H M "%n %m"
```

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!