Find largest files (Linux)
1️⃣ Find files larger than a specific size
Example: files larger than 500 MB:
/— search from root (you can replace with/var,/home, etc.)2>/dev/null— hides permission errors
Use -exec ls -lh
ls -lhshows sizes in human-readable format (K, M, G).Output example:
-rw-r--r-- 1 root root 1.2G Jan 17 /var/log/mariadb/mariadb.log
-rw-r--r-- 1 www-data www-data 700M Jan 17 /var/log/drupal.log
Limit /var/log/messages
/var/log/messages is managed by rsyslog (or syslog/journald). To limit it:
You can create/modify a file, e.g., /etc/logrotate.d/messages:
Explanation:
daily→ check every dayrotate 7→ keep 7 old logscompress→ gzip old logssize 500M→ rotate immediately if file > 500 MB
Then test rotation:
b) Optional journald approach
If your system uses systemd-journald (many modern CentOS/RHEL/Fedora):
Then restart journald:
This limits all journal logs including /var/log/messages if ForwardToSyslog=yes.
2️⃣ Limit /var/lib/mysql/mysql-slow.log
This is MariaDB’s slow query log. There are two ways:
a) Using logrotate
Create /etc/logrotate.d/mariadb-slow:
size 500M→ rotates if bigger than 500MBpostrotate ... USR1→ tells MariaDB to reopen slow lo
b) Limit slow log directly in MariaDB
In /etc/my.cnf:
You cannot directly limit the size inside MariaDB, but with logrotate + USR1 signal you can safely manage it.
✅ Summary recommendation:
/var/log/messages→ logrotate or journald limit/var/lib/mysql/mysql-slow.log→ logrotate + USR1 signalOptional: set
dailyrotation instead ofsizeif you prefer predictable schedule