sudo bash -c gave permission denied

In my linux (centos 7), there are 2 users A (normal user) and B (belongs to wheel group). I am trying to change User A’s .bash_profile file by running the following command with user B. ./test.sh /home/a/.bash_profile “export something” #!/bin/bash set -o errexit filePath=${1}; content=${2}; result=`sudo grep “$content” $filePath || true`\ if [[ -z $result … Read more

sudoers sudoedit recursive wildcard

I want to allow editing any file (recursively) under specific directory via sudoers. None of the below works (Debian 9 sudo) ops ALL=(root) NOPASSWD: sudoedit /opt/myapps/ ops ALL=(root) NOPASSWD: sudoedit /opt/myapps/* ops ALL=(root) NOPASSWD: sudoedit /opt/myapps/** ops ALL=(root) NOPASSWD: sudoedit /opt/myapps/**/* What is the correct syntax? Answer You could give the user access to the … Read more

How does google cloud setup sudoers for googlecloudshell user without adding it to the /etc/group file

I am not a new user on unix and linux. Before today I know everything works needs a logical configuration to make it work. But today, when I create ubuntu instances on google cloud, I found something unusual. I create an additional user besides the default cloud shell user which I use browser to login. … Read more

Changing Hostname in sudoers file

So i got a sudoers file containing a NOPASSWD. Though somehow my laptop decides to change its hostname whenever it goes offline. (user hostname.home = (root) NOPASSWD: /path/to/smth/) I thought about replacing hostname.home with $HOSTNAME(Not sure if this Works). Thx for the help!! Answer AttributionSource : Link , Question Author : Usus , Answer Author … Read more

sudo to allow apt-get install of remote packages, but forbidding arbitrary commands

I’m looking for a way to allow a user to install (only remote) packages via apt-get (or another mechanism?) but not allow them to run arbitrary commands as root. I can get some of the way there via /etc/sudoers. Say I have this in my /etc/sudoers file root ALL=(ALL:ALL) ALL john ALL=NOPASSWD:/usr/bin/apt,/usr/bin/apt-get Then John appears … Read more

sudo to allow apt-get install of remote packages, but forbidding arbitrary commands

I’m looking for a way to allow a user to install (only remote) packages via apt-get (or another mechanism?) but not allow them to run arbitrary commands as root. I can get some of the way there via /etc/sudoers. Say I have this in my /etc/sudoers file root ALL=(ALL:ALL) ALL john ALL=NOPASSWD:/usr/bin/apt,/usr/bin/apt-get Then John appears … Read more

sudo to allow apt-get install of remote packages, but forbidding arbitrary commands

I’m looking for a way to allow a user to install (only remote) packages via apt-get (or another mechanism?) but not allow them to run arbitrary commands as root. I can get some of the way there via /etc/sudoers. Say I have this in my /etc/sudoers file root ALL=(ALL:ALL) ALL john ALL=NOPASSWD:/usr/bin/apt,/usr/bin/apt-get Then John appears … Read more