Skip to content
Log In Sign Up info@muvcloud.com

Log Locations by Distribution

LogUbuntu, DebianAlmaLinux, Rocky
Logins, sudo, SSH/var/log/auth.log/var/log/secure
General system/var/log/syslog/var/log/messages
Kernel/var/log/kern.logIn messages
CronIn syslog/var/log/cron
Mail/var/log/mail.log/var/log/maillog
Nginx/var/log/nginx//var/log/nginx/
Apache/var/log/apache2//var/log/httpd/
Packages/var/log/apt/, dpkg.log/var/log/dnf.log

Web server folders hold access.log and error.log on Debian and Ubuntu, and access_log and error_log for Apache on AlmaLinux and Rocky Linux. A site can set its own log paths in its configuration, so check there when the default file is empty.

Systems with Only the Journal

The text files syslog, messages, auth.log, and secure are written by rsyslog. Since Debian 12, Debian no longer installs rsyslog by default, and some minimal and cloud images of other distributions leave it out too. Those systems keep logs only in the systemd journal, and the files do not exist. Check:

ls /var/log
systemctl status rsyslog

Without rsyslog, read the same messages with journalctl: journalctl -u ssh (sshd on AlmaLinux and Rocky Linux) for logins, journalctl -k for the kernel. The journalctl guide covers the filters. If you prefer text files, install the rsyslog package.

Read a Log File

sudo tail -n 100 /var/log/auth.log
sudo tail -f /var/log/nginx/error.log
sudo less +G /var/log/syslog
sudo grep -i "failed password" /var/log/auth.log

Most files in /var/log need sudo. tail -f follows new lines; see the tail command. In less, G jumps to the end and / searches. To count or group lines, awk works well on access logs.

Older, Rotated Logs

Old logs are kept next to the current one as auth.log.1, auth.log.2.gz, and so on. Read compressed ones without unpacking them:

sudo zcat /var/log/auth.log.2.gz | less
sudo zgrep -i "error" /var/log/nginx/error.log.*.gz

Binary Login Records

  • Successful logins: last reads /var/log/wtmp on Ubuntu 24.04, Debian 12, AlmaLinux, and Rocky Linux.
  • Failed logins: sudo lastb reads /var/log/btmp on the same systems.
  • Last login per user: lastlog, where installed.

These files are not text; open them only with these commands. On Debian 13 and Ubuntu 26.04, util-linux no longer provides last or lastb; last comes with the wtmpdb package instead. On Debian 13, install wtmpdb and libpam-wtmpdb and run wtmpdb last; lastlog2 replaces lastlog, and sudo lslogins --failed gives similar information to lastb.

How logrotate Keeps Logs in Check

logrotate renames, compresses, and deletes old logs on a schedule. Its main file is /etc/logrotate.conf, and packages add their own rules in /etc/logrotate.d/. Each rule sets how often to rotate, how many old copies to keep, and what to tell the service afterward so it writes to the new file. To test a rule without changing anything:

sudo logrotate -d /etc/logrotate.d/nginx

Add a rule for your own application's logs in the same folder, or they grow until the disk is full.

Never Delete a Log by Hand

Deleting a log file that a service still has open does not free the space: the service keeps writing to the deleted file until it is restarted, and the history is gone. When a log is too large, rotate it through logrotate; the rule's postrotate step, or its copytruncate option, makes sure the service writes to a fresh file:

sudo logrotate -f /etc/logrotate.d/nginx

If disk space did not come back after a deletion, sudo lsof +L1 shows deleted files still held open; see the lsof command and how to check disk space.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations