4

I am trying to lock and suspend from the terminal. I tried:

pmi action suspend | at now + 1 min

And then typed

exit

But both that and vlock kill the running command. Is there a way to lock the terminal and than get the computer to suspend using only Terminal commands?

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
JGreen
  • 261
  • 4
  • 18
  • http://askubuntu.com/questions/184728/how-do-i-lock-the-screen-from-a-terminal – Raja G Feb 11 '13 at 15:03
  • 1
    This command only seems to work in a terminal running side the GUI. When I try and run it from a virtual terminal it dosn't work also it does not lock the virtual terminal itself. – JGreen Feb 11 '13 at 18:43
  • Have you tried `pm-suspend` from the `pm-utils` package? – Attila O. Feb 12 '13 at 02:09
  • It is possible to use hibernate with full disk encryption. [hibernate from swap file](https://askubuntu.com/questions/6769/hibernate-and-resume-from-a-swap-file) –  Sep 17 '21 at 22:30

1 Answers1

3

I use sudo -v;gnome-screensaver-command --lock;sleep 10;sudo pm-suspend, with the sleep long enough for me to put the kbd and mouse away. Look at man pm-action for other commands (pm-hibernate,pm-suspend-hybrid), and be aware that hibernate doesn't work with encrypted swap.

waltinator
  • 35,099
  • 19
  • 57
  • 93