Linux: Finding What Distro We Are Using
-
I'm confused - wouldn't you have to know what distro you're using to run those commands.
i.e. you can't run the
cat /etc/gentoo-release
command on Ubuntu, can you? and if you can, can you run it on another Linux family line?
-
@Dashrender said in Linux: Finding What Distro We Are Using:
I'm confused - wouldn't you have to know what distro you're using to run those commands.
i.e. you can't run the
cat /etc/gentoo-release
command on Ubuntu, can you? and if you can, can you run it on another Linux family line?
Of course you can. You simply get an error that there is no file.
the command is
cat
the parameter is the path and file name. -
root@jaredweb:[~] $ cat /etc/gentoo-release cat: /etc/gentoo-release: No such file or directory root@jaredweb:[~] $ cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) root@jaredweb:[~] $
-
@Dashrender said in Linux: Finding What Distro We Are Using:
I'm confused - wouldn't you have to know what distro you're using to run those commands.
i.e. you can't run the
cat /etc/gentoo-release
command on Ubuntu, can you? and if you can, can you run it on another Linux family line?
You have to know what to look for and look for it. Same with anything. How do you know that you are on Windows? You rely on look and feel, knowing ahead of time what it is. If you make a Linux desktop look just like Windows and answer to Windows commands, how would you determine that it is really Windows?
It's harder than it sounds.
You also have to know that it is Linux, what if it was AIX or HP-UX? At some point you just have to know what things look like and poke around.
A simple solution for Linux machines is to do this...
ls /etc/ | grep release
-
You can do this as well:
cat /etc/*release
And see the output of every file with the name all at once. But you might get more than you wanted.
-
Most distros will also give you a hint when opening a session (SSH, bash, getty etc). But it's nice to see such a summary, thanks.
-
@scottalanmiller said in Linux: Finding What Distro We Are Using:
You can do this as well:
cat /etc/*release
And see the output of every file with the name all at once. But you might get more than you wanted.
For exampels, CentOS 7 has 4 files that match.
root@jaredweb:[~] $ ls /etc/*release /etc/centos-release /etc/os-release /etc/redhat-release /etc/system-release
It would output this disaster
root@jaredweb:[~] $ cat /etc/*release CentOS Linux release 7.3.1611 (Core) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" CentOS Linux release 7.3.1611 (Core) CentOS Linux release 7.3.1611 (Core)
-
What can be done if you do not want to rely on a maybe like
cat /etc/os-release cat /etc/lsb-release
Is to write your own if/then script to find the data you need.
-
@Dashrender Yes that is generally true. However you usually are only going to have 2 options, redhat_release or debian as those are by far the two most common in use in any business environment.
also theos-release
seems to be very new for distros. It is not in my centOS 6.6 or 6.8 but is in my debian 8+, but not in a debian 5 server i have.
typing
cat /etc/os
then tab complete will get you possibilities with os in etc dir. If os-release isnt there it isnt.
so you cancat /etc/r
then tab complete to seeredhat-release
-
/proc/version usually has pertinent information across most systems.
Edit: I looked closer. It's just the OS name (RHEL/Ubuntu) and kernel version. Never mind.
-