Confused, sudo pacman vs pacman

Hi there,

I have been on EOS for some time now and still learning new things.

I have a question. What is the right way to use pacman?

For the most part I was using “sudo pacman -Syu” to update the system and “sudo pacman -S <package name>” for regular app packages like Steam, discord, Libre office, gimp and etc.

But is this right way to use pacman?

Could I just use for example pacman -S steam?. Is it safer to not give root access or is there any different in terms of usage or safety?

I assume same logic applies to yay for AUR or just overall.

Since installing and updating packages involve writing into system directories, pacman would need root privilege in order to be able to do so.

Also, make sure that your system is always updated fully before installing any other packages.

5 Likes

Yes.

No. Since pacman installs to the system, it needs super user privileges for the same. Using sudo is necessary.

You can’t install/uninstall packages from system without super user privileges. While it indeed is a good safety measure to not run untrusted scripts/applications with sudo; pacman however is trusted and needs sudo in order to function.

Query commands (eg. pacman -Q ...) don’t need sudo since they don’t modify anything on system.

paru/yay or makepkg can build package from PKGBUILD without super user privilege. However, you’ll nevertheless need privileges in order to finally install the built package. yay is expected to be run without sudo. It automatically asks you for password when package is built and needs to be installed.

6 Likes

Thank you for the reply and explanation. For a second I thought I was using everything wrong. In arch wiki as the first thing it shows using pacman without sudo, so I got confused.

There is always # before any commands that need to be run as root in Arch Wiki.

7 Likes

Notice that they prepend the command with a pound symbol (#)

# pacman -S package_name1 package_name2 ...

taken from: https://wiki.archlinux.org/title/pacman#Installing_specific_packages

The pound symbol denotes that you need super user privileges.

In contrast, if command is to be run without sudo, the prefix is dollar symbol ($)

$ pacman -Sg gnome

last command of this section: https://wiki.archlinux.org/title/pacman#Installing_package_groups

6 Likes

Thank you pebcak and flyingcakes. I didn’t realize that there is # instead of $ and I didn’t know that # stands for super user. Noted! :smiley:

1 Like

If you are more familiar with the package management of other distros, this might be of help too: https://wiki.archlinux.org/title/Pacman/Rosetta

4 Likes

Thank you a lot for this.

I was making notes there and there about Arch commands and their usage. This is very handy, especially I also have Linux Mint(ubuntu) laptop so good to know equivalent commands.

1 Like

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