Lock screen from cmd line

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.


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.

Tags:

Linux

Rhel 6