LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 10-07-2019, 04:25 PM   #1
dmchess
Member
 
Registered: Jan 2005
Posts: 244

Rep: Reputation: 43
Problem running scripts as plain user


I installed Debian Jessie on an older OrangePizero. It works, but inorder to run scripts, I have to be signed into root. I added the regular user to the sudo list (using visudo) and even tried adding this user to the adm and sudo group.

I am not that knowledgeable about plain Debian, I mostly use Ubuntu and Mint.
 
Old 10-07-2019, 05:41 PM   #2
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
* What script?
* How are you trying to invoke the script?
* What happens? Any error messages?
 
Old 10-08-2019, 09:04 AM   #3
dmchess
Member
 
Registered: Jan 2005
Posts: 244

Original Poster
Rep: Reputation: 43
I am just ssh in across a home netwwork and Actully there are three scripts:

1. A classic awk script:

myuser@OrangePizero:~$ cat bin/AllUser.sh
#!/bin/bash
awk -F":" '{printf("%s \t %-10s \t %s \t%d\n", "User Name:", $1, "User ID No.:", $3)}' /etc/passwd | sort --key=18

2. an fping network scanning script (I use this script on my network a lot):

myuser@OrangePizero:~$ cat bin/myfping.sh
#!/bin/bash
/usr/bin/fping -s -g 192.168.0.0 192.168.0.255 -r 1 2> /dev/null | grep alive

3. And finally, a little calculator script I picked up somewhere:

myuser@OrangePizero:~$ cat bin/Calc.sh
#!/bin/sh
cat << EOF | bc -l
scale=4
$*
EOF
exit 0

If I try running them as a normal user nothing happens, or it says killed.

myuser@OrangePizero:~/bin$ ./Calc.sh '1+1'
Killed
myuser@OrangePizero:~/bin$ ./myfping.sh
@OrangePizero:~/bin$ ./AllUser.sh

I just checked again and myuser can run it as sudo, but not normal user.

The ls -la shows all three files are executable by all users.

drwxr-xr-x 2 myuser myuser 4096 Oct 7 16:00 .
drwxr-xr-x 3 myuser myuser 4096 Oct 7 16:00 ..
-rwxr-xr-x 1 myuser myuser 127 Oct 7 15:28 AllUser.sh
-rwxr-xr-x 1 myuser myuser 52 Oct 7 16:00 Calc.sh
-rwxr-xr-x 1 myuser myuser 91 Oct 7 15:41 myfping.sh

Last edited by dmchess; 10-08-2019 at 09:26 AM.
 
Old 10-08-2019, 03:22 PM   #4
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Curious.

What happens if you run some of those commands directly, rather than in the scripts?
 
Old 10-08-2019, 05:02 PM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Is something wrong with /bin/sh and /bin/bash? Or with a shared library used by the shell or the commands? Is there anything inthe system log and/or the kernel message buffer?

If not, run the scripts as bash AllUsers.sh, and try the debug option bash -x AllUsers.sh.
 
Old 10-08-2019, 05:48 PM   #6
dmchess
Member
 
Registered: Jan 2005
Posts: 244

Original Poster
Rep: Reputation: 43
I tried that, the commands do not run from this user:

myuser@OrangePizero:~$ /usr/bin/awk -F":" '{printf("%s \t %-10s \t %s \t%d\n", "User Name:", $1, "User ID No.:", $3)}' /etc/passwd | sort --key=18

If I run it as:

myuser@OrangePizero:~$ bash -x AllUser.sh+ awk -F: '{printf("%s \t %-10s \t %s \t%d\n", "User Name:", $1, "User ID No.:", $3)}' /etc/passwd
+ sort --key=18

No output. I also tried apt-get'ing awk and bash, no change. I checked to see what shell is set and it was bash.
checked path and

/home/myuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I did a whereis awk and it said /usr/bin

Terry
 
Old 10-08-2019, 08:29 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,331
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
The issue here might be the permissions attached to the scripts. My guess is that only root has "execute" privileges.

Try checking the permission on them:

Code:
ls -l /path/to/filename
Here's an example:

Code:
$ ls -l /usr/bin/podget
-rwxr-xr-x 1 root root 147171 Jun 19 19:50 /usr/bin/podget
See man ls for more.
 
Old 10-08-2019, 08:36 PM   #8
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Can you do the following and copy paste everything from /tmp/log.txt

Code:
$ script /tmp/log.txt
$ /usr/bin/awk -F":" '{printf("%s \t %-10s \t %s \t%d\n", "User Name:", $1, "User ID No.:", $3)}' /etc/passwd | sort --key=18
$ echo $?
$ ls -l /etc/passwd
$ cat /etc/passwd

Last edited by phil.d.g; 10-08-2019 at 08:38 PM.
 
Old 10-08-2019, 08:37 PM   #9
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by frankbell View Post
The issue here might be the permissions attached to the scripts. My guess is that only root has "execute" privileges.
Quote:
Originally Posted by dmchess
The ls -la shows all three files are executable by all users.

drwxr-xr-x 2 myuser myuser 4096 Oct 7 16:00 .
drwxr-xr-x 3 myuser myuser 4096 Oct 7 16:00 ..
-rwxr-xr-x 1 myuser myuser 127 Oct 7 15:28 AllUser.sh
-rwxr-xr-x 1 myuser myuser 52 Oct 7 16:00 Calc.sh
-rwxr-xr-x 1 myuser myuser 91 Oct 7 15:41 myfping.sh
Also, if that was the case I would expect "Permission denied" errors.
 
Old 10-09-2019, 08:28 PM   #10
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,834

Rep: Reputation: 108Reputation: 108
Hya,

Can be far off topic, but file system integrity (fsck) could be a culprit.

cheers
 
Old 10-09-2019, 08:36 PM   #11
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,331
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
Quote:
if that was the case I would expect "Permission denied" errors.
Just as an aside, when I try run as user a command that only root can run, I usually get a "file not found."

Note that this refers to commands, not to scripts.
 
Old 10-09-2019, 08:57 PM   #12
dmchess
Member
 
Registered: Jan 2005
Posts: 244

Original Poster
Rep: Reputation: 43
Under normal user, no file created. Under root, file created but empty.
 
Old 10-10-2019, 04:26 PM   #13
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by dmchess View Post
Under normal user, no file created. Under root, file created but empty.
Did you prefix each command with sudo? Or run all the commands in one root shell session? If the former, I'd expect an empty file.

Something's way off. It's definately not behaving normally (you indicated you don't know Debian all that well).

How old is this installation?
Have you installed anything not from the offical repositories?
Have you followed any online tutorials?
If you create a brand new user, does that user have the same problem?
 
Old 10-10-2019, 08:51 PM   #14
dmchess
Member
 
Registered: Jan 2005
Posts: 244

Original Poster
Rep: Reputation: 43
Well I'll tell you what I did,

I copied the commands from the post and pasted them into the user account sign on, which I knew would fail. Then I did a

"fc -l" and saw what the begin and end command numbers were. Lets say they were 20 and 25. I then did a "fc -e vi 20 25" and
then used vi to delete off the first two characters from each command. I then did a :x and the commands executed.
I then repeated this procedure under root. I know a few tricks.

Terry
 
Old 10-10-2019, 10:45 PM   #15
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
At first I was reluctant to suggest hardware problem, because you said that everything works fine under root. However, it looks like everything is not fine with root. /tmp/log.txt should contain the commands you executed and their output.

What about the other 4 questions I asked?

Does the rest of the system work properly? How long since its last reboot?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NS2: Need of plain plain aodv.cc and aodv.h files chenil Linux - Software 1 07-10-2013 06:17 AM
Firefox: Treating *.sh files (shell scripts) as plain/text Woodsman Linux - Desktop 1 01-13-2008 01:34 PM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 12:56 PM
VNC showing plain X w/ no desktop when vncserver started by non-root user jboo Linux - Software 6 02-08-2004 04:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration