2

This question already has an answer here:

I have already gone through the post in Unix & Linux and tried altering /etc/passwd manually like below

user1:x:1001:1001:,,,:/home/user1:/usr/sbin/nologin

after making change user1 is not being able to login from terminal but surprisingly can login from gnome

What's wrong?

Description:    Ubuntu 14.04.3 LTS
kernel:         3.19.0-33-generic

marked as duplicate by Sergiy Kolodyazhnyy, Parto, Community Jan 21 '16 at 7:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Technically your question is a duplicate, there have been questions asking same thing before. I do recall posting answer to exactly similar question. You could refer to this. Yes, it says lock/disable account, but essentially it's the same thing. User will be there, just unable to log in. I'll be searching for the question I mentioned earlier, however – Sergiy Kolodyazhnyy Jan 21 '16 at 5:56
2
passwd -l

that might be what you're looking for :)

from the passwd man page:

-l, --lock Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it adds a ´!´ at the beginning of the password).

Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970).

Users with a locked password are not allowed to change their password.

  • What does that do exactly? Can you add a small description of what this will actually accomplish. – Parto Jan 21 '16 at 6:29
  • Thanks CZ0 but I was aware of this solution as I gone through the post in Unix & Linux channel. I was more keen to know that how come after changing the shell to /sbin/nologin user is being able to login. chown -R root:root /home/user1/.Xauthority answered that. – Neel Jan 21 '16 at 7:13
  • 1
    That's simply because when you log in via the GUI, you're not spawning a shell. – Léo Lam Jan 21 '16 at 17:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.