Task to Clean DEbian Server Command line

Hi, guys, there is any shell script that i can use to clean my Debian based server.

What do you need to clean up?

1 Like

for sample to clean old repos, and free size in sda1

You could try rm -rf /, don’t actually do that LOL.

I’m guessing you’re looking or something like the Disk Clean button in Windows? I’ve never seen a script like that. From my experience there isn’t much excess stuff in Linux. So each install is going to be different with regard to what you can get rid of. You could build a script that works for your instance. This looks like a good place to start in understanding how to find things to get rid of.

sudo apt-get clean
Or
sudo apt-get autoclean

Will erase downloaded packages or old downloaded from updates.

You can check /tmp for temporary files
Also inside /var/logs you can erase old logs.

To find where the files are use one of theses:
If your debian has a desktop GUI use: QDirStat
If you want to use from a shell, use: ncdu

1 Like