What is the difference between linear and non-linear filters?
To understand the linearity property more easily.Let us consider the above diagram,here we have 2 sequences namely Xn and Yn. when we add both the sequence we get Xn+Yn whose amplitude value are represented with blue colour. when any system which satisfy this condition then it is called linear. 
In case of mean filter, mean value for sequence Xn is 1+1+3/3=5/3.mean value for sequence Yn is 1+2+0/3=1.mean value for Xn+Yn is 2+3+3/3=8/3.

$ mean(Xn)+mean(Yn)= mean(Xn+Yn), \\ \\
 5/3    +    1   = 8/3 $

hence we called mean filter as linear filter.
In case of median filter, if we calculate median value for sequence Xn, we get 1 (arrange the sequence in ascending order and then find the middle value). similarly median value of sequence Yn is 1 .median value of sequence Xn+Yn is 3. 

$median(Xn)+median(Yn)  \neq  median(Xn+Yn).\\ \\
1 + 1  \neq    3 $

hence we call median filter as non-linear filter