I was wondering what is the F test (in general) that is done by the function $\texttt{lm()}$ in R.
I mean you can do different F tests, which one does it chose and how? For instance in a linear regression setting, I can fit a certain model with $\texttt{lm()}$ , but (before running the code) how do we know against which model it will be compared to?
For instance my model here is of the form $$Y_i= \beta_0+\beta_1x_{i1}+\beta_2x_{i2}+\beta_3x_{i1}^2+\beta_4x_{i2}^2+\beta_5x_{i1}x_{i2}+\epsilon_i$$ but, before running this code, what F-test could I have expected to get out of $\texttt{lm()}$? And what test (here) has actually been performed?

By default it tests the full model against the null model which includes intercept only, i.e., $$ H_0: \beta_1 = \beta_2 =... = \beta_p=0. $$ Let $SSreg(F)$ be the sum of squares of the full model, i.e., $\sum(\hat{y}_i - \bar{y}_n)^2$, where each $y_i$ is fitted using all the $p$ explanatory variables. Let $SSreg(R)$ be the sum of squares of the restricted model, i.e., $\sum(\hat{y}_i - \bar{y}_n)^2$ where each $y_i$ is fitted using only a subset of size $q$, $q< p$ of the explanatory variables. And the MSE is the unbiased estimator of $var(\epsilon) = \sigma^2$ that is given by $\frac{1}{n-p-1}\sum (\hat{y}_i - \bar{y}_n)^2$. Thus, the $F$ statistic is calculated by
$$ F_{stat}=\frac{(SSreg(F) - SSreg(R))/p}{MSE}. $$ However, because for the null (restricted) model with an intercept only, you get $\hat{y}_i = \bar{y}_n$ for all $i$, thus $SSreg(R)=\sum ( \hat{y}_i - \bar{y}_n)^2=0$, thus under $H_0$ you have $$ F_{stat} = \frac{MSreg}{MSE} \sim F(p, n-p-1), $$ where $MSreg = SSreg(F)/p$.