Let G be a 2-torsion free unital generalized matrix algebra with center Z(G), and Φ be a linear mapping on G satisfying the condition X, Y ∈ G, XY = Y X = 0 ⇒ [Φ(X), Y ] = 0. This paper is devoted to the study of the structure of Φ under some mild assumptions on G. We provide the necessary and sufficient conditions for Φ to be in the form Φ(X) = λX + μ(X) (∀ X ∈ G), where λ ∈ Z(G) and μ : G → Z(G) is a linear mapping. Then we apply our results to characterize linear mappings on G that are commutant preservers or double commutant preservers.