02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School

Powerful Linux ways to control users

Not every user on linux is equal and many times you would want to create a user but not only limit there access but maybe freeze there account or define for how long will there account be active. That's the main topic of this lesson.

To lock a user we would call this command:

usermod -L demo

and to unlock the user:

usermod -U demo

Notice that we are not deleting the account of the user but not letting the user in when we lock them out. We talked about deleting users a few lessons ago. Another powerful feature is setting an expiration date to a user:

usermod -e 2015-01-01 demo

now we updated the user demo to expire on january first 2015. We can extend that user at any point but once that date would reach the user account would be locked.

Video Transcript

00:00At this stage, you know almost everything you need to know about users.
00:03You know how to add users, remove users, you know how to change their password.
00:07Now, just a few more kind of like follow-up or things that might become really useful
00:12as you're starting to work with the team.
00:14So what if you want to just disable a user for just a little bit of time,
00:18but not disable them forever?
00:20To disable a user for just a short amount of time,
00:23what you want to do is you want to use your user mode.
00:26Again, let me just type it user mode,
00:29mod, sorry, not mode, mod, user mod.
00:32And I'm going to type your minus and uppercase L for lock.
00:37And then I'm going to type the user.
00:38So right now we're locking that user.
00:40The user has no more access to this account.
00:44The account is not deleted.
00:45I could reactivate it whenever I want to.
00:48So for example, I would use this if I'm working with a contractor
00:51and they didn't deliver their work and there's some issues
00:55or there is some issue that is of concern,
00:58but I don't want to delete their account.
01:00Another, once I'm done and we're happy,
01:03all I have to do is again, user mode.
01:05And this time I want to unlock it.
01:07So I'm going to put your uppercase U for unlock and type the user.
01:11And now we unlock that user.
01:13Now, last but not least, what if you want to,
01:17you have a contractor that's working for you
01:19and you know they're only going to work for a week
01:22and you don't want to worry about going into the account
01:25and deleting your account and unlocking and forgetting.
01:28And I don't know what.
01:29So how about setting his access level and saying,
01:31Hey, when this date arrives, lock his account, expire his account.
01:37So there's no way to access his account anymore
01:39because it has expired.
01:41Now you probably would never do it on one of your own accounts,
01:44but this is definitely something to consider
01:46when you're getting a developer to basically expire it after a month.
01:49And if he's still working for you, then expiring it again
01:51until you build a trust by user and you feel like you don't have to do it.
01:55But in general, it's not a bad idea to set limits on the accounts
01:59because it gives you a little bit more control.
02:01So the way I'm going to do that is again, I'm going to use that user mod.
02:05But this time around, I'm going to use the E lowercase E for expiry.
02:09And then you're going to type here a full qualified year month date,
02:13which means let's say right now we're in 2014.
02:16So I'm going to type your 214.
02:18I'm in June.
02:18So how about I'm going to set it to expire in August?
02:22I have to put here two letters, even though it's only August.
02:25So it's zero eight.
02:26And now zero one, the first of August, this account will expire.
02:30And if I click your enter, now this, oh, we didn't put a user.
02:33So I have to put here a space and put the user name as well.
02:38So the user is demo.
02:42And there we go.
02:43Now we created a user that expires on a certain day,
02:46but we can always extend that expiration date.
02:48But once that expiration date reaches,
02:50if we did an update to update it,
02:52the user will have no access to his account anymore.
02:55All right.
02:56And that's everything you need to know about this.
02:59So for example, if you're going to create some sort of a hosting plan,
03:02or some sort of, I don't know what,
03:03but you don't want to delete the user's files because that would just be mean.
03:07But if the user is paying you on a monthly basis,
03:09you could then set the configuration to basically expire if his payments don't come in.
03:13So once a month you extend his, you extend his permissions
03:17and at some point he loses his permissions.
03:21All right.
03:22That's about it.
03:23So thank you very much.
03:25That's everything we want to talk about users.
03:26And we're done with this topic.
03:27And it's time for us to move on and continue setting up and building up our server.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!