Skip to content

Root privileges needed for “systemctl suspend” command

On an embedded Linux device (Colibri module with an iMX7d processor) I am not able to run the command systemctl suspend as an non-root user in order to switch into suspend mode. When I log in as root user, the command is executed and the system switches to suspend mode. The same command runs on a Ubuntu PC system as an non-root user.

I would like enter the suspend mode also on the embedded Linux device without root privileges. Can anybody help me or show me the direction on how to achieve this? Any help would be greatly appreciated.

Here is the Linux kernel version of the embedded device:

$ uname -r

Here is the version of the systemctl version:

$ systemctl --version
systemd 244 (244.5+)



To allow running root only command for other (non-root) users, you can use sudo

Assuming your non-root user that needs to be able to suspend is called: user1

Create file in /root/ that contains systemctl suspend, and make sure it’s mode is 0700 and owned by root:root, e.g. run these as root:

echo 'systemctl suspend' > /root/
chmod 0700 /root/
chown root:root /root/

Then run visudo as root, then add this line:

user1 ALL=(root) NOPASSWD: /root/

then save the file

This means that user1 can run script /root/ as root user, without asking for its (user1’s) password

when you want to suspend as user1, run: sudo /root/

With this solution, user1 can run sudo /root/ as root, but cannot run arbitrary command as root (unless you added the user to sudo group)


You must make sure /root/ is only writable by root (and that it’s containing directory /root/ is also only writable by root)

If any non-root user can write to /root/, then when user1 run the file it will execute the arbitrary command there.

If any non-root user can write to directory /root/, any user can also remove/delete /root/ and then create new file with same name with arbitrary command.

User contributions licensed under: CC BY-SA
5 People found this is helpful