orugari
orugari

Reputation: 426

php shell_exec() change user or navigate to user folder

I would like to know if it was possible to use shell_exec as an other user. The point is to access directly to the user folder (in home/user/)

Or, is it possible to navigate from var/www/ to home/user/ folder using shell_exec?

Thank you for your help!

Upvotes: 2

Views: 1727

Answers (2)

Alok Patel
Alok Patel

Reputation: 8022

Yes you can. You can change directory with cd command inside shell_exec(). But make sure you write subsequent commands in the same line after putting ;

Like this,

shell_exec("cd .. ; pwd");

Above function will move directory to current's parent directory and display present working directory.

Upvotes: 3

LF-DevJourney
LF-DevJourney

Reputation: 28529

just like the shell command.

`cd /home/user && you command`

'``'is similar to shell_exec in php

Upvotes: 1

Related Questions