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: Greg Wooledge
Subject: Re: [Help-bash] Root access in subshell
Date: Fri, 24 Jan 2014 08:45:25 -0500
User-agent: Mutt/1.4.2.3i

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.



reply via email to

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