Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to generate a script that will execute terminal commands through Apache(PHP).When i got to execute commands i don't have any root permissions to do so. even tho i am logged in as root.
Could someone help me out?
i think there is some sort of command you have to enter into php but i am not sure. . .
I'll put the usual warnings about running a web script which can do things as root here...be very, very careful!
Check the PHP shell_exec manual http://us2.php.net/shell_exec - some of the comments at the bottom are regarding script root access, and may help you out a bit.
I am trying to generate a script that will execute terminal commands through Apache(PHP).When i got to execute commands i don't have any root permissions to do so. even tho i am logged in as root.
Could someone help me out?
i think there is some sort of command you have to enter into php but i am not sure. . .
Many Thanx
Rich.
Hi, and welcome to LQ!
What are you trying to achieve, what command are you
invoking, what is the error message you're getting?
Cheers,
Tink
P.S.: I'd suggest that you let me move this to our
programming forum, better exposure there.
HI, i am at university we have a project to build a firewall in linux using iptables, basically all i wanted to do was execute bash commands in php. But i dont have the correct permissions?
If I knew which commands you're trying to execute from which
environment, maybe? And you told me what the exact error message
was ... maybe we could assess what the problem is. But with
the things you keep repeating: no.
Are you using PHP from the command-line or from within Apache?
If it's Apache: as what user is the service being run?
...
Look at using sudo. This will you specify the user Apache runs as, often www-data, to access various commands normally only accesible to the root user. As mentioned before, be careful what commands you allow, and ensure there's some kind of syntax validation within your PHP so that naughty code can't get passed to the shell. There's a host of debates as to what's the right way to do it from a security point of view! Otherwise, pretty easy to execute iptable commands. If you're wanting to do more, then again as mentioned before, tell us a bit more info.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.