2

I want to suspend my computer from terminal (one obtained by CTR+ALT+F1).

If I call:

# echo -n mem > /sys/power/state 

after wakeup I'm leaving an authenticated console with (possibly) root credentials open to anyone.

Is there any elegant way to suspend the computer without leaving this console open?

Background: Suspend button is not working on my XFCE desktop and because of many reasons I don`t want to fix it right now. So it is easier to just suspend from terminal.

  • What do you think about screen locking mechanisms? – polym Jun 22 '14 at 17:52
  • I'didn't want to go into that much detail in the question, in my case I mostly work in Gnome3, sometimes (on conferences) i disable nVidia card and work on xfce (to have better battery life). Everytime i do this suspend does not work beacause some incompatible change. So it's easier for me just to do it from console... – jb. Jun 22 '14 at 20:16
2

Here is my solution (it is not very clean).

I created a script called /sbin/suspend.sh containing:

#!/bin/bash
echo -n mem > /sys/power/state

and then in my .bashrc file added following alias:

alias dosuspend='sudo suspend.sh && exit'

Now whenever I call dosuspend console is logged out right after wakeup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.