  Standard dynamical system analysis of Einstein-Maxwell equation in $f(R)$
theories is considered in this work. We investigate cosmological dynamics of a
uniform magnetic field in the Orthogonal Spatially Homogeneous (OSH) Bianchi
type I universe with viable $f(R)$ models of gravity. In this work, the $f(R) =
R -\alpha R^n$ and $f(R) = \left( R^b - \Lambda\right)^c$ models are examined
by using our dynamical system analysis. Our results show that both of two
$f(R)$ models have a viable cosmological consequence identical to the analysis
present in Ref.\cite{Amendola:2007nt} for the FLRW background. Contrary to
Ref.\cite{Amendola:2007nt}, we discover in our models that there is an
additional anisotropic and non-zero cosmological magnetic fields fixed point
emerging before the present of the standard matter epoch. This means that the
universe has initially isotropic stage with the intermediated epoch as the
anisotropic background and it ends up with the isotropic late-time
acceleration. The primordial magnetic fields play a crucial role of the shear
evolutions obtained from these two models which have the same scaling of the
cosmic time as $\sigma\sim t^{-\frac13}$, instead of $\sigma\sim t^{-1}$ for
the absence of the primordial magnetic cases.
