Just had the message:

Low disk space.. 2 GB left

Judging by a posted message on ubuntu.org forums, I found that I have a .log file in /var/log at 22 GB in size! My root is an 82 GB partition and Disk Analyser shows the offender to be in log. The system root was installed circa 8 months ago, so clearly this is not a good thing in creating a 22 GB log on an 82 GB root partition.

Is it safe to delete the log file or please advise on the correct safe procedure to cleanse it without messing up my system. I presume it may be ok, but would like some other opinions before I do the task of delete.

  • 1
    An alternative is to compress it using gzip or bzip2 -- though this requires temporarily having enough space to hold both uncompressed and compressed copies of the file. Log files tend to have a lot of redundancy, so they should compress quite well (probably better than 90%). Aug 3, 2012 at 22:11

5 Answers 5


It is generally safe to delete log files. The only disadvantage associated with doing so is that you may not be able to examine the log, if you're troubleshooting some other problem later. Since new logs are automatically generated, even this disadvantage is short-lived.

Most logs are deleted automatically (after being rotated by compression and renaming, and kept a while in that archived format). If you have a log that's expanded faster than Ubuntu is deleting it, it's unlikely that you'll experience any problems from deleting it manually.

However, if you have a log file that's 22 gigs in size, something very strange is happening, and it would be worthwhile to investigate that. I recommend editing your question again to include a link to the Ubuntu Forums thread you're talking about, and also to include the full name of the 22 GB log file.

  • 2
    Thanks for the advice. I have now found out the offending log file is a "mail.log". Here is the link to the Ubuntu forum: [ubuntuforums.org/showthread.php?p=12148780#post12148780] Readers will notice in the screenshot 3 large log files, (sys, mail, mail.err). I hope this helps anyone with a similar issue with root space loss.
    – Paul B
    Aug 3, 2012 at 21:06
  • 1
    I now have 60Gb free space after deleting the offending .log files. Please refer to the ubuntu forum above. Thanks to Eliah for highlighting the issue and answering my post.
    – Paul B
    Aug 3, 2012 at 21:37

I'd like to add a word of caution here - maybe you can delete all your log files, but you might have problems if you delete the /var/log subdirectories. I deleted all my log files and their directories (rm -r /var/log/*) and it broke my apache2 functionality. Apparently apache doesn't/can't recreate the log directories and therefore can't write log files and that apparently can cause it to fail.

I've heard before that deleting some log files can cause problems, though I don't have any first-hand experience to support it. But of course I didn't have any first-hand experience of directory deletion being a problem until a few days ago...

  • 1
    Good point actually. Although unrelated to the question here, I have also had a scenario where I mistakenly deleted the log folder and the process was unable to recreate it because it required sudo permission which is not given to the process during run time (for security purposes).
    – Rafid
    Jan 13, 2018 at 20:20
  • @Rafid deletion has broken the sites hosted on the server. Now I am looking for a solution. Maybe, reinstalling apache will resolve. Jan 15 at 7:59

Further to my original post, I found it easier to use BleachBit (on Root) to clear out all the old logs on my Ubuntu 12.10 desktop; why they get so large I still don't know, but for now BleachBit 'clears all known bits, DEAD!' I reclaimed over 1.6Gig in space. if you find similar log, problems, then check out the BleachBit utility from the Ubuntu Software Resource or Synaptic Package Manager.


I know this is old, but so is the software I'm working with lately. I needed to install an old version of Android Studio and it was running strange when launched by a standard user. So I was experimenting with running it with GKSU root. Within a couple hours of playing around my entire hard disk was gone. WTF? Well the offending files were log files in /var/log. So I launched GKSU nautilus and went looking around. It had made 3x 30gb log files which I promptly deleted since I knew what and where they came from. So while I understand the risks of running things as root, maybe this will help somebody figure out a problem.


If you are using rsync or suffering low disk space, two nice tasty targets are taken care of by these two commands:

sudo rm /var/log/kern*
sudo rm /var/log/messages*

These can get to be huge, and will be recreated the first time the system wants to write to them.

When using rsync they will not only save disk space but also will speed up the backup.

  • 1
    This is really bad advise ... deleting the active logfile (like kern.log) will not release disk-space before syslog is restarted. Also it is always good practice to investigate what is filling up the logs (and fix the problems) before deleting them.
    – Soren A
    Jan 12, 2021 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .