Answer
$$y= 1+4e^{-\tan x }$$
Work Step by Step
Given
$$y^{\prime} \cos ^{2} x+y-1=0 \quad y(0)=5$$
Rewrite the equation as the following
\begin{aligned}
y^{\prime} +\frac{1}{\cos ^{2} x}y&=\frac{1}{\cos ^{2} x} \\
y^{\prime} +(\sec^2 x)y&=\sec ^{2} x\\
\end{aligned}
This is a linear equation with
$$ p(x) =\sec^2 x,\ \ \ \ \ \ \ q(x) =\sec^2 x$$
The integration factor
\begin{aligned}
u(x) &=e^{\int p(x)dx}\\
&= e^{\int \sec^2xdx}\\
&=e^{\tan x }
\end{aligned}
Hence the solution given by
\begin{aligned}
u(x) y&= \int u(x) q(x) dx\\
e^{\tan x } y &= \int \sec^2 xe^{\tan x }dx\\
e^{\tan x } y &= e^{\tan x }+c
\end{aligned}
At $x=0$, $y=5$, then
\begin{aligned}
5 &= 1+c\\
c&=4
\end{aligned}
It follows that
\begin{aligned}
e^{\tan x } y &= e^{\tan x }+4\\
y&= 1+4e^{-\tan x }
\end{aligned}