Under what conditions can we find a basis of a Lie algebra such that the adjoint representation acts by skew-symmetric matrices?
My question might be very silly as I've only recently started to learn about Lie algebras.
Given a Lie algebra $\mathfrak{g}$, and a vector space basis $\{e_i|i=1 \ldots \dim \mathfrak{g}\}$, we can write the adjoint action $\text{Ad}_x: \mathfrak{g} \to \mathfrak{g}: y \mapsto [x,y]$ in matrix form, where the $i,j$th entry of the matrix $[\text{Ad}_x]$ equals $\lambda_i$ if $[x,e_j] = \sum_{k}\lambda_k e_k$. I am looking for necessary and sufficient conditions on our Lie algebra $\mathfrak{g}$ such that there exists a basis in which all of these matrices $\{ [\text{Ad}_x]| x \in \mathfrak{g} \}$ are skew-symmetric.
If the condition turns out to be either simplicity of compactness of the associated simply connected Lie group, I would be very happy.
$\DeclareMathOperator{\tr}{tr}\DeclareMathOperator{\ad}{ad}$I will expand my comment here. I am assuming (though I am not sure if this is the case) that the OP is interested in real Lie algebras. If $\mathfrak{g}$ is the Lie algebra of a compact semisimple Lie group, then with respect to any orthonormal basis of $\mathfrak{g}$ with respect to (minus) the Killing form, the matrix representing $\operatorname{ad}_x \in \mathfrak{gl}(\mathfrak{g})$ is skew-symmetric, for any $x \in \mathfrak{g}$.
Define the Killing form $B(-,-): \mathfrak{g} \times \mathfrak{g} \to \mathbb{R}$ by:
$$B(x,y) = \tr(\ad_x \circ \ad_y).$$
I claim that for any $z \in \mathfrak{g}$, $B([z,x],y) + B(x,[z,y]) = 0$. For short, it is common to say that the Killing form is $\ad$-invariant.
$$ \begin{align*} & B([z,x],y) + B(x,[z,y]) \\ = & \,\tr(\ad_{[z,x]} \circ \ad_y)+ \tr(\ad_x,\ad_{[z,y]}) \\ = & \,\tr([\ad_z,\ad_x] \circ \ad_y) + \tr(\ad_x \circ \, [\ad_z, \ad_y]) \\ = & \,0 \end{align*}$$
by the cyclic property of the trace ($\tr(BCA) = \tr(ABC)$). I have also used the fact that $\ad_{[x,y]} = [\ad_x,\ad_y]$.
There is another fact from Lie theory that we need, namely that if $\mathfrak{g}$ is the Lie algebra of a compact semisimple Lie group, then its Killing form is negative definite.
Let us now choose an orthonormal basis of $\mathfrak{g}$, say $x_1,\ldots,x_n$, with respect to minus the Killing form. Note that, for any $x \in \mathfrak{g}$, we have
$$ -B(\ad(x)(x_i),x_j) = -B([x,x_i],x_j) = B(x_i, [x,x_j]) = B(x_i, \ad_x(x_j)).$$
Hence the matrix representing $\ad_x$ with respect to the orthonormal basis $x_1,\ldots,x_n$ is skew-symmetric.
Malkoun's beautiful answer shows that for a semisimple real Lie algebra, a sufficient criterion for such a basis to exist is that the Lie algebra is anisotropic, i.e. what in the real case is commonly called "compact", i.e. the corresponding Lie groups are compact.
I just want to point out that for semisimple real Lie algebras $\mathfrak g$, this is also necessary (as alluded to by Tsemo Aristide in the answer to this related question). Namely, if a real semisimple Lie algebra is not anisotropic (compact), then it contains elements $x \neq 0$ which are ad-diagonalisable, i.e. such that $ad(x)$ has non-zero real eigenvalues. However, all eigenvalues of real skew-symmetric matrices are purely imaginary, so there can be no basis of $\mathfrak g$ in which all $ad(x)$ are skew-symmetric.
Incidentally, Malkoun's answer can also be used to show that somewhat surprisingly, the result is true for all complex semisimple Lie algebras $\mathfrak g$. Namely, it is a classical cornerstone of the theory that for each such $\mathfrak g$ there exists a (unique) compact real form, i.e. an anisotropic real semisimple Lie algebra $\mathfrak g_0$ such that the scalar extension $\mathbb C \otimes\mathfrak g_0$ is isomorphic to $\mathfrak g$. Now take an orthonormal (real) basis $e_1, ..., e_n$ of $\mathfrak g_0$ w.r.t. its Killing form as per Malkoun's answer, and the matrices of all the adjoints to those elements will be skew-symmetric. Now all elements of $\mathfrak g$ are $\mathbb C$-linear combinations of elements of $\mathfrak g_0$, hence the matrices of all $ad(x), x \in \mathfrak g$ in the basis $1 \otimes e_1, ..., 1 \otimes e_n$ will be skew-symmetric (complex) matrices. (Note that what I wrote in my second paragraph does not contradict this, as complex skew-symmetric matrices can have all eigenvalues one could want, as long as they add up to $0$.)