House Keeping in Linux

House Cleaning. Is there any monthly or routine jobs that need /should be run. I’m thinking about log files, temp files, update files, printer files, or de-frag that may need to be run to keep the your system running smooth and/or not expanding too much?

2 Likes

are you asking about for debian specifically or linux in general?

Actually, I was thinking of Linux in general since it’s base on ubuntu. I am using Linux Mint.

2 Likes

Firstly, you should NEVER defrag Linux it isn’t needed as it doesn’t work like windows does. As you use Mint there are steps you can take and are safe to do so.

  1. sudo apt-get auto clean, in the terminal. This cleans old packages etc left behind after updates.
  2. Via Update Manager -view Linux kernel and then when the box comes up with any not in use now, you can safely remove them.

As with all things, however, do a timeshift before you do anything so if in the highly likely event things go wrong you can always undo them.

As for a schedule, that really is up to you. I tend to do mine once a month, depending upon use or how many updates have been done during the month.

4 Likes

Try uCareSystem - does the lot with one command - brilliant !

2 Likes

I have just seen this. Just a personal view, but I would rather still do it myself and know that I have done it rather rely on a third party. Not saying it is bad or anything and I can see why some would want to use it, just a personal preference.

1 Like

I use stacer and ubuntu-cleaner. they both do good job, but you need to know what your doing or you can break your system. stacer can be found here: And ubuntu-cleaner here.
Note: I’m not sure what distro your using stacer can be used on most Ubuntu-cleaner is ubuntu/mint centric.

1 Like

I use “sudo ucaresystem-core” on the first of every month. It does a great job. In between, I sometimes use Stacer(https://github.com/oguzhaninan/Stacer/releases/download/v1.1.0/stacer_1.1.0_amd64.deb). Between the two of them, my machines stay clean.

1 Like

Absolutely disagree here. True, it’s not the same as in Windows. But if you frequently move around files that are big enough, a defrag may be needed.
Look for e4defrag.

I use it on my video partitions (huge files come and go frequently).

1 Like

I shall disagree with you here and I will stick to the statement I made and make reference to this which amongst other articles says you don’t do it: https://ubuntuforums.org/showthread.php?t=1890008 or this one https://www.howtogeek.com/115229/htg-explains-why-linux-doesnt-need-defragmenting/ which explains how Linux works. This one https://forums.linuxmint.com/viewtopic.php?t=199008

I also reference this from Ptjor https://easylinuxtipsproject.blogspot.com/p/fatal-mistakes.html#ID4 and the pdf he mentions on this. He has a great deal more experience than I have and most of us have and is trusted for that advice.

You are welcome to your view and to do what you wish on your system. True I have seen article about defraggers for linux and have read through them. Based on that the counter ones I still say NEVER. Even more so if you have an SSD.

It is good that another has another opinion so the community can see both sides and I thank you for making it.

1 Like

Thanks.

I agree with you regarding an SSD. :slight_smile:
However, I still think e4defrag exists for a reason.
I have only one link to post here:


On page 186.

“Performance measurement has shown that defragmentation for a single file can improve read performance by 25% on a fragmented 1GB file.”
Hmmm… May be it’s may very bad english, maybe I did not read carefully enough, but that encourages me to keep my video partitions defragged…

It appears that you are BOTH right! That quote describes single huge files (like a video) that are fragmented. The received wisdom is that the OS does not need it as a regular maintenance activity.

3 Likes

This is the pdf: https://drive.google.com/file/d/1rIOv22_Yegl8vVc82dtxfsFGE1aW2Ogw/view it was done in 2006, but it might be worth your looking at to see what you think. It was one of many things I looked at. The article you mention and I have read does give a reasoned argument for some fragmentation, however both of these were written between 12 and 13 years ago so things have changed in that time.

As @cliffsloane says we are both correct, for different reasons. The reason why I stated as I did is because this thread is about house keeping and that is the point I was making here. Yet you have pointed out something I did not know, so thank you again for that. Perhaps the conclusion should be use only with caution and not regularly :grinning:

1 Like

I come back with some additional detailI, for which I did not care before.
We can use e4defrag -c to check wether it is required to defrag.
To me it seems, e4defrag calculates a fragmentation score and acts based on that.
For example, I take the currently most fragmented file:

laco@Nagygep:/home/laco/.thunderbird# e4defrag -c /home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB
e4defrag 1.44.1 (24-Mar-2018)
now/best size/ext
/home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB
8/1 128000 KB

Total/best extents 8/1
Average size per extent 128000 KB
Fragmentation score 0
[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
This file (/home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB) does not need defragmentation.
Done.

So it tells me it’s stored in 8 extents, but it doesn’t need to be defragged.
However, If I still run defrag for it:

laco@Nagygep:/home/laco/.thunderbird# e4defrag -v /home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB
e4defrag 1.44.1 (24-Mar-2018)
ext4 defragmentation for /home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB
[1/1]/home/home-ext/laco/Videók/tavaszk-2017/DVD/VIDEO_TS/VTS_01_2.VOB: 100% extents: 8 -> 8 [ OK ]
Success: [1/1]

And that happened in practically zero time, so I’m confident, that ~130MB was not moved.
If I understand it correctly, e4defrag won’t do any work, if the performance penalty for fragmentation is negligible. I can not show now, but I used to see messages like “extents 228 --> 31” for ~30 GB files, or such. At the moment I believe, if e4defrag DOES something, then it’s really necessary. If a defrag isn’t needed, it just doesn’t do anything. As a test, feeling a bit llike a hero, against all recommendations I made run e4defrag on my whole /home folder, which is stored on SSD, and holds around ~12GB data. It swept thrugh thousands of files in approx. 11 seconds. Characters ran so fast, I couldn’t even catch a line. And that included my inbox folder in Thunderbird, which is couple GB’s in size. Obviously, e4defrag just checked each file if it needs defrag, and went on to the next one…
Just the very last few lines of the output:

[141458/141466]/home/laco/.ccnet/logs/applet.log: 100% extents: 1 -> 1 [ OK ]
[141459/141466]/home/laco/.ccnet/logs/seafile.log: 100% extents: 1 -> 1 [ OK ]
[141460/141466]/home/laco/.ccnet/seafile.ini: 100% extents: 1 -> 1 [ OK ]
[141461/141466] “/home/laco/.sane”
File is not regular file [ NG ]
[141462/141466] “/home/laco/.sane/xsane”
File is not regular file [ NG ]
[141463/141466]/home/laco/.sane/xsane/CANON:CanonPIXMAMG5300.drc: 100% extents: 1 -> 1 [ OK ]
[141464/141466]/home/laco/.sane/xsane/xsane.rc: 100% extents: 1 -> 1 [ OK ]
[141465/141466] “/home/laco/.sane/xsane/batch-lists”
File is not regular file [ NG ]
[141466/141466]/home/laco/.sane/xsane/xsane.mdf: 100% extents: 1 -> 1 [ OK ]

Success: [ 134475/141466 ]
Failure: [ 6991/141466 ]
Total extents: 135220->134563
Fragmented percentage: 0%->0%

So I think, and here I have to agree with Electricdandyslider, that an average user with average sized drives, having average sized files on it, really does not have to worry about needing defrag.
But it won’t do any harm if one runs e4defrag, it simply won’t do anything if unnecessary.
It needs an extreme extraordianry usage, like what I do with my video partitions, which can make a defrag necessary.
My caution is as always: I may be completely wrong. :slight_smile:
And my lesson again: never say never :smiley:

2 Likes

in regards to temp files, i just found out about the systemd-tempfiles-clean service that runs every couple of days on my system. i was looking into whether or not fstrim runs automatically since i just started using an ssd. i found an ask ubuntu answer that said you could check if fstrim was running by using the systemctl list-timers command. when i ran that, it listed the temp file cleaner mentioned above :slight_smile: in case anyone else is interested in a bit more info about their fstrim settings, the post also says you can run systemctl status fstrim.timer to see that.

4 Likes

Thanks so much for sharing cordx !!! I never knew about timers or about systemd-tmpfiles as it is callled on opensuse leap 15.1

1 Like

Thanks cordx for that info great to see my trim is working. Those are good commands to know :slight_smile:

1 Like

Returning to the original question it’s no bad thing to sit down on a rainy day and put the house in order. How you spring clean your own Home folder will be a personal matter. Back it up (before and) afterwards.

Then: <sudo apt update && sudo apt upgrade -y>

… and then run Bleachbit

Done

2 Likes

Try search by some “CCleaner” for Linux, it could to be nice ! :smile: