I am trying to add a line to the /etc/rc.conf file via a script (so I can recreate it automatically) which requires using sudo (I do not have the root's password). I get a permissions error when I try
How do I get sudo to apply the echo to the file?
Here are a couple of things I have tried:
Since I don't have the root password I cannot run
sudo echo 'apache22_enable="YES"' >> /etc/rc.conf
and I believe that sudo is handling the echo 'apache22_enable="YES"'
but is not handling the >> /etc/rc.conf
portion.How do I get sudo to apply the echo to the file?
Here are a couple of things I have tried:
Code:
$ sudo echo 'apache22_enable="YES"' >> /etc/rc.conf
cannot create /etc/rc.conf: Permission denied
$
$ sudo -c "echo 'apache22_enable="YES"' >> /etc/rc.conf"
sudo: unknown login class: echo 'apache22_enable=YES' >> /etc/rc.conf
sudo: unable to initialize policy plugin
$
$ sudo -s "echo 'apache22_enable="YES"' >> /etc/rc.conf"
#
# exit
$
Since I don't have the root password I cannot run
su -C "[i]some command here[/i]"