Disable and Enable a user account in Linux :
Prevent user to access account / Prevent user to reach on shell prompt :
If you want to disable a user account in Linux, follow these steps.
if it is debian or ubuntu :
When you try to access disabled account, it says
Second Method :
a) Open file /etc/passwd and search your username there.
b) If a line ends with /bin/bash, it means user can log in.
c) Change the text /bin/bash into /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu) for your username.
d) Save the file. Now User will not be able to log-in.
Second Method :
a) Open file /etc/passwd and search your username there.
b) If a line ends with /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu), it means user can not log in.
c) Change the text /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu) into /bin/bash for your username.
d) Save the file. Now User will be able to log-in.
If you want to disable a user account in Linux, follow these steps.
if it is debian or ubuntu :
$ sudo usermod -s /usr/sbin/nologin username
if it is centos or fedora :$ sudo usermod -s /sbin/nologin username
When you try to access disabled account, it says
This account is currently not available
Second Method :
a) Open file /etc/passwd and search your username there.
b) If a line ends with /bin/bash, it means user can log in.
c) Change the text /bin/bash into /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu) for your username.
d) Save the file. Now User will not be able to log-in.
Enable a User Account
Allow user to access account / Allow user to reach on shell prompt :
If you want to enable a user account in Linux, Run the command.
Allow user to access account / Allow user to reach on shell prompt :
If you want to enable a user account in Linux, Run the command.
$ sudo chsh -s /bin/bash username
Second Method :
a) Open file /etc/passwd and search your username there.
b) If a line ends with /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu), it means user can not log in.
c) Change the text /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu) into /bin/bash for your username.
d) Save the file. Now User will be able to log-in.
You can see the solution in the following video.
No comments:
Post a Comment