How to lock screen and at the time of unlock should ask password? How to do it from command prompt?
I have tried:
gnome-screensaver-command -l
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 communityHow to lock screen and at the time of unlock should ask password? How to do it from command prompt?
I have tried:
gnome-screensaver-command -l
But not asking password at the unlock time.
No need of a command line: Ctrl+Alt+L will do that immediately for you.
Edit:
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.
gnome-screensaver-command -l
gnome-screensaver-command -a
refer here https://askubuntu.com/questions/184728/how-do-i-lock-the-screen-from-a-terminal
It depends on your environment, but in any case physlock
(look it up) will lock your screen in whichever environment (X, Wayland, VT, or other).
No fancy colors or graphics with that one, though.
I believe it depends on your display manager.
I have lightdm so it's dm-tool lock
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.
physlock
now, it locks the screen and works for X, wayland or VTs. Linux software can be very rich in bugs, so I would not be surprized if it's one. Also I don't use any DM anymore, I just log into a VT and launch startx, weston, or whatever I fancy from there. It's easy to switch between WMs with a simple .xinitrc
script.
– Rolf
Mar 29 '18 at 22:02
A solution that is more likely to be independent from the desktop environment in use:
xdg-screensaver lock