What is the default path of sudo command? I checked in some Linux flavours and some solaris flavours, it is:
/usr/bin/sudoIf a Solaris machine is not bundled with sudo, where will it get installed if we installed it by an external package?
I am developing a discovery script which is common for all Unix-based systems. It will get executed based on the uname command’s output.
To get the machine information without root user, I can create a session using sudo command, for that I need the default path of the sudo command.
2 Answers
Use whereis to find command location/path
$ whereis whereis
sudo: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz The default path for linux should usually be /usr/bin/sudo, but for all unix, or even some customized linux distros, it could really be anywhere (say /usr/local/bin/sudo, or even something link /opt/bin/sudo, or /srv/bin/sudo, etc.)
Assuming it is in your PATH—which it should be— then you should discover it by using which
sudocmd=`which sudo`Because the installation prefix on the same distribution could vary, depending on how it is installed.