What Is the Default Path for Sudo Command?

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest