Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Running Command Or Script As Root
stick35
post Sep 3 2003, 10:13 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 3-September 03
Member No.: 1,374



I need a way to run a script with root priveleges without being prompted for the root password.

Quick description of my problem: I have a KVM unit that allows me to share one monitor, keyboard and mouse between 2 machines (SuSE 8.1 and XP). When I use my KVM to switch back to my SuSE 8.1 machine, the mouse needs to be re-initialized - this is a known problem. The recommended way to reset the mouse is to press Ctrl-Alt-F1 to go to text mode, then Ctrl-Alt-F7 to go back to X. That works, but I found a command that resets the mouse: xmset -E

xmset can only be run when you have root privileges. I know I can run sux in a shell before executing xmset, but I need to do that without it prompting me for the root password because I want to use xbindkeys to assign a keystroke to do the whole thing. I have created a script file that does the sux and xmset commands, but it forces me to type the root password.

I am the only user on the machine, so security is not an issue - I set the whole thing up. The machine is not open to the world.

Anyone have any advice? I'm open to listening to other approaches if you think there is a better way to do what I'm trying to do.

Thanks for any help you can give.
Go to the top of the page
 
+Quote Post
hughesjr
post Sep 3 2003, 10:54 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



if you have sudo installed, you can do this:

edit your /etc/sudoers file and add this line to the bottom of the file (you have to run the command visudo as root to edit the sudoers file):

username ALL=NOPASSWD:full_path_to_script

(substitute your username and path for username and full_path_to_script above)

Then ... use the command:

sudo full_path_to_script


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
stick35
post Sep 4 2003, 08:42 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 3-September 03
Member No.: 1,374



Thank you. I will check that out tonight. I was able to get it working using "expect" last night, but your solution would be much cleaner.

Thanks again!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th December 2017 - 07:57 AM