Can I run sudo commands without specifying absolute path?

Solution Verified - Updated -

Issue

  • Can I run sudo commands without specifying absolute path?
  • While running custom commands and scripts via sudo using relative path, command fails with following error:
       [root@localhost ~]# sudo my_test_cmd -l
       sudo: my_test_cmd: command not found
  • Same command works correctly with absolute path of command/script:
      [root@localhost ~]# sudo /opt/custom_application/my_test_cmd -l
      Custom_Application started Successfully.

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.