Page 1 of 1

[SOLVED] Shell script stops and ask root password but it does not work !

Posted: 23 Feb 2021, 15:33
by hope
Hi,
I am trying to write a script file which use root priviliges such as changing files under root folder by script (usr/local/bin). However, although I used my commands in "sudo -s<<EOF ... EOF" block, script stops when it see sudo commands and ask root password. However Porteus's default root password" , since I did not change it, does not work in terminal window. It writes :
" We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
"

Where am i doing wrong? Why root password does not work?
My code is :

Code: Select all

#!/bin/sh
sudo -s <<EOF
cp -v unrar /usr/local/bin
EOF
Thanks.

Shell script stops and ask root password but it does not work !

Posted: 23 Feb 2021, 16:10
by Ed_P
Not sure what the <<EOF does but for some sudo scripts I use:

echo toor | sudo -S command/options

Shell script stops and ask root password but it does not work !

Posted: 23 Feb 2021, 16:58
by hope
Hi, I tried it now, but does not work for me. :no: The problem is eventhough I entered the root password "toor" to command line it does not work! After three attempt it says that "...3 incorrect attempt..." Does it restricted by some super invisible admin? :sos: How can I disable it?
[Edit issue is SOLVED] :
I found https://askubuntu.com/questions/1253643 ... inistrator. I supposed that it asks me root password, however, it asks my own password ! :shock: Thanks :).

[SOLVED] Shell script stops and ask root password but it does not work !

Posted: 23 Feb 2021, 17:24
by beny
hi you have to add guest to the sudoers configure if you want to use sudo but porteus or slackware use the su option su root password toor and you run your script.

[SOLVED] Shell script stops and ask root password but it does not work !

Posted: 23 Feb 2021, 22:21
by ncmprhnsbl
just FYI, from 5.0rc2 onwards the sudo password has been configured to ask for the target users password. ie the root password for root..
in any case, as beny says, su works just as well in a script: su -c <command>
and it's best to change the root password to something more secure ;)

[SOLVED] Shell script stops and ask root password but it does not work !

Posted: 24 Feb 2021, 09:10
by hope
ncmprhnsbl wrote:
23 Feb 2021, 22:21
just FYI, from 5.0rc2 onwards the sudo password has been configured to ask for the target users password. ie the root password for root..
in any case, as beny says, su works just as well in a script: su -c <command>
and it's best to change the root password to something more secure ;)
In the future Porteus, password should be "not for the caller but for the target" in sudo commands. Since I am new in Porteus, I am trying to get used to/ memorize such "patterns", and this announce break the routine. Thanks for great info!