Geometric condition for linearity In Are linear transformations precisely those that keep lines straight and the origin fixed?, @Leo asks whether a full-rank transformation of $\Bbb R^n$ to itself that sends parametric lines to parametric lines and fixes the origin must in fact be linear. I want to look at a somewhat weaker condition. 
Suppose that for some $n \ge 2$, $f:\Bbb R^n \to \Bbb R^n$ is surjective and "maps lines to lines" in one of the two following senses:


*

*For every line $L$, $f(L)$ is a subset of some line, or

*For every line $L$, $f(L)$ is (setwise) equal to some line.


Here "line" means "a straight line", not "a straight line through the origin", i.e., $L$ is a line if there's a nonzero vector $v$ and a point $P$ such that 
$$
L = \{ P + tv \mid t \in \Bbb R \}.
$$
Must $f$ then actually be a linear transformation? 
In the related question, @don-joe shows that for $n = 1$, $f$ need not be a linear transformation (basically making it the identity for negative $x$, and the doubling function for nonnegative $x$; this maps the only line setwise to itself, but is not linear). So the only hope is that the $n \ge 2$ condition allows some sort of "rigidity" to help out. 
I'd like to think that the conjecture is true for sense 1 (because of surjectivity), but I'd be happy even if it were true for sense 2. I've played a little with this question in the past, making no real progress, and not really being careful about how I phrased it, so the related question prompted me to try to clean up the question itself and see whether someone else knows an answer. 
 A: a few thoughts
$$
\newcommand{\bu}{{\mathbf u}}
\newcommand{\bv}{{\mathbf v}}
\newcommand{\be}{{\mathbf e}}
$$
Let's work in the case $n = 2$, because it probably tells the whole story. 
Let $K = \Bbb R^2 - \{(0,0)\}$ be the punctured plane, and let $H = f^{-1}(K)$ be its preimage. 
There are vectors $\bu, \bv \in H$ with $f(\bu) = \be_1, f(\bv) = \be_2$, by surjectivity. That means that $f(c \bu) \in span(\be_1)$, i.e., the $x$-axis, for any real $c$ (because the line from $0$ through $\bu$ must map to within the line through $f(0) = 0$ and $f(\bu) = \be_1$). 
If $\bv \in span(\bu)$, then $f(\bv)$ would have to be in the $x$-axis, which it's not. So (repeating the argument in the other direction), $\bu$ and $\bv$ are independent. 
There's a linear transformation $S$ from the plane to itself, taking $\be_1$ to $\bu$ and $\be_2$ to $\bv$, and the function 
$$
g: \Bbb R^2 \to \Bbb R^2
$$
define by $g = f \circ S$ is a function with all the properties $f$ had (surjective, fixes 0, preserves lines), and $g(\be_i) = \be_i$ for $i = 1, 2$. 
Summary
We might as well assume that in addition to its other properties, $f$ fixes the $x$-axis and the $y$-axis setwise, and the unit points $\be_1$ and $\be_2$ on those axes, pointwise, and that the goal is now to prove that $f$ is the identity. 
The next idea is to show (perhaps by treating the point $P = (a, 0)$ (for $a \ne 0$) as lying on the $x$-axis and on the line from $e_2$ through $P$) that each other point on the axes must be fixed by $f$ as well. And then we'd show that off-axis points are fixed by $f$, too, perhaps by something like dropping perpendiculars to the two axes. 

Digression. 
@Piquito suggests a counterexample:

The function $f$ such that to every straight line $$ associate,
  through a bijection, the perpendicular to $$ that passes through the
  origin and whose restriction to a fixed line $_0$ coincides with the
  identity, it should not be difficult , I guess, to show that it is not
  linear nor continuous.

If I read this correctly, we can pick $L_0$ to be the line $x = 1$. Let's see what happens to a line of the form $y = c$ for some constant $c$. 
Well, it intersects $L_0$ at $(1, c)$, so the rule above says to rotate it 90 degrees (making it vertical), but leaving the point $(1, c)$ fixed. Well, the only vertical line containing $(1, c)$ is the line $x = 1$. We conclude that every horizontal line is sent by this map entirely within the line $x = 1$, so the map is not surjective. (I actually believe that the map is not well-defined, but I don't need to show that to demonstrate that it's not a counterexample to the claim.) 

