Thursday, March 21, 2019

.bash_aliases set permissions for web directories

# Copy the following and paste into bottom of: /home/username/.bash_aliases

web-dir() {
  if [ $UID -ne 0 ]; then
    if [ -d "$1" ]; then
        sudo find "$1" -type f -exec chmod 664 {} \;
        sudo find "$1" -type d -exec chmod 775 {} \;
    else
        echo "DIR not found"   
    fi
  else    
    if [ -d "$1" ]; then
        find "$1" -type f -exec chmod 664 {} \;
        find "$1" -type d -exec chmod 775 {} \;
    else
        echo "DIR not found"   
    fi
  fi       
}

# The above Linux script will set folder permissions so group www has read/write....

#.bashrc should have: umask 0002

# usermod -g www-data MYUSERNAME

No comments:

Post a Comment