Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #261209
| From | Nate Bargmann <n0nb@n0nb.us> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Using the bash shell: determine if the root user used 'sudo -i' |
| Date | 2023-08-26 19:20 +0200 |
| Message-ID | <H7573-4zuO-1@gated-at.bofh.it> (permalink) |
| References | <H72sy-4xRT-5@gated-at.bofh.it> <H72Cd-4xUZ-3@gated-at.bofh.it> <H73RD-4yAo-1@gated-at.bofh.it> <H73RD-4yAo-5@gated-at.bofh.it> <H741j-4yT0-11@gated-at.bofh.it> |
| Organization | Amateur Radio! |
[Multipart message — attachments visible in raw view] - view raw
* On 2023 26 Aug 11:10 -0500, Tom Browder wrote: > 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" In such cases I prefer specifying the complete paths in the script so as not to get lost. If the script needs to work in a specific directory of root I'll put: cd /root/dir/dir1 or something like: cd /home/username/dir and so on (adding whatever error recovery is needed). If I need to source a file I just type in the complete path name. It's a one time bother and the executing shell doesn't care and as the script gets more complex it's much easier to keep one's bearings on where the script is working at various points. As I see it, relative paths are more for interactive shell use. - Nate -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Web: https://www.n0nb.us Projects: https://github.com/N0NB GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 16:30 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Roberto C. Sánchez <roberto@debian.org> - 2023-08-26 16:40 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 18:00 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Greg Wooledge <greg@wooledge.org> - 2023-08-26 18:00 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 18:10 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Nate Bargmann <n0nb@n0nb.us> - 2023-08-26 19:20 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Karl Vogel <vogelke@pobox.com> - 2023-08-27 01:10 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Greg Wooledge <greg@wooledge.org> - 2023-08-27 01:30 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Michael Kjörling <2695bd53d63c@ewoof.net> - 2023-08-26 18:20 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' <tomas@tuxteam.de> - 2023-08-26 18:40 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Alain D D Williams <addw@phcomp.co.uk> - 2023-08-26 17:30 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' <tomas@tuxteam.de> - 2023-08-26 17:50 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 21:00 +0200
Re: Using the bash shell: determine if the root user used 'sudo -i' tomas@tuxteam.de - 2023-08-26 21:20 +0200
csiph-web