How to view user login logs in CentOS?

To view CentOS user login logs, you can follow these steps:

  1. Login to the CentOS system using the root user.
  2. Open the terminal or console and input the following command to view the path of the user login log file:
  3. Display the contents of the file located at /var/log/secure.
  4. This will display the contents of the secure file, which includes information about user logins and authentication. You can use the pagination command to browse through longer log contents, for example:
  5. View the contents of the secure log file using the less command.
  6. You can also use the grep command to filter the login logs for keywords or specific users. For example, to view the login records of a specific user, you can use the following command:
  7. Search for the string “username” in the file /var/log/secure.
  8. Replace “username” with the actual username you want to search for.

Please note that the above steps are applicable to CentOS 7 and higher versions. For older versions of CentOS, the path to the login logs file may be different.

bannerAds