As a developer and Linux server owner, security-wise it is very useful to know last and lastb, you can use the information outputted by these commands to take proper security measures to protect your system.
1. Use the last command to check successfully user logins on your system:
last
The output will look something like this:

2. Use the lastb command to check failed user login attempts on your system:
lastb

Now, you can see the malicious login attempts and the IP address where the login was attempted from. This log output also contains failed SSH login attempts. You can install fail2ban for intrusion prevention, it automatically bans and unbans IP addresses.