Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Getting back that precious disk space
eLabFTW
eLabFTW

Posted on

     

Getting back that precious disk space

Hello devs,

I you're like me and you like to try things out, work on several projects in several languages, chances are that you've been cluttering your computer with gigabytes of files that are not worth keeping.

I'm talking about all the cached packages from package managers, old docker images, and containers you started without the--rm flag.

This post is an attempt at regrouping the commands to clear that space. It's written for GNU+Linux users and will probably work for Mac. Some of the commands will also work on Windows (but then if you're doing dev on Windows I'm deeply sorry for you).

If you want to go along and execute the commands, start by checking your disk usage withdf -h first so you know how much space you'll get back :)

WARNING: we're going to delete files here! It shouldn't cause any issue because it's only cached files that you can easily get back, but be careful about following a random blog post on the internets telling you to run a bunch ofrm -rf commands ;) I shall not be held responsible for any damage caused by executing the commands described below.

I'm starting this article with 94 Gb free on/.

npm (javascript)

npm cache clean --force
yarn cache clean
rm -r ~/.cache/typescript/*

composer (php)

composer clear-cache

cargo (rust)

There is no baked in command for that. SeeGitHub issue.

rm -rf ~/.cargo/git ~/.cargo/registry

We don't delete the whole~/.cargo folder as it might contain useful binaries inbin/.

docker

docker system prune -a

I like this command because it tells you how much disk space you got back after running it, and it really removes everything not currently in use. If you've been using docker for while and never used it, you might get as much as 40 Gb or more back! (yes images take up space!)

pip/pipenv (python)

rm -r ~/.cache/pip{,env}
rm -r ~/.local/share/{virtualenvs,jupyter}

go

go clean -cache -modcache -i -r

The -i flag causes clean to remove the corresponding installed archive or binary (what 'go install' would create). The -r flag causes clean to be applied recursively to all the dependencies of the packages named by the import paths.

css

Nope, just kidding.

some non-dev stuff

While we're at it...

rm -r ~/.cache/{mozilla,chromium,thumbnails}

You might want to have a look into this folder, as it's quite possible that a game you played 20 minutes in 2011 is taking up 3 Gb...du -sh ~/.cache/*.

Let's not forget the package managers!

Archlinux commands (BTW, I use Arch!):

sudo pacman -Sc (add anotherc to really remove everything)
yay -Sc

For Debian/Ubuntu/Mint users:

sudo apt-get clean
sudo apt-get autoclean

For Fedora/CentOS users:

dnf clean all

Conclusion

Please let me know in the comments how much disk space you got back! I had 94 Gb free at the beginning, now it's showing 128 Gb! That's 34 Gb back from the dead!! :)

Header image "GrandPerspective disk map" by Lars Plougmann is licensed under CC BY-SA 2.0

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
fluffynuts profile image
Davyd McColl
Code monkey extraordinaire
  • Location
    Durban
  • Work
    Full stack dev at Codeo
  • Joined

Also, using a tool like QDirStat (or the windows port WinDirStat) can help to pinpoint where that space is going (:

CollapseExpand
 
elabftw profile image
eLabFTW
Dev of eLabFTW, a free and open source laboratory notebook.
  • Joined

I'm partial to baobab myself. Installed by default on some distribs (fedora).

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Dev of eLabFTW, a free and open source laboratory notebook.
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp