Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Aug 2004 16:07:33 -0700
From:      Bill Campbell <freebsd@celestial.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: sudo syntax
Message-ID:  <20040826230733.GA94453@alexis.mi.celestial.com>
In-Reply-To: <20040826223449.GF6896@asu.edu>
References:  <20040826223449.GF6896@asu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 26, 2004, David Bear wrote:
>I want to run a command
>
>tar czf - / | ssh id@somehost dd of=tarball.tgz
>
>I need to run tar as root.  However, I need to run ssh as user 'id'.
>
>I tried 
>
>sudo tar czf - / | ssh id@somehost dd of=tar.tgz
>
>but am unsure if ssh was launched as 'id' or as root.

Everthing to the left of the pipe symbol is one process (e.g.  sudo), the
process to the right is independent of that, and will run as the normal
user.

>Any way to be certain that sudo is doing what I want?

You could do something like this if you want to see it which would display
the output of id before starting the right side ssh command.

	sudo tar czf - / | ( id ; ssh id@somehost dd of=tar.tgz )

Bill
--
INTERNET:   bill@Celestial.COM  Bill Campbell; Celestial Systems, Inc.
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``It is surprising how much new stuff users find that developers never do.
You put a copy in front of a normal user and they find all these bugs that
you would think developers would find. The real users and developers are
completely different species as far as I am concerned.''
    --Linux creator Linus Torvalds



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040826230733.GA94453>