1

I would like to check if the given ip address is already in the config file. But /etc/ can only be accessed by root, and I'm running the a script as admin. It seems I can't just do sudo

#!/bin/bash
CLIENT_WG_IPV4="10.66.66.1"

DOT_EXISTS=$(sudo grep -c "$CLIENT_WG_IPV4/22" "/etc/wireguard/wg0.conf")
if [[ ${DOT_EXISTS} == '0' ]]; then
   ...
fi

I get the error message:

grep: /etc/wireguard/wg0.conf: Permission denied

What can I do?

Houman
  • 1,545
  • 4
  • 22
  • 36
  • 2
    sudo is certainly asking for a password. you should run your script as an authorized user or as root without sudo. – dominix Nov 15 '21 at 05:57

0 Answers0