Below is the command I tried executing, without success:
exec(\'ln -s \' . PLUGIN_DIR . \'/.htaccess \' . ABSPATH . \'/.htaccess\');
When y
This in not a direct answer to your question, but is very useful, if you want to know what exactly happened by returned error code.
If error code ($res), returned by command:
exec('command', $out, $res);
was in range 1-2, 126-165, 255, than it was returned by shell (eg. BASH) invoked from PHP (to execute your command). If returned code is not in this range, than it was returned by your command (not shell).
See (for BASH error code descriptions)
https://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/exitcodes.html