Commands are not working even when I tried to give permissions
This means the php not set as a Environment Variable.
So it must be tried with a full path with php:
/opt/lammp/bin/php
Reference
Run this in SSH:
which php
And then provide the full path e.g.:
/usr/bin/php bin/magento
Replace the /usr/bin/php
with the result of which php
command