You get a bonus - 1 coin for daily activity. Now you have 1 coin

sudo: error "sorry, you must have a tty to run sudo"

Practice



If you've come across the error "sorry, you must have a tty to run sudo" in the logs when trying to run a command from a script using sudo, know this: by default sudo wants to be run only by logged-in users (i.e. users who have an open TTY terminal) - for security reasons.

This means sudo won't want to work from a script. But we can get around this.

Open the sudoers file for editing and find this line:
Default requiretty

and comment it out:
#Default requiretty


Location of the sudoers file depending on the OS:
  • FreeBSD: /usr/local/etc/sudoers
  • Debian/ubuntu: /etc/sudoers
  • CentOS/RedHat: /etc/sudoers

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "LINUX operating system"

Terms: LINUX operating system