Run sudo command on login?

Kernel: 5.14.3-zen1-1-zen
DE: Plasma 5.22.5

I'm trying to run this terminal command automatically every time I log on my device:
sudo intel-undervolt apply

I've been searching around and it seems there are many ways to accomplish this, but I'm too wet behind the ears to successfully do it, so was hoping someone could help explain how it's done.

I've tried making an .sh file with the below command and add it to the Xfce Autostart under System Settings, but it didn't do the job. The file is also set to executable.

#!/bin/bash
sudo intel-undervolt apply

Sorry for the novice question, I only recently jumped from M$ to Linux so I still have lots to learn.

I think the best approach would be to create a simple systemd service at startup including only that command (I think you don't need sudo there).
If necessary, this is just the first tutorial found with a search, but there are hundreds...
https://www.linode.com/docs/guides/start-service-at-boot/

7 Likes

Hi and Welcome, I usually use systemctl for running command on boot but there is a lot of ways. If your .sh works from terminal then you can add it to the above command.
https://wiki.archlinux.org/title/Systemd

4 Likes

Thank you, this guide hit the spot!

2 Likes

You're welcome, also in the forum :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.