I have this code in a linux executable file to start atom from there:
#! /bin/bash
sudo atom
I wanted to include sudo password after that lines of code, so the program will run automatically.
I have this code in a linux executable file to start atom from there:
#! /bin/bash
sudo atom
I wanted to include sudo password after that lines of code, so the program will run automatically.
I wouldn't suggest hardcoding a password into your script as it carries a security risk.
Strictly speaking you can by doing:
echo "yourpassword" | sudo -S <command>
The -S
flag will read the password from stdin.
There is another better way for you to allow password-less sudo commands by modifying your sudoers file.
Why you not use sudoers? Try running atom without password.
Edit /etc/sudoers
via visudo:
visudo -f /etc/sudoers
Put new line and save:
youuser ALL=(ALL:ALL) NOPASSWD: atom
do not forget to replace youuser