Adding users to sudoers through shell script

You could simply echo (with elevated privileges, of course) directly to the /etc/sudoers file: sudo -i echo ‘nickw444 ALL=(ALL:ALL) ALL’ >> /etc/sudoers # ^^ # tab (note the tab character between the username and the first ALL) Or, for a script: #!/bin/bash # Run me with superuser privileges echo ‘nickw444 ALL=(ALL:ALL) ALL’ >> /etc/sudoers Then … Read more

Ansible non-root sudo user and “become” privilege escalation

Why am I getting permission denied? Because APT requires root permissions (see the error: are you root?) and you are running the tasks as david. Per these settings: become: true become_user: david become_method: sudo Ansible becomes david using sudo method. It basically runs its Python script with sudo david in front. the user ‘david’ on … Read more

sudo pip install VS pip install –user

$ sudo pip install Installs the package globally in your python installation, i.e. for all users. $ pip install –user Installs to the local user directory, i.e. ~/.local/lib/python — just you. Example: $ sudo pip install jupyter $ jupyter notebook Will run jupyter, open a web browser, allow you to work with notebooks. $ pip … Read more

On OS X El Capitan I can not upgrade a python package dependent on the six compatibility utilities NOR can I remove six

Quick Fix: I just got around what I think was the same problem. You might consider trying this (sudo, if necessary): pip install scrape –upgrade –ignore-installed six Github is ultimately where I got this answer (and there are a few more suggestions you may consider if this one doesn’t solve your problem). It also seems … Read more

Why does pip3 want to create a kdewallet after installing/updating packages on Ubuntu 20.04?

This solved it for me: python3 -m keyring –disable Running it adds: [backend] default-keyring=keyring.backends.null.Keyring to the file ~/.config/python_keyring/keyringrc.cfg. Presumably PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring mentioned at https://stackoverflow.com/a/68504137/895245 offers an environment variable way to achieve the same result. Without this, it would show the annoying KDE keyring popup every time I try to install a package: Google, index this: The … Read more

Running as a host user within a Docker container

You can share the host’s passwd file: docker run -ti -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v `pwd`:`pwd` -w `pwd` -v pydeps:/usr/local -p 8000:8000 python:3-slim ./manage.py runserver Or, add the user to the image with useradd, using /etc as volume, in the same way you use /usr/local: docker run -v etcvol:/etc python….. useradd -u `id … Read more

What is the proper way to sudo over ssh?

Another way is to use the -t switch to ssh: ssh -t user@server “sudo script” See man ssh: -t Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services. Multiple -t options force tty allocation, even if ssh … Read more

sudo in php exec()

It sounds like you need to set up passwordless sudo. Try: %admin ALL=(ALL) NOPASSWD: osascript myscript.scpt Also comment out the following line (in /etc/sudoers via visudo), if it is there: Defaults requiretty

tech