Solved

running command as root

Posted on 1997-03-17
1
237 Views
Last Modified: 2013-12-16
Solaris 2.x:
Is there a way for a user to run a script, in which some commands are ran as root? Or for a user to run an entire script as root?
I want a user to be able to run some commands which only can be ran by the root, without having to give the root's password to the user...

Thank You.
0
Comment
Question by:jonie
1 Comment
 
LVL 3

Accepted Solution

by:
pc012197 earned 50 total points
ID: 1811853
That's what the setuid-flag is good for. Enter

chmod u+s <filename>

to allow any user to run <filename> as the owner of <filename>. If <filename> belongs to root, the command will be run as root.

Be careful, though, this is a dangerous feature, which may allow your users to hack your machine. DON'T create shell scripts which are suid root. Think carefully about which programs may be run as root safely, without giving the user too much power. Try to think of a way to avoid having your users run commands as root.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now