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

Re: Using the bash shell: determine if the root user used 'sudo -i'



On Sat, Aug 26, 2023 at 10:57 Greg Wooledge <greg@wooledge.org> wrote:
On Sat, Aug 26, 2023 at 10:49:45AM -0500, Tom Browder wrote:
> I would like to know whether 'sudo -i' or 'sudo -s' was used.
...
In fact, I suspect "I need to know if the cwd is /root" is STILL an X-Y
problem.  It's sounding like "I need to ensure my script's working
directory is /foo".  If that's truly the case, just do "cd /foo || exit"
at the top of the script.
...

Excellent mind-reading, Greg! So to use your line I will put in that dir:

    "cd /required-dir || exit"

Thanks so much.

And thanks to all others who responded.

-Tom


Reply to: