User authentication and logging
One of the major parts of user authentication is to monitor the users of the system. There are various ways to keep a track of all the successful and failed login attempts made by a user in Linux.
Getting ready
Linux system maintains a log of all loginattempts by different accounts in the system. These logs are all located at /var/log/
:
![](https://static.packt-cdn.com/products/9781789138399/graphics/45d6f84d-a440-47ec-a9d2-fc30451656f8.png)
Â
How to do it...
Linux has many ways to help an administrator to view the logs, both through graphical and command-line methods:
- If we want to check the incorrect login attempts for a particular user, like root for instance, we can do so by using this command:
lastb root
Â
Â
Â
Â
- To see the log using the Terminal, we use the
dmesg
command. This command displays the buffer of the Linux kernel's message stored in memory, as shown here:
![](https://static.packt-cdn.com/products/9781789138399/graphics/8ff1bb6f-0154-4012-b57e-fddd6a3aa0c7.png)
- If we wish to filter the preceding output to show only the logs related to USB devices, we can do so by using
grep
:
![](https://static.packt-cdn.com/products/9781789138399/graphics/9f557fdd-1249-431f-9fce-cf8b2fe89ba8.png)
- Instead of viewing all the logs, if we wish to view only the 10 most recent logs in a particular...