We give an explicit formula for the expectation of the number of real lines on a random invariant cubic surface, i.e., a surface Zsubset {mathbb {R}}{mathrm {P}}^3 defined by a random gaussian polynomial whose probability distribution is invariant under the action of the orthogonal group O(4) by change of variables. Such invariant distributions are completely described by one parameter lambda in [0,1] and as a function of this parameter the expected number of real lines equals: Eλ=9(8λ2+(1-λ)2)2λ2+(1-λ)22λ28λ2+(1-λ)2-13+238λ2+(1-λ)220λ2+(1-λ)2.\\documentclass[12pt]{minimal}\t\t\t\t\\usepackage{amsmath}\t\t\t\t\\usepackage{wasysym}\t\t\t\t\\usepackage{amsfonts}\t\t\t\t\\usepackage{amssymb}\t\t\t\t\\usepackage{amsbsy}\t\t\t\t\\usepackage{mathrsfs}\t\t\t\t\\usepackage{upgreek}\t\t\t\t\\setlength{\\oddsidemargin}{-69pt}\t\t\t\t\\begin{document}$$\\begin{aligned} E_\\lambda =\\frac{9(8\\lambda ^2+(1-\\lambda )^2)}{2\\lambda ^2+(1-\\lambda )^2}\\left( \\frac{2\\lambda ^2}{8\\lambda ^2+(1-\\lambda )^2}-\\frac{1}{3}+\\frac{2}{3}\\sqrt{\\frac{8\\lambda ^2+(1-\\lambda )^2}{20\\lambda ^2+(1-\\lambda )^2}}\\right) . \\end{aligned}$$\\end{document}This result generalizes previous results by Basu et al. (Math Ann 374(3–4):1773–1810, 2019) for the case of a Kostlan polynomial, which corresponds to lambda =frac{1}{3} and for which E_{frac{1}{3}}=6sqrt{2}-3. Moreover, we show that the expectation of the number of real lines is maximized by random purely harmonic cubic polynomials, which corresponds to the case lambda =1 and for which E_1=24sqrt{frac{2}{5}}-3.