In this video, you'll learn how to limit user access.
So this is about temporarily locking user accounts.
Use userMod-L to lock a user account, uppercase L that is, do remember, Linux is case-sensitive.
And userMod-U will unlock a user account.
User accounts can also be set to expire.
If you want to do that, use userMod-E for expire, followed by the expiration date.
Like 2032-0101 for user bill, which will expire account bill on the 1st of January of 2032.
If you create user accounts ever that are not intended to log in at all, you can use
a default shell, use userMod-S to set the default shell to slash sbin slash no login.
This is typically something that makes sense for application users, not for people users
that really need to log in to your system.
Let me demonstrate.
So let's get started with a till minus 5 on etc.shadow to see these different properties.
So we have userLorry, userLorry has a password.
I'm using userMod-L for lorry.
And now I'm using till minus 5 again.
Do you see the difference?
The difference is that userLorry at this moment is locked.
Her name starts with an exclamation mark.
And if the password failed, and if the password field starts with an exclamation mark or just
has an exclamation mark, then logging in is not allowed for the user.
We can easily undo that by using userMod-U on the user, which will remove the exclamation
mark again.
And hey, I can hear you thinking, what if I manually edit etc.shadow?
Yes, if you manually edit etc.shadow, you can do the exact same thing.
And you will also discover that the passwd command allows you to do something like this
as well.
So let's use userMod-E of 2025-0901 for userBia, which is doing what?
Well, that is expiring userBia on the 1st of September of 2025.
So till minus 1 on etc.shadow.
Or let's do minus something else so that we can easily compare.
Here we can see a new value that has been added for userBia.
In case you are thinking, what kind of weird value is this?
This is the number of days since January 1st, 1970, which is the start of time in Unix.
So here we can see that 20,235 days after January 1st, 1970, the user was created.
And the user will expire 20,331 days later.
Is there an easy way to get that out of the system?
Of course there is.
You'll learn that in one of the next videos.