I am using the below command to delete the file:
$ echo <Password> | sudo -S -u <User> rm -f <Filename>
rm: cannot remove ‘<Filename>’: Permission denied
Please let me know where I am going wrong
I am using the below command to delete the file:
$ echo <Password> | sudo -S -u <User> rm -f <Filename>
rm: cannot remove ‘<Filename>’: Permission denied
Please let me know where I am going wrong
Don't do it this way.
You can write a script, then configure sudo
(/etc/sudoers
), to allow your user to sudo
it without a password.
You could also write a go
program, and then use suid
.
Don't do this, or any version of what you are trying to do, but you can use yes
:
$ yes 'password' | sudo -Su USER rm -f FILE
What you should do instead is allow USER
passwordless sudo access by modifying /etc/sudoers
(use visudo
where available), and adding that user to the required group.
How to run a specific program as root without a password prompt?
ps
at the right time will see your password. – Andrew Henle Jan 11 '20 at 22:47ps
I already have bigger issues to worry about than them getting my password. – jesse_b Jan 11 '20 at 22:53