Answer
$y=\dfrac{1}{2}-\dfrac{1}{x}+\dfrac{c}{x^2}$
Work Step by Step
Here, we have $x \dfrac{dy}{dx}+2y=1-\dfrac{1}{x}$ ...(1)
or, $\dfrac{dy}{dx}+\dfrac{2y}{x}=\dfrac{1}{x}-\dfrac{1}{x^2}$
The integrating factor is: $v(x)=e^{\int (2/x) dx}=x^2$
In order to determine the general solution, multiply equation (1) with the integrating factor and integrate both sides.
$ x^2 \dfrac{dy}{dx}+2xy=x-1$
and $\int (x^2y)' dx=\int (x-1) dx$
or, $x^2y=\dfrac{x^2}{2}-x+c$
Thus, the general solution is as follows:
$y=\dfrac{1}{2}-\dfrac{1}{x}+\dfrac{c}{x^2}$