Friday 25 January 2019

linux - sorry, you must have a tty to run sudo

I had already asked this question in Stack Overflow, but I've been asked to post it here. So doing the same.


I ran this command using my java program-


sudo -u  -S pwd

I got this output-


command=sudo -u  -S pwd
exitCode=1
sudo: sorry, you must have a tty to run sudo

I tried editing /etc/sudoers but it already contains


       ALL=(ALL)       NOPASSWD: ALL

Then, I learned that this can be done by commenting out the following code in /etc/sudoers


# Defaults requiretty

Also, by default, when attempting to execute a command as another user using sudo, we have to provide our own password. But this can be changed by making the following change in /etc/sudoers-


Defaults targetpw

My Question is, is it possible to execute my above command in java without making any changes anywhere i.e. by having default settings?

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...