-1

If I run df -h command in the terminal, it is returning with:

udev            1,5G     0  1,5G   0% /dev
tmpfs           312M  2,0M  310M   1% /run
/dev/sda1       109G  7,8G   96G   8% /
tmpfs           1,6G   29M  1,5G   2% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           1,6G     0  1,6G   0% /sys/fs/cgroup
/dev/loop0       36M   36M     0 100% /snap/gtk-common-themes/1198
/dev/loop2       90M   90M     0 100% /snap/core/6673
/dev/loop1       68M   68M     0 100% /snap/sublime-text/51
/dev/loop3       68M   68M     0 100% /snap/sublime-text/58
/dev/loop4      190M  190M     0 100% /snap/gitkraken/138
/dev/loop5      137M  137M     0 100% /snap/termius-app/29
/dev/loop6       54M   54M     0 100% /snap/core18/782
/dev/loop7       54M   54M     0 100% /snap/core18/941
tmpfs           312M   20K  312M   1% /run/user/122
tmpfs           312M   44K  312M   1% /run/user/1000
/dev/sdb2       112G   23G   89G  21% /media/benadzs/E4C0DB03C0DADB3E

But I want running it from PHP shell, but it is not seeing /dev/sdb2. The file has root permission.

Zain Farooq
  • 2,956
  • 3
  • 20
  • 42
benadzs
  • 127
  • 2
  • 13
  • try a whoami and compare with $bla = shell_exec('whoami'); echo "
    ". $bla ."
    "; to see the executing user, cause executed in php you may execute it as a different user e.g. www-data
    – FatFreddy Apr 16 '19 at 09:33
  • the terminal returned with "benadzs", the php file returned with "www-data". so it is the problem? edit: a try to open /media/benadzs with scandir, but i can't. permission denied – benadzs Apr 16 '19 at 11:14
  • i think so, well at least to compare the two results you have to execute the command with the same rights – FatFreddy Apr 16 '19 at 11:32
  • i tried to set the chown to "benadzs" but i can't. have can i set the chown to benadzs to the file? – benadzs Apr 16 '19 at 11:39
  • the owner of the file doesnt matter, you should execute the command as sudo , have a look at https://unix.stackexchange.com/questions/79927/how-to-execute-php-file-as-different-user-securely and https://stackoverflow.com/questions/6913403/running-command-line-application-from-php-as-specific-user – FatFreddy Apr 16 '19 at 12:09

1 Answers1

1

www-data ALL=(ALL:ALL) NOPASSWD:ALL
I paste it to the visudo and now it is working.

benadzs
  • 127
  • 2
  • 13