Skip to main content
Quoting
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

If, for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown $"${USER:=$(/usr/bin/id -run)}:$USER$USER" "/var/www/$sitename$sitename"

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run.

If, for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$sitename

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run

If for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown "${USER:=$(/usr/bin/id -run)}:$USER" "/var/www/$sitename"

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run.

If, for some reason, $USER$USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER$USER variable, you can use the shell expansion to supply a default value. Change the chownchown line in your script to:

sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$sitename

If USERUSER is empty or unset when this is run, bash will set the USERUSER variable to the output of /usr/bin/id -run

If, for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$sitename

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run

If, for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$sitename

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run

Source Link
Tim Cutts
  • 446
  • 5
  • 5

If, for some reason, $USER is not set, you can use the id command to obtain the identity of the real user. So the first time you use the $USER variable, you can use the shell expansion to supply a default value. Change the chown line in your script to:

sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$sitename

If USER is empty or unset when this is run, bash will set the USER variable to the output of /usr/bin/id -run