Score:0

How do I empty logfiles in Ubuntu?

lk flag

How do I empty logfiles in Ubuntu? I got message that root has less than 1 GB of space left.. I found out that logfile is huge, over 400 GB. (Does size of logfiles relate to root directory at all?) I'm using Focal Fossa.

I'm unsure to use commands from older posts since I'm afraid they've been changed and I might empty something else in progress.

FedKad avatar
cn flag
What is the "logfile" you mentioned? For routine maintenance see `man logrotate`.
Heta Rikala avatar
lk flag
I'm unsure what it exactly is, but most if(2,4 GB) it is under \var\log\lib\snapd\
Score:1
in flag

If you are uncomfortable with using the terminal then consider using a GUI package like Stacer downloadable from the ubuntu software center.

enter image description here

Running stacer and using the cleaning tool you can see graphically your Application Logs and choose what to clear down by clicking on the check mark against each.

enter image description here

Heta Rikala avatar
lk flag
I tried Stacer and it showed kernel logs, ufw.log.1 and two syslogs as huge files. Are they safe to empty?
24601 avatar
in flag
if they weren't safe to remove, Stacer wouldn't list them. I use Stacer often without drilling down on 20.04 (and 18.04 before that) and have never experienced a problem. If you remove a log, you won't have the reference later if you needed it, that's all.
heynnema avatar
ru flag
@HetaRikala before deleting ANY log files, view them to determine why they are so large. Typically there's an error that repeats itself and fills the logs. This error needs to get fixed before manipulating any log files, as the problem will just return later.
24601 avatar
in flag
@heynnema that said, (and I don't disagree) a shorter log file might just be easier to assimilate.
heynnema avatar
ru flag
@24601 No forensic detective would ever consider getting rid of valuable data before looking at it first :-)
24601 avatar
in flag
.. and they would first make a copy so as to preserve and protect but most end users eyes would just glaze over with the sheer weight of detail.
Heta Rikala avatar
lk flag
Well, here is the partial detail of one logfile(ufw.log) that has been slowly but surely hogging space all day.. (Can't paste whole log to pastebin since my computer temporarily freezes up when I try to do so.) https://pastebin.com/rByDUqq3
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.