Adding vertical ticks at nodes on a horizontal like drawn with TikZ

I have the following minimal code

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[solid, thick]
(0,0) node [below]{0}
-- (2,0) node [below]{$n-k$}
-- (6,0) node [below]{$n$};
\end{tikzpicture}

\end{document}


This creates the image below:

How can I get short vertical tick marks at the nodes? By this I mean, how can I get the image to appear like the one below?

Note that the red colour is not necessary but it was just added to the image to make the desired result easier to understand.

The next code

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[solid,thick] (0,0) -- (6,0);
\draw[thick] (0,0.2) -- ++ (0,-0.4) node[below] {0};
\draw[thick] (2,0.2) -- ++ (0,-0.4) node[below] {$n-k$};
\draw[thick] (6,0.2) -- ++ (0,-0.4) node[below] {$n$};
\end{tikzpicture}

\end{document}


produces:

You can draw tick in the \foreach loop:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (6,0);
\foreach \i/\j in {0/0, 2/n-k, 6/n}
\draw[draw=red] (\i,0.2) -- ++ (0,-0.4) node[below] {$\j$};
\end{tikzpicture}
\end{document}