You are not logged in.
Pages: 1
I've installed Archlinux recently, installed sudo and added my user to wheel group. Then I uncommented the line from visudo. I am able to use pacman with sudo, but not without (is it supposed to be like that? I don't know). Is it possible to somehow use it without writing sudo before all the time?
Offline
You can use an alias
alias sp="sudo pacman "
You can use pacman w/o sudo for 'pacman -Q', 'pacman -Ss' etc.
Last edited by karol (2013-05-10 18:47:59)
Offline
If you could make changes to your system without root access, that would destroy the point of using sudo.
For your own benefit you could make an alias like above, or something more like
alias pacman="sudo pacman"
Just put that in your .bashrc or .bash_aliases and then when you type 'pacman', bash will interpret it as if you wrote sudo in front of it. Of course if you did that, then it will ask for your password even when doing commands that don't require root (like -Q or -Ss). I have mine set up similar to what the Arch Wiki recommends, e.g.:
alias pacs="sudo pacman -S"
alias pacup="sudo pacman -Syu"
alias pacf="pacman -Ss"
alias pacq="pacman -Q"
Last edited by zezhyrule3 (2013-05-10 19:14:41)
- dots -
Offline
Thanks
Offline
Please remember to mark the thread as solved https://bbs.archlinux.org/viewtopic.php?id=130309
Offline
I got this from a different section of the Arch forums about someone requesting this kind of function in zsh. If you have bash you can put the following in your .bashrc and calling `pacman` will only be done as root if pacman needs to be run as root.
pacman()
{
case $1 in
-S | -D | -S[^sih]* | -R* | -U*)
/usr/bin/sudo /usr/bin/pacman "$@" ;;
*) /usr/bin/pacman "$@" ;;
esac
}
The problem with making an alias for pacman is that some actions don't require the use of sudo, so you would more likely want to create a separate alias for when you don't want to run pacman as a super user. This seemed to fix that for me.
Edit: I do not how it works so unless you do and feel comfortable, use at your own risk.
Last edited by jgreen1tc (2013-05-10 21:12:19)
Offline
I created 3 shortcuts: sp (sudo pacman), p (pacman), and pu (sudo pacmanu -Syu)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
There's nothing wrong with e.g. 'sudo pacman -Q foo', you won't break anything, but you're right saying that this script is The Right Way (tm).
Offline
If you could make changes to your system without root access, that would destroy the point of using sudo.
For your own benefit you could make an alias like above, or something more like
alias pacman="sudo pacman"
Just put that in your .bashrc or .bash_aliases and then when you type 'pacman', bash will interpret it as if you wrote sudo in front of it. Of course if you did that, then it will ask for your password even when doing commands that don't require root (like -Q or -Ss). I have mine set up similar to what the Arch Wiki recommends, e.g.:
alias pacs="sudo pacman -S" alias pacup="sudo pacman -Syu" alias pacf="pacman -Ss" alias pacq="pacman -Q"
I have even more extreme version of aliases:
alias S="sudo pacman -S
alias Syu="sudo pacman -Syu
alias Ss="pacman -Ss"
alias R="sudo pacman -R"
Yeah I'm that lazy.
Arch x86_64 ATI AMD APU KDE frameworks 5
---------------------------------
Whatever I do, I always end up with something horribly mis-configured.
Offline
I just re-read the OP and it seems like he is asking a different question than what we have been answering. I think he is saying that he can't use pacman unless he uses sudo. Is that the case OP? Can you try to run, for instance:
pacman -Ss iptables
and see if you get a result? I'm not sure if you are trying to simply use certain flags that require pacman to be run as root. If that's the case, and you don't want to use sudo before you call pacman with these flags, the advice we have given so far wont be useful.
Edit: I guess karol did touch on it.
Last edited by jgreen1tc (2013-05-10 21:36:49)
Offline
If you want to use pacman without root privileges, you can allow the command in /etc/sudoers like this:
username hostname= NOPASSWD: /usr/bin/pacman -Syu
Last edited by teateawhy (2013-05-10 23:22:36)
Offline
If you want to use pacman without root privileges, you can allow the command in /etc/sudoers like this:
username hostname= NOPASSWD: /usr/bin/pacman -Syu
But that will create a gaping security hole and cannot be recommended.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
teateawhy wrote:If you want to use pacman without root privileges, you can allow the command in /etc/sudoers like this:
username hostname= NOPASSWD: /usr/bin/pacman -SyuBut that will create a gaping security hole and cannot be recommended.
Now i am really interested in this point, but i do not want to hijack this thread.
As far as i know you pacman asks for your password when changing one letter of the command.
sudo pacman -Syu package
Password:
As /etc/pacman.d/mirrorlist can only be written by root, how could this be used against me?
Offline
I personally don't use sudo... I just use su to become root. I imagine it counts as more secure? But I do it just because I find it more intuitive. It certainly beats having to have different pacman aliases depending on whether the pacman command requires root privileges or not.
Offline
Just use pacaur. It will ask for sudo password only if it needs it.
Offline
Just use pacaur. It will ask for sudo password only if it needs it.
Pacman, too. If you dont type sudo...
Last edited by teateawhy (2013-05-11 21:52:38)
Offline
BasT wrote:Just use pacaur. It will ask for sudo password only if it needs it.
Pacman, too. If you dont type sudo...
Why would it ask for sudo password if you don't type sudo?
Offline
Sorry, i was not clear enough. I wanted to say that pacman can be used without root for example for 'pacman -Q'. It will not ask for password then.
Offline
As far as i know you pacman asks for your password when changing one letter of the command.
sudo pacman -Syu package Password:
As /etc/pacman.d/mirrorlist can only be written by root, how could this be used against me?
You're right. I didn't realise sudo worked like that. I still worry that it may open a security hole but certainly a much less straightforward one.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
You're right. I didn't realise sudo worked like that. I still worry that it may open a security hole but certainly a much less straightforward one.
I don't see a real security hole, but there is a problem. Imagine an update that needs manual intervention (e.g. update config files) and some regular user performs it. As a result the next reboot will be a challenge. The admin first has to trace the problem to the update and then fix it before the regualr users can boot again.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
cfr wrote:You're right. I didn't realise sudo worked like that. I still worry that it may open a security hole but certainly a much less straightforward one.
I don't see a real security hole, but there is a problem. Imagine an update that needs manual intervention (e.g. update config files) and some regular user performs it. As a result the next reboot will be a challenge. The admin first has to trace the problem to the update and then fix it before the regualr users can boot again.
Yes, in a scenario with admins and regular users, users should not be allowed to use sudo / root .
Offline
Pages: 1