0

I found out how to suspend via command line, namely by sudo pm-suspend. What I miss there is that when the machine wakes back up, the sessions (all of them running in different tty's) are not protected by password. I checked the man page for pm and this aspect is nowehere to be found there. Thus two questions:

1) How to make it work simply?

2) I could make an alias for pm-suspend, but then, what should I put there as instructions? Is there any way to log out of a shell session without killing it? Which is an interesting question on its own.

EDIT:

The question is about how to lock a shell session running outside any X environment (Gnome, etc).

EDIT:

To find out what I mean press Ctrl+Alt+F1 and follow from there. But make sure you know how to go back before you jump there :-)

  • Which Ubuntu version are you using? We might have to distinguish between upstart and systemd. – guntbert Apr 06 '16 at 18:26
  • 14.04 64-bit. I know neither of them yet. –  Apr 06 '16 at 18:28
  • Do you say that you don't have a GUI on your notebook and get asked for a password when suspending by closing the lid? – guntbert Apr 06 '16 at 18:39
  • I have a GUI, but it's about tty 1 to 6. And it's about NOT being asked when back awake. –  Apr 06 '16 at 18:42
  • AFAIK tty simply don't have the concept of "session", thats why I assumed a GUI. – guntbert Apr 06 '16 at 18:45
  • 1
    Possible duplicate of How do I lock the screen from a terminal? (look at the answer about vlock) – guntbert Apr 06 '16 at 18:47
  • That's not a duplicate. This one's not about Gnomes etc. As for the former, press Alt+Ctrl+F1 and see. –  Apr 06 '16 at 18:51
  • @guntbert No, this for suspending (not locking) from a TTY (not from a desktop environment). @ Tomasz how about sudo pm-suspend && exit? – kos Apr 06 '16 at 18:54
  • @kos Are you serious? –  Apr 06 '16 at 18:55
  • @gunbert The vlock answer is relevant though. But only partially. And now I need to find out how to vlock all tty's running a session. –  Apr 06 '16 at 18:59
  • I think I missed the fact that you want to lock multiple sessions. Then no, I wasn't serious. It seems like vlock would work well for that. – kos Apr 06 '16 at 19:08
  • I just removed my last comment. vlock -a && pm-suspend doesn't work. And it blocks in a way it asks for root's password and doesn't accept mine. –  Apr 06 '16 at 19:10

1 Answers1

0

It seems like I can answer my question myself. Still, give more answers if you have them.

sudo pm-suspend && vlock -a does the trick. But it requires the vlock being installed. And don't make it the other way round, ie. sudo vlock -a && pm-suspend, as it will ask for root's password on wake up, and there is no such thing in Ubuntu, as far as I know.