sudo multiple commands at once without shell script

perryh at pluto.rain.com perryh at pluto.rain.com
Sat Oct 25 18:36:34 PDT 2008


> How do I run multiple sudo commands at once? This fails
> because the semicolon ends the whole sudo command:
>
> > sudo whoami; whoami
> root
> user
>
> This confuses tcsh:
>
> monica:~> sudo ( whoami ; whoami )
> Badly placed ()'s.

Supposing sudo spawns a shell, something like

  ~> sudo whoami \; whoami

or

  ~> sudo "whoami; whoami"

should work.  If not, maybe try explicitly running a shell:

  ~> sudo sh -c "whoami; whoami"


More information about the freebsd-questions mailing list