cat /etc/os-release and
hostnamectl. Both contain Fedora in some way. Which is the official, preferred way?
$ lsb_release -is Fedora $ lsb_release -rs 37 $ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: Fedora Description: Fedora release 37 (Thirty Seven) Release: 37 Codename: ThirtySeven $
I don’t think there is an “official way”. There are whole bunch of different ways though.
I think that
/etc/os-release is probably the most universal way.
hostnamectl takes the value of
PRETTY NAME from
/etc/os-release anyway. I’d suggest using
/etc/os-release, since it’s shipped by the different release packages.
I usually go with
cat /etc/redhat-release or
hostnamectl are not available on all UNIXes, not even on all Linuxes.
os-release sounds like the safest bet.