Solved

running command as root

Posted on 1997-03-17
1
241 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

828 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