Linux system how to sleep

  

Linux system sleep

Under Linux, I like to use the command to let the system go to sleep:

$ echo mem |  Sudo tee /sys/power/state

Of course, you don't have to type a long string every time, you can add it to a script. Adding the script command to the /etc/sudoers file will avoid having to enter the user password every time.

Some colleagues can't figure out why the following command was unsuccessful:

$ sudo echo mem > /sys/power/state

The flow of the above shell command is :fork a child process, wait → shell closes the standard output, opens the redirect file state as standard output → execve "sudo echo mem" → In the second step, the shell did not have write permission, so it has failed.

Copyright © Windows knowledge All Rights Reserved