Re: Run script as root without sudo

From: Aristedes Maniatis via freebsd-stable <>
Date: Sun, 22 Aug 2021 01:26:15 UTC
My goal is to use standard AMI so that upgrading to new FreeBSD releases 
is easy without a manual process to build a new custom AMI each time. 
I've submitted a patch to saltstack which allows the bootstrap process 
to work without sudo on a clean FreeBSD AMI. On Linux the bootstrap 
script is run with sudo and obviously that doesn't work on a fresh 
FreeBSD install.

Thanks for everyone's help, especially Andriy who pointed out that I was 
missing the fundamental difference between:

$ su - -c

$ su -l root -c

The first one uses the fact that root is the default, but then -c is an 
su command which specifies the user class and so will fail. The second 
actually passes "-c" to the shell because an explicit 
username effectively ends the 'su' command and everything after passed 
to the shell. On Linux, the -c is an su command which passes the next 
param to the shell so the -c is never itself passed to the shell and so 
both variations work over there although inn fundamentally different ways.

I just hope that in 5 years from now I can find this mailing list post 
when I completely forgot the whole thing and can't figure how to make it 


On 19/8/21 4:34pm, Jonathan Chen wrote:
> On Thu, 19 Aug 2021 at 18:25, Aristedes Maniatis <> wrote:
>> That would require root to put the file there and then to reboot the
>> machine.
> In which case, wouldn't it be simpler to just start a new instance,
> install your packages by hand, and then take a snapshot of the volume
> and convert it to a custom AMI instead? That way all new instances
> from your custom AMI will be preconfigured with the required packages.
> Cheers.