LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-09-2006, 06:44 AM   #1
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242
scripts with root priviliges


Hi,
I wrote a short script mounting/unmounting external sata drives or pen drives. I installed slackware on a new box, and the problem is that when I run the script as a normal user, I get
the error about not having permissions to mount it (fair enough),
but when I su and run the script as root the script can't be found. obviously it's not in the path, but I do not want to add
normal_user/home/bin to root's path. I am sure some time ago I managed to do it without adding anything to the root's path.
Obviously, I can always cd /home/bin/ and run the script, but that's not the point.

thank you
 
Old 08-09-2006, 07:04 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

Why not use su - on the mount command only and run the script as regular user?

I.e:

#!/bin/bash

some code...
more code...

su - -c "mount -o loop -t iso9660 /data/Multimedia/"

more code....


Su's -c switch lets you enter a command (man su for details).

You will be asked for a password.

By the way: If you use su instead of su -, root's environment is not parsed.

PS: You could also install/configure sudo.

Hope this helps.
 
Old 08-09-2006, 07:07 AM   #3
rahulk
Member
 
Registered: Mar 2006
Posts: 110

Rep: Reputation: 16
Quote:
Originally Posted by sycamorex
Hi,
I wrote a short script mounting/unmounting external sata drives or pen drives. I installed slackware on a new box, and the problem is that when I run the script as a normal user, I get
the error about not having permissions to mount it (fair enough),
but when I su and run the script as root the script can't be found. obviously it's not in the path, but I do not want to add
normal_user/home/bin to root's path. I am sure some time ago I managed to do it without adding anything to the root's path.
Obviously, I can always cd /home/bin/ and run the script, but that's not the point.

thank you
do the following:-

[root@yourcomputer /] whereis ls

then whatever the path is suggested by the command, put your script in there and then it will work like a normal linux command. Also remember, the permission should be 777 on the file, but mounting wont be allowed to any other user except root.

Rgds,
Rahul.
 
Old 08-09-2006, 07:52 AM   #4
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836

Original Poster
Blog Entries: 1

Rep: Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242
Thanks guys, I will try both methods at home.
I know sudo is installed on my box, how do I configure it?

thanks
 
Old 08-09-2006, 08:49 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

I don't use sudo myself, but here are a few links:

sudo setup guide
man sudoers
man sudo

and last, but not least:

sudo main page

Hope this helps.
 
Old 08-09-2006, 09:16 AM   #6
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836

Original Poster
Blog Entries: 1

Rep: Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242
thanks, I will play with it
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Suspicious User added with root priviliges z3r0star21 Linux - Security 8 03-03-2006 12:20 PM
root mail priviliges akitchens Linux - Newbie 5 12-20-2005 05:09 PM
can't use my root priviliges 47.46.45 Linux - Security 2 06-27-2005 02:31 PM
Root Priviliges Itsu SUSE / openSUSE 7 11-19-2004 08:42 PM
writing a script running firestarter automatically with kppp without root priviliges melquiades Linux - Newbie 3 08-11-2003 06:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:58 AM.

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