0

I have com across the Situation, that I need to replace all index.php files in direct subdirectories with a symlink to an index php in an repository. This is the structure of my directory.

-
|__ _base
|   |__index.php
|
|__ foo.something
|   |__ index.php
|
|__ bar.something
    |__ index.php

now have to replace the index.php file in foo.something and bar.something with a symlink linking to the index.php in _base.

I however have to runn the command as a specific user on the server. So i tried:

runuser -u username <<'EOF'
> for directory in ./*.something; do
>  echo $directory
>  ln -sf ../_base/index.php ./$directory/index.php
> done
> EOF

However that throws the error "no command found". I may put the commands in a script and execute it with superuser, still I am curious of I just missused runuser, or if there is an other solution as I am fairly new to working with bash.

  • 1
    Can you attach whole log? runuser might not be present on your system. If that's the case - try replacing runuser with su, as explained here: https://stackoverflow.com/questions/17758235/how-to-execute-a-group-of-commands-as-another-user-in-bash – Andrew Mar 11 '21 at 08:31
  • yeah, that was the problem! I am still failry new to the server wolrd! Thanks for helping out! – Konzertmeister Mar 11 '21 at 08:37

0 Answers0