How to view the server access logs in Linux?
To view the access logs of a Linux server, you can utilize the following methods:
- Check login logs: Login logs keep track of users logging into the server. These logs are usually located in the file /var/log/auth.log. You can view login logs using the following commands:
- Display the contents of the /var/log/auth.log file using elevated privileges.
- Alternatively, you can use the grep command to filter specific keywords.
- Search for occurrences of the word “Accepted” in the /var/log/auth.log file using sudo privileges.
- The keyword “Accepted” indicates a successful login.
- Viewing access logs: Access logs record network requests and visits on the server. Different server software has different access log file paths and formats. Common web server software such as Apache and Nginx have access logs. For example, Apache’s access log is located in the file /var/log/apache2/access.log. You can use the following command to view it:
- Please open the access log file for Apache as the superuser.
- Alternatively, you can use the grep command to filter specific keywords.
- Utilize audit log tools: Linux systems offer audit log tools to record system activities and events. Audit logs can document detailed information such as user logins, file access, and process executions. Common audit log tools include auditd and ausearch. You can view audit logs using the following command:
- Use the command “sudo ausearch” to search for events related to the specified file path.
- Replace “/path/to/file” with the path to the file you want to view.
The methods for viewing access records on a Linux server mentioned above are common, but the specific methods and commands may vary depending on the server configuration and the Linux distribution being used.