Why has this happened?

The biggest clue, and possibly the biggest culprit, will be found in your Linux system logs.

Why Are Logs Taking Up So Much Disk Space?

A close-up of a hand writing with a pencil in front of another hand typing on a laptop

jd8 /Shutterstock

Logs are an important part of managing your Linux system.

Linux logging daemons are similar toEvent Viewer on Windows.

The logs normally dont take up much space.

du -h command output from the /var/log directory in Linux

This is because most distros will automatically manage how much space they take up on your disk.

Alternatively, your distro will either use rsyslog or syslog-ng.

Youre going to have to find out whats filling up your system logs and fix it.

journalctl logs on Linux

To view the logs, punch in thejournaldcommand at the shell prompt.

There are other useful command line options.

If your distro doesnt use systemd, youll find the logs in the/var/logdirectory.

journalctl -f command output on Linux

Even with systemd, some programs still store their logs in this directory.

This is the result of the system rotating older logs.

Most distros have a utility that will do this automatically, called logrotate.

logrotate systemd service file

logrotate is typically set up to run as acron jobor a systemd timer.

By default, most distros will run logrotate daily.

logrotate compresses older logs using gzip, as evidenced by the .gz file extensions.

/var/log directory in Linux

The default options for logrotate are sufficient for most desktop users.

Youre better off fixing whats filling up your logs than tweaking configuration files to save disk space.

If you absolutely must change the configuration, you’re free to read thelogrotate manual page.

Which Logs Are Safe to Delete?

and ending with gz.

Always be very careful when running commands via sudo, especially destructive commands like rm!

If you do have a problem, you might need to refer to older logs, though.

Your best bet is repeating error messages.

Youll have to deal with the offending process to save disk space.

When youve finally fixed it, it’s possible for you to delete the older logs safely.

You should have much more disk space now.