75

I'd like to be able to detect which particular Linux flavor is installed on a computer, e.g., Ubuntu vs. Fedora, via a command line command.

Some people recommend uname -a, but that only reports the kernel version.

1

6 Answers 6

121

Try the below command.... It worked for me...

cat /proc/version 

Once you know that you are running Red Hat for example, you can get to the point with:

cat /etc/redhat-release 

Or on Debian:

cat /etc/debian_version 

or in general :

cat /etc/*-release 

Also you could use the following command

cat /etc/issue 
Sign up to request clarification or add additional context in comments.

2 Comments

cat /etc/*-release is it work on all Linux flavours? like Cent OS, Ubuntu, Debian etc.
It should work ...but it doesn't then try other options that I have provided.
25

For displaying details including release and codename of the distro

lsb_release -a 

3 Comments

Doesn't work for Red Hat Enterprise Linux Server release 7.6 (Maipo)
... or Arch Linux.
Does cat /etc/os-release work?
7

cat /etc/os-release is the command that worked for me. It displays information in the following format:

NAME="Linux Mint" VERSION="21.1 (Vera)" ID=linuxmint ID_LIKE="ubuntu debian" PRETTY_NAME="Linux Mint 21.1" VERSION_ID="21.1" HOME_URL="https://www.linuxmint.com/" SUPPORT_URL="https://forums.linuxmint.com/" BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/" PRIVACY_POLICY_URL="https://www.linuxmint.com/" VERSION_CODENAME=vera UBUNTU_CODENAME=jammy 

As ddelange and Stuart mentioned in the comments, you can also use it like this:
source /etc/os-release && echo $UBUNTU_CODENAME
which outputs:
jammy
and source /etc/os-release && echo $ID_LIKE
which outputs:
ubuntu debian

2 Comments

a handy shorthand: source /etc/os-release && echo $UBUNTU_CODENAME
sourcing & echoing $ID_LIKE seems reliable for the flavour
3

You can try:

echo $(lsb_release -si) 

3 Comments

Doesn't work for Red Hat Enterprise Linux Server release 7.6 (Maipo)
Why would you need to echo a subshell output, isn't that redundant?
@nomæd Yes, do lsb_release -si, echo is useless
0

Try hostnamectl. It lists the operating system, CPE OS Name, Kernel, Architecture, etc.

1 Comment

only for systemd based systems :)
0

Use command to know the name of the os:

cat /etc/*-release 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.