Log Locations by Distribution
| Log | Ubuntu, Debian | AlmaLinux, Rocky |
|---|---|---|
| Logins, sudo, SSH | /var/ | /var/ |
| General system | /var/ | /var/ |
| Kernel | /var/ | In messages |
| Cron | In syslog | /var/ |
/var/ | /var/ | |
| Nginx | /var/ | /var/ |
| Apache | /var/ | /var/ |
| Packages | /var/, dpkg. | /var/ |
Web server folders hold access.log and error.log on Debian and Ubuntu, and access_ and error_ 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 rsyslogWithout 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.logMost 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.*.gzBinary Login Records
- Successful logins:
lastreads/var/log/wtmpon Ubuntu 24.04, Debian 12, AlmaLinux, and Rocky Linux. - Failed logins:
sudo lastbreads/var/log/btmpon 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/nginxAdd 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/nginxIf 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.
More Guides
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.

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