From now on it will be assumed that the name of the Gazebo user is USERNAME
and that its home directory is /home/USERNAME.
Thus USERNAME should be replaced with the corresponding user name.

first step

is to create the directory where the material file and textures will be stored.
In this tutorial the directory '~/.gazebo/' will be used.
Feel free to use any other directory, but make sure to make the corresponding changes in further steps.

Make sure that /home/USERNAME/.gazeborc exists (do not mistake ~/.gazeborc for ~/.gazebo), and has USERNAME as its owner:

If it does not exist it, write the following lines inside it using the unprivileged user that will run gazebo:

second step

Textures will be placed in '.gazebo/Media/materials/textures/' , and the gazebo material file must be placed in '.gazebo/Media/materials/scripts/' .
After storing the texture files in the textures directory and filling the Gazebo.material file, the .gazebo/ directory should look like this: