Getting error "sudo: illegal option '-n' " while using sudo -n

Solution Verified - Updated -

Issue

  • sudo -n shows as an illegal option for "-n"
  • Getting the below error while running the sudo -n command:
sudo -n -H -u root -S /bin/sh -c "echo BECOME-SUCCESS-kdsghndwgxqczwjffjhrdipnrsdzbvcl ; whereis apt-get"
sudo: illegal option `-n'
usage: sudo -h | -K | -k | -L | -l | -V | -v
usage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]
            {-i | -s | <command>}
usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...

Environment

  • Red Hat Enterprise Linux 8
  • sudo

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content