Run sudo commands without having to write my passwoard?

Hey! I’ve been learning web development for a few months now, and lately I was thinking about streaming my learning path, my personal projects, etc. The thing is that, since I use Vim I’d really like to include my pressed keys with Screenkey, but I can’t since I occasionally install something globally with npm, or with sudo pacman, and that involves showing my password.

Is there something I could do for those cases? I’m sorry if the solution is very simple, I never got really deep into Linux neither Arch other than for wm ricing.

Thanks!

Do not. On Arch based systems, never use third-party package managers like npm, pip, gem, etc… to install stuff globally (requiring root privileges).

You can use these locally, in your user space, but do all global package management using ALPM (i.e. pacman or some wrapper for pacman, like yay). Not heeding this advice will create a mess out of your system and eventually result in package conflicts.

Regarding sudo, you can disable it prompting for password, but that is a security concern, of course. A better solution is to remember to disable Screenkey when typing passwords.

But probably the best solution for streaming is to use a Virtual Machine and have some stupid password in it which you don’t mind leaking.

2 Likes

Yes, sudo is quite tunable.

“man sudoers” in your terminal (or whatever helper you’ve got, or google for “sudoers”) for much more details.

I imagine that the main reason for not doing it is in case the package to install has something dangerous, right? I only install official language servers, eslint and prettier.

Thanks! I’m going to take a look at it :slightly_smiling_face:

No, that’s not the reason. The problem is that all files you install manually or using a third-party package manager are invisible to ALPM. And many of the packages from the repos use the same filenames, so there can easily arise a conflict between files you’ve added and files from the packages from the official repos. So you really are creating a mess in your /usr/bin directory when you let something other than ALPM install stuff in it.

Aah I see, I’ll be more aware of that and see if there is any way to install the language servers with the options you gave me.

Here is an example, say you wanted to install numpy library for Python. A wrong way to do that would be:

sudo pip install numpy

This is how it is done on some other distros, and you may even find that in official and unofficial guides on how to install that library. But not on Arch!

It may work at first, but let’s say you wanted to install FreeCAD. You would try

sudo pacman -S freecad

and you’d get a bunch of errors. Why? Because package freecad has package python-matplotlib as a dependency, and the package python-matplotlib has the package python-numpy as a dependency. But package python-numpy uses the same files you’ve already installed with pip, but ALPM did not know that. Even worse, you may have the wrong version of numpy installed, so even if you manage to make it work, FreeCAD might have unpredictable errors – this is very similar to a partial update situation.

So, on Arch Linux, the solution is to only use ALPM if you want to globally install stuff!

For numpy, there is python-numpy package in the official repos, so the correct way to install it is:

sudo pacman -S python-numpy

Similarly, for the packages you want, you should first look in the official repos, if they are there. If not, look in the AUR. If not, either install them in your userspace (that is, without sudo) or make a package yourself.

Specifically, eslint is in the repos. So, just install it normally like this:

sudo pacman -S eslint
7 Likes

Welcome to the :enos: forum @emzom.dev
Going by your first discussion you are already feeling right at home :wink:

Excellent security suggestion right there.

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