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

Post here if you are a new Porteus member and you're looking for some help.
Post Reply
hope
White ninja
White ninja
Posts: 14
Joined: 04 Jul 2020, 12:07
Distribution: porteus 5.0rc1 KDE desktop

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

Post#1 by hope » 23 Feb 2021, 15:33

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.
Last edited by hope on 23 Feb 2021, 17:10, edited 1 time in total.
Newbie to Linux-Unix systems, try to read,learn, apply, modify and create.

User avatar
Ed_P
Contributor
Contributor
Posts: 5939
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

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

Post#2 by Ed_P » 23 Feb 2021, 16:10

Not sure what the <<EOF does but for some sudo scripts I use:

echo toor | sudo -S command/options
Ed

hope
White ninja
White ninja
Posts: 14
Joined: 04 Jul 2020, 12:07
Distribution: porteus 5.0rc1 KDE desktop

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

Post#3 by hope » 23 Feb 2021, 16:58

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 :).
Newbie to Linux-Unix systems, try to read,learn, apply, modify and create.

beny
Full of knowledge
Full of knowledge
Posts: 950
Joined: 02 Jan 2011, 11:33
Location: italy

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

Post#4 by beny » 23 Feb 2021, 17:24

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.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 2836
Joined: 20 Mar 2012, 03:42
Distribution: 5.0rc1-64bit all-DE+more
Location: australia
Contact:

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

Post#5 by ncmprhnsbl » 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 ;)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

hope
White ninja
White ninja
Posts: 14
Joined: 04 Jul 2020, 12:07
Distribution: porteus 5.0rc1 KDE desktop

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

Post#6 by hope » 24 Feb 2021, 09:10

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!
Newbie to Linux-Unix systems, try to read,learn, apply, modify and create.

Post Reply