Step 1. Open the terminal.
Step 2. Login through the SSH
ssh {user_name}@{host_name}
Step 3. Press Enter then it will ask for the Password after entering the Password you will be logged in.
Step 4. Navigate to the folder/file for which you want to change the permission as well as the owner/group
Change the file and folder permission
chmod 777 {folder/file name}* -R chmod 777 media* -R
-R means recurcively it will change the permission of all the files as well as the folder of the media folder.
Change the file and folder owner and group
chown -R {owner name}:{group name} {folder/file name} chown -R {owner name}:{group name} media
then it will change the owner and group of the media folder.
Hope this will help to someone.