Restore correct ownership on a domain folder and all its contents

INFO=($(MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin psa -sN -e'SELECT h.www_root,s.login FROM domains d, hosting h, sys_users s WHERE AND AND""')); chown -R ${INFO[1]}:psacln ${INFO[0]}; chown ${INFO[1]}:psaserv ${INFO[0]}

Starting from Plesk 17.8 it can be done easier

plesk repair fs

Check if the server is hosted on Google Cloud or AWS

  • AWS
    curl -Lso /dev/null && echo "Definitely AWS"
    if ((IWR -URI -UseBasicParsing) -ne $null) { echo "Definitely AWS" }
  • GCN
    curl -Lso /dev/null -H "Metadata-Flavor: Google" && echo "Definitely GC"

    PowerShell 3.0 or newer is required to send custom headers

    if ((IWR -URI "" -Headers @{"Metadata-Flavor"="Google"} -UseBasicParsing) -ne $null) { echo "Definitely GC" }

Show permissions for a file and all parent folders

function namei {
    If ( $args[0] -eq $null ) {
        $path = ($pwd).Path
    } Else {
        $path = $args[0]
    If ( -not (Test-Path -Path $path) ) {
        echo "Path does not exist"
    While ( $path -ne "" ) {
        $acl = Get-ACL -Path $path
        echo $path "`r`n"
            $acl | Select -Property Owner,Group | FL | Out-String
        $acl | Select -Expand Access | Select -Property FileSystemRights,AccessControlType,IdentityReference,IsInherited | FT
        $path = $path | Split-Path
namei C:\Windows