You are not logged in.

#1 2024-04-04 16:00:39

redshoe
Member
Registered: 2015-12-16
Posts: 250

How to run a sudo required command without using sudo?

I am using powerpanel to monitor my UPC activities and whatnot. The command pwrstat require me to use sudo. But is there a way for me to work around this process? I was guessing that adding my user to a power group or something would do the trick.

Offline

#2 2024-04-04 16:32:50

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,351

Re: How to run a sudo required command without using sudo?

Are you doing it in a script?

Dirty (and insecure) workaround is

 echo password | sudo -S command

Last edited by Roken (2024-04-04 16:33:25)


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Fractal Design Define 7 XL, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

/ is the root of all problems.

Offline

#3 2024-04-04 17:25:27

redshoe
Member
Registered: 2015-12-16
Posts: 250

Re: How to run a sudo required command without using sudo?

No. I am just running on the terminal...

Offline

#4 2024-04-04 17:28:17

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,156

Re: How to run a sudo required command without using sudo?

Is the pwrstatd daemon/service running -- and do you still have the limitations if you explicitly start the service? Also just judging from that, adding your user to the power group "should" give you access to these things.

Offline

#5 2024-04-04 18:02:07

redshoe
Member
Registered: 2015-12-16
Posts: 250

Re: How to run a sudo required command without using sudo?

Yes. I am running the daemon/service, and yes, I still do need to type sudo in order for me to run the commands. Do I just add my user name to the power group like

sudo useradd –G power user

?

Offline

#6 2024-04-04 18:51:08

loqs
Member
Registered: 2014-03-06
Posts: 18,872

Re: How to run a sudo required command without using sudo?

What happens when you do not use sudo?

Offline

#7 2024-04-04 19:07:33

redshoe
Member
Registered: 2015-12-16
Posts: 250

Re: How to run a sudo required command without using sudo?

loqs wrote:

What happens when you do not use sudo?

Permission denied

Offline

#8 2024-04-04 20:22:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: How to run a sudo required command without using sudo?

sudo useradd –G power user

"man usermod", what's the output of "id"?

Permission denied

Is that really all?

Offline

#9 2024-04-04 20:44:37

redshoe
Member
Registered: 2015-12-16
Posts: 250

Re: How to run a sudo required command without using sudo?

seth wrote:

sudo useradd –G power user

"man usermod", what's the output of "id"?

uid=1000(rangke) gid=1000(rangke) groups=1000(rangke)
seth wrote:

Permission denied

Is that really all?

Yes. Single line of

Permission denied

Offline

#10 2024-04-04 20:56:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: How to run a sudo required command without using sudo?

You're not in the power group, check the usermod manpage and nb. that you'll have to re-login to apply that.
(Running a nested login shell will do, so you don't have to completely quit the session)

Offline

#11 2024-04-05 06:30:55

walkingstickfan
Member
From: USA
Registered: 2021-05-10
Posts: 116

Re: How to run a sudo required command without using sudo?

V1del wrote:

Is the pwrstatd daemon/service running -- and do you still have the limitations if you explicitly start the service? Also just judging from that, adding your user to the power group "should" give you access to these things.

Isn't adding yourself to the power group kind of dangerous? Being prompted for a password when using something requiring sudo is somewhat of a safety measure.


Arch Linux with Openbox & Tint2

Offline

#12 2024-04-05 06:35:32

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: How to run a sudo required command without using sudo?

My preferreed solution to the likely problem would be to put the desired command (which is likely some value polling?) into sudoers as NOPASSWD, but https://wiki.archlinux.org/title/Users_ … sed_groups

Offline

Board footer

Powered by FluxBB