Let's say I create a user named "larry" using the
There are two methods to prevent a user from being able to login:
Change the below line with the
to this.
To lock user:
To unlock user:
adduser
command. How can I make sure this user will not be able to login
into the system directly, without disabling the account. In short, I want the account to
be accessible via su - larry
, but I do not want it to be accessible via a regular login prompt.There are two methods to prevent a user from being able to login:
- you can lock the user by editing
/etc/passwd
- by directly issuing the
passwd
command with the-l
switch
- open a terminal and login as root
- type
vi /etc/passwd
passwd
file press i to edit the file.Change the below line with the
nologin
option (/bin/bash
means the user is able to login).root:x:0:0:root:/root:/bin/bash
to this.
nologin
means the user is unable to login.
root:x:0:0:root:/root:/bin/nologin
Method #2To lock user:
passwd -l username
To unlock user:
passwd -u username
No comments: