In this paper, we systematically study gravitational waves (GWs) first produced by remote compact astrophysical sources and then propagating in our inhomogeneous universe through cosmic distances, before arriving at detectors. To describe such GWs properly, we introduce three scales, λ, Lc and L, denoting, respectively, the typical wavelength of GWs, the scale of the cosmological perturbations, and the size of the observable universe. For GWs to be detected by the current and foreseeable detectors, the condition λ Lc L holds. Then, such GWs can be approximated as high-frequency GWs and be well separated from the background γµν by averaging the spacetime curvatures over a scale , where λ Lc, and gµν = γµν + hµν with ≡ λ/L, and hµν denotes the GWs. In order for the backreaction of the GWs to the background spacetimes to be negligible, we must assume that |hµν | 1, in addition to the condition 1, which are also the conditions for the linearized Einstein field equations for hµν to be valid. Such studies can be significantly simplified by properly choosing gauges, such as the spatial (χ0µ = 0), traceless (γ µν χµν = 0), and Lorentz (∇ ν χµν = 0) gauges, where χµν ≡ hµν − hγµν /2, and ∇ ν denotes the covariant derivative with respect to γµν . We show that these three different gauge conditions can be imposed simultaneously, even when the background is not vacuum, as long as the high-frequency GW approximation is valid. However, to develop the formulas that can be applicable to as many cases as possible, in this paper we first write down explicitly the linearized Einstein field equations for χµν by imposing only the spatial gauge. Then, applying these formulas together with the geometrical optics approximation to such GWs, we find that they still move along null geodesics and its polarization bi-vector is parallel-transported, even when both the cosmological scalar and tensor perturbations are present. In addition, we also calculate the gravitational integrated Sachs-Wolfe effects due to these two kinds of perturbations, whereby the dependences of the amplitude, phase and luminosity distance of the GWs on these perturbations are read out explicitly.