LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to run root command having normal user permission (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-run-root-command-having-normal-user-permission-422428/)

ravi.patil 03-07-2006 06:41 AM

how to run root command having normal user permission
 
Hi,
I want to run some root commands.I am having normal user permission.I have tried with setuid bit?

i followed followig steps.

$ cp mkdir ~/test
$ chmod 4776 test
$ ls -l test
-rwsrwxrw- 1 u03125 b-03 20888 2006-03-07 17:49 test
$ ./test /usr/bin/ttfonts
./test: cannot create directory `/usr/local/bin/ttfots':permission denied


can any body help me out how to do this?

marozsas 03-07-2006 06:49 AM

The SETUID bit means the command will run as the owner of program and not as the current user.
To this work, you need to change the owner of test from u03125 to root: "chown root test".

cheers

ravi.patil 03-07-2006 07:04 AM

hi this is also saying
"failed to change ownership of `test' to root
chown: changing ownership of `test': Operation not permitted
"

what the cause of it?

marozsas 03-07-2006 07:34 AM

Only root can do that ! ;)
Otherwise, this will be a big security hole, isn't ?

muha 03-07-2006 07:35 AM

You need to be root for "chown root test".

pixellany 03-07-2006 07:56 AM

OP wants to know how to run commands that need root access, but he does not have that...right?

Only option is sudo. If you do not have adequate privileges using sudo, then you need to find the administrator for the machine.

twantrd 05-21-2006 02:06 PM

I'm trying to do the same thing. I'm trying to run a script as a normal user but I want to write a file to a location that only root can.

Code:

-rwsrwxrwx    1 root    root          37 May 21 10:44 writetest.sh

[twantrd@trdlinux twantrd]$ /tmp/writetest.sh
touch: creating `/etc/writetest': Permission denied

Here is the script 'writetest.sh'
Code:

#!/bin/bash

touch /etc/writetest


Any ideas?

-twantrd

twantrd 05-21-2006 02:21 PM

Argh, nevermind. Went drinking last night. Anyhow, Linux doesn't read the suid bit on scripts.

-twantrd


All times are GMT -5. The time now is 01:18 AM.