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, 2014 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, 2014 at 20:16

1 Answer 1


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

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .