How to lock screen and at the time of unlock should ask password? How to do it from command prompt?
I have tried:
But not asking password at the unlock time.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
No need of a command line: Ctrl+Alt+L will do that immediately for you.
That has nothing to do with the command. You have to go to your System Settings, and check that password is required to disable screensaver. In Gnome, open 'system settings' and click 'brighness and lock' and toggle the lock to ON.
I believe it depends on your display manager.
I have lightdm so it's
Lock the current seat. This will switch to a greeter with a hint that the screen is locked. You can return to this session by authenticating in the greeter.
EDIT: It looks and acts like a screen lock, but I have noticed that I can "skirt around it" by switching to a text terminal and back to the X terminal (on my machine Ctrl-Alt-F2 then Ctrl-Alt-F6 does that).
dm-lock would then just exit.
I'm not sure if I'm doing something wrong here. But I am leaving these here as a pointer, I think it would still be useful information for someone.
The gnome command that other mentioned did not work for me, by the way. I do not really use Gnome on my desktop.