You are not logged in.

#1 2008-11-15 15:14:24

hungsonbk
Member
Registered: 2007-05-26
Posts: 105
Website

sudo can't execute some commands[SOLVED]

Hi Archers,

I am using sudo and disable root account. There is some problems with sudo such as the following commands:

#sudo echo "1234"  >/etc/rc.local
# sudo cd /root

I can't execute these commands with sudo, instead i have to login as root and execute the commands. So the question is how can I solve these problems?

The Second issue is how can I give certain user the commands that they can execute. For example, user A is only allowed to use "ls" commands and not any other commands?

Cheers

Last edited by hungsonbk (2008-11-17 02:02:29)

Offline

#2 2008-11-15 15:52:38

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: sudo can't execute some commands[SOLVED]

why don't you do "sudo su" before executing those commands?


Give what you have. To someone, it may be better than you dare to think.

Offline

#3 2008-11-15 16:52:40

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: sudo can't execute some commands[SOLVED]

You can't use those commands because it aren't real commands, it are shell builtins and they are ran by your shell which is ran by your regular user.

sudo echo foo > bar

This runs the "echo" binary as root but the ">" part is handled by the shell, appropriate way to handle this:

 echo foo|sudo tee bar

cd wont work neither, if it did you could cd to a directory you don't have permissions to and then you would be in their as regular user, unable to do anything... You should just work from outside /root or use sudo -s.

For the user thing: man sudoers.

Last edited by Ramses de Norre (2008-11-15 16:52:55)

Offline

#4 2008-11-15 18:21:43

qdiesel
Member
Registered: 2008-05-19
Posts: 61

Re: sudo can't execute some commands[SOLVED]

try this
sudo sh -c "echo \"1234\"  >/etc/rc.local"

Last edited by qdiesel (2008-11-15 19:17:41)

Offline

#5 2008-11-15 23:08:45

creslin
Member
Registered: 2008-10-04
Posts: 241

Re: sudo can't execute some commands[SOLVED]

Have a look here, particularly the "Downsides of using sudo" section.


ARCH|awesome3.0 powered by Pentium M 750 | 512MB DDR2-533 | Radeon X300 M
The journey is the reward.

Offline

#6 2008-11-17 02:04:21

hungsonbk
Member
Registered: 2007-05-26
Posts: 105
Website

Re: sudo can't execute some commands[SOLVED]

Thank everybody,

I have read the downside of sudo and found that this is the problem of sudo and we need some hacks to work around it.

Thanks

Son Dinh

Offline

Board footer

Powered by FluxBB