1

What is the default path of sudo command? I checked in some Linux flavours and some solaris flavours, it is:

/usr/bin/sudo

If 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.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
prasanna
  • 161
  • 2
  • 4
  • 10

2 Answers2

2

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.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
johnshen64
  • 4,593
  • 17
  • 11
2

Use whereis to find command location/path

$ whereis whereis
sudo: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
VDR
  • 1,061
  • 9
  • 8