I'm trying to login as root in shell by following command :
$ echo 'myPassword' | sudo -Si
But gets me following error:
stdin: is not a tty
-bash: line 1: myPassword: command not found
My Goal :
I added above command in ~/.bashrc
in order to whenever Terminal starts up, it logged in as root
P.S :
I can successfully run below command :
For instance
$ echo 'myPassword' | sudo -S chown $USER ~/file.txt
It's as simple as this:
Update:
Seems like you want to get into root automatically whenever terminal is opened. Well, I'm not going to give you a lesson about security, but instead will provide you a solution:
Get rid of password when doing
sudo
:And add following line (replace username with whatever you need):
Next, add following at the end of your ~/.bashrc file: