help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Root access in subshell


From: Richard Taubo
Subject: Re: [Help-bash] Root access in subshell
Date: Mon, 3 Feb 2014 00:24:45 +0100

On Jan 24, 2014, at 2:45 PM, Greg Wooledge <address@hidden> wrote:

> On Fri, Jan 24, 2014 at 10:20:38AM +0100, Richard Taubo wrote:
>> I am running the following command in the terminal logged in as root (not 
>> via a script):
>>      [#] $(find / -user myuser)      # This is a part of a little larger 
>> script
>> 
>> When running this subshell, the subshell does not execute the command as 
>> root.
> 
> Yes it does.  What makes you think it doesn't?
> 
>> Is there a way to execute the subshell as root as well (as I am logged in as 
>> root)?
> 
> All the commands issued from a "root shell" (that is, a shell running
> with UID 0) will also run with UID 0, unless the command itself drops
> privileges.  Examples of commands that drop privileges are su, sudo,
> and setuidgid.
> 
> # id
> uid=0(root) gid=3(sys) 
> groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7(lp),20(users)
> # echo "$(id)"
> uid=0(root) gid=3(sys) 
> groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7(lp),20(users)
> 
> It's the same.

I made the error of thinking that the subshell would return the result directly 
to the main shell, so I was confusing the lack of returned feedback with that
the subshell was not run as root.
I saw that error messages came from the subshell, but not the result of the
command itself, and was taken for a spin . . .

I see that if the subshell is set to a variable I can return 
the feedback to the main shell — are there other ways to return such
feedback to the main shell?

Thanks!

Richard Taubo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]