2

Is there a way I can purge (empty) the ufw log file (located in /var/log/ufw.log?

I tried rm but it didn't work.

I tried to stop ufw and delete the file but I couldn't do it.

Everybody talks about log level but nobody explains how to empty this file...

0

2 Answers 2

2

As @muclux correctly points out, system files are usually removable only with administrator privileges; e.g. sudo. This command will remove the file:

sudo rm /var/log/ufw.log

Verify:

ls /var/log
1
  • 2
    After removing that file, the logging stops to work until I restart Rsyslog with sudo service rsyslog restart. To avoid that you could empty the file without removing it by doing cat /dev/null | sudo tee /var/log/ufw.log.
    – Jean Paul
    Nov 9, 2020 at 18:10
0

Using administrator privileges on the tee command as Jean Paul's comment pointed out will write over the file such that it becomes empty

cat /dev/null | sudo tee /var/log/ufw.log

sudo echo >/var/log/ufw.log does not work, as the sudo only applies to the echo and not to the output redirection >

You must log in to answer this question.

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