Let $X$ be compact subset of $\Bbb R $ and the function $f : X \to \Bbb R$ is continuous then given $ \epsilon > 0$ show that there is $M>0$ such that for all $x, y \in X$ $ |f(x)-f(y)| \le M|x-y| + \epsilon$.
I tried by contradiction: suppose there is some $ \epsilon$ and $M_n$ a sequence of positive number such that $M_n \to \infty$ and for some $x'$ and $y'$ we have $ |f(x')-f(y')| \ge M|x'-y'| + \epsilon$. but from here i can not go further, guide me.
If you are given a continuous function on a compact subset in $\mathbf{R}$, you almost always want to pass to uniformly continuous. I'd even go as far as to say that for all cases, even when it might be unnecessary, just go for uniform continuous anyway.
So since $f$ is uniformly continuous, there is a $\delta > 0$ such that for $|x-y| < \delta$
$$| f(x) - f(y) | < \epsilon \le \epsilon + M' |x - y|$$
where $M'$ is any nonnegative number, trivially added on.
Now, let's suppose $x,y$ are outside of the delta ball, i.e. $|x - y| \ge \delta$. But $f$ is a continuous function on a compact subset so it is bounded (EVT) thus there is now a $N$ such that $|f(x) - f(y) | \le N$ for every $x,y \in X$. By taking $M' = \frac{N}{\delta}$, we are done, for
$$ |f(x) - f(y)| \le N = M' \delta \le M' |x - y| \le M' |x - y| + \epsilon$$