executing linux sudo command in php web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yasantha
Forum Newbie
Posts: 1
Joined: Wed Jul 29, 2009 1:06 am

executing linux sudo command in php web page

Post by yasantha »

I want to view disk information in a PHP page by executing fdisk -l command in PHP page. But only the super user can run this command.Is anyone know how to execute this command for non super user
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: executing linux sudo command in php web page

Post by VladSun »

An example:

/etc/sudoers

Code: Select all

Cmnd_Alias      NETWORKING = /bin/ping, ifconfig [0-9]* eth0
 
root    ALL=(ALL) ALL
www-data ALL=NOPASSWD:NETWORKING

Code: Select all

sudo ping localhost -f -c4
sudo ifconfig 192.168.0.1 eth0
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply