Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A An alternative to pacman sudo nag?

Some pacman functions require sudo. When I forget the sudo, you get: error: you cannot perform this operation unless you are root. I then have to press the keys: up, home, s, u, d, o, space, en...

2 answers  ·  posted 10mo ago by matthewsnyder‭  ·  last activity 9mo ago by TowerOfTurtles‭

#1: Initial revision by user avatar matthewsnyder‭ · 2024-01-18T00:05:26Z (10 months ago)
An alternative to pacman sudo nag?
Some pacman functions require sudo. When I forget the sudo, you get:

```
error: you cannot perform this operation unless you are root.
```

I then have to press the keys: `up, home, s, u, d, o, space, enter` to rerun with sudo. I find this irritating and it breaks my flow.

Is there a better solution here? If sudo is required for an operation, it should be run with sudo, rather than erroring out. In most situations where sudo is *dangerous*, it would prompt for a password anyway, so there's very little danger here. I have almost never ran pacman with sudo when I didn't mean to, but I have forgotten the sudo many times.

I could alias `pacman` to `sudo pacman`. However, some operations don't need sudo, like `-Q`. That alias would result in needless password prompts, which I also want to avoid.

How can I make pacman automatically use sudo when needed? I'd also like it to participate in sudo caching, so for example I don't want a situation like `systemctl` which automatically asks for sudo password when needed, but fails to remember it.