Can I ensure that every CentOS 7 has /etc/os-release file? - linux

I made a script, and it checks OS version in the beginning.
It reads /etc/os-release file, and checks whether the os is CentOS 7 or not.
But I'm not sure whether I can ensure that every CentOS 7 has that file.
Other OSs don't matter, but CentOS 7 matters.
Can I ensure this?
Is there any document about this?
Thanks :)

Yes, as you describe, the file /etc/os-release should do the work in any CentOS version, although you can also try to query the installed package centos-release, where you can find the same information: rpm -qi centos-release | grep Version

Related

Which linux flavor is running

I want to find out the linux flavor running on the vm created using minikube-kubernetes.
I log in to the vm and do a cat /proc/version
Linux version 4.9.13 gcc version 5.4.0 (Buildroot 2017.02).
Can someone tell me which flavor this is?
Obviously not ubuntu as none of the commands man, apt-get work.
cat /etc/*release
This works across most distributions.
The minikube distro is custom built using buildroot. It is meant to be a minimal distro and does not include a package manager or package repository.
https://github.com/kubernetes/minikube/tree/master/deploy/iso/minikube-iso
https://github.com/kubernetes/minikube/blob/master/docs/contributors/minikube_iso.md
lsb_release -ai but you might need to install lsb module.

Indication of when a minor rev level will increase after an OS patch

The question came up asking how a person would know if a minor rev level of a OS patch for Redhat would be known ahead of a patch. As an example, if a server is at RHEL 6.6 what would indicate that after a yum update was done the OS would be RHEL 6.7? Is there a package that would indicate if the minor version number would bump up?
Thanks,
Greg
This may be better asked on SuperUser but yes you should have a package called redhat-release or in my case centos-release which gives the current version information.
rpm -q centos-release returns centos-release-6-8.el6.centos.12.3.x86_64

Gitlab on suse linux

I want to install Gitlab on the suse linux OS.
Could some one please suggest me which OS supported Gitlab installer from the available ones on Gitlab site : Ubuntu, Debian and Centos can be used to install Gitlab on Suse linux ?
OS details :
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 4
I'm afraid that Suse is a complete different system. They use a package manager called YaST that won't be compatible with any of the proposed OS on the GitLab website.
Alternatively, you can try installation via Docker (Hopefully your system is 64bits):
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/docker
Or the hard way, manually:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md
Or even pop an instance somewhere in the cloud but this would involve some costs.
For all other OSs it has packages to install all the required components, but for SUSE there is no package, so you will have to install all the required components like ruby, redis, mysql and other dependent libs on your own.
You may like to try this :
https://gist.github.com/rriemann/5163741
or
https://gist.github.com/jniltinho/5565606
Since I found this answer while looking for the installation on SUSE 12 (SP3), there is one of the currently working options (2021).
First, check the version supported on the system, (Gitlab 12.1 in case of SUSE 12 SP3, which corresponds to OpenSUSE 42.3)
After that, get the proper .rpm file using wget.
Install with
sudo EXTERNAL_URL="http://gitlab.my.domain" rpm -ivh path/to/file/filename
That's it. Some Versions of Omnibus for SUSE are supported directly, but it really depends on the host system version.

check if my OS release is CentOS or not

using cat/etc/redhat-releasegives me output
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Is my OS release CentOS or not?
Secondly, How to check?
And upon searching I came to know that Santiago is codename for this distribution. Then how Santiago & centOS differs? are they related?
Check out /etc/issue to get additional branding/OS issue on RedHat based operating systems. This has been buggy in the past, so you can additionally check rpm -q centos-release or /etc/os-release.
Note that /etc/issue is meant to be read by the tty, so check out man agetty if you see lines like \S or Kernel \r on an \m and want to know what that means.
Santiago just is a release name for RHEL 6.2.
Finally, for even more information, check out lsb_release -a and you'll see lines for Distributor ID, and Description.

Determine Redhat Linux Version

How do I determine which RedHat Linux version I am running?
Here's what I've read:
/etc/redhat-release file contains the version, but anybody can tamper with that file.
people say uname command, but you can install any kernel on Redhat.
If I am running redhat 5.1 and someone upgrade it with 5.2 or 5.x, what determines the version of RedHat?
even lsb_release -a read /etc/redhat-release file.
Try this command:
rpm -qa | grep release
for instance on my machine I get this
redhat-release-workstation-6Workstation-6.4.0.4.el6.x86_64
If "anybody" has root access to your machine to either change /etc/redhat-release or install an alternate kernel you're most probably in bigger trouble than determining the redhat version of your system.
Just use the value pointed out by /etc/redhat-release or even better in terms of portability use the output of lsb_release as this is exactly the purpose they were made for.
With "anybody" being able to do anything with your system there is no other chance at all.
You can use the lsb_release command on recent linux distributions. If you issue:
lsb_release -i -r
Or
uname -r
And map the output. 2.6.9 kernels are RHEL4, 2.6.18 kernels are RHEL5. If necessary, you can map the full version to the specific update releases from Red Hat (i.e. 2.6.9-89 is RHEL5 U4).
Note: since July 2012, /etc/os-release should be the standard file where to look for the version of any OS.
It relieves application developers who just want to know the distribution they are running on to check for a multitude of individual release files.
It provides both a "pretty" name (i.e. one to show to the user), and machine parsable version/OS identifiers (i.e. for use in build systems).
It is extensible, can easily learn new fields if needed.
See its man page.
Example for RedHat:
# cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.0 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.0"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"
A trick working on numerous Linux distributions:
cat /etc/issue
Example on Red Hat 6:
$ cat /etc/issue
CentOS release 6.7 (Final)
Kernel \r on an \m
$
The most simple command is:
lsb_release -d
try
uname -r
or
cat /etc/issue
for recent linux machines
lsb_release -d
For folks who are reading this today, or in the future:
The kernel version that is RUNNING is your version of RedHat. There may be other versions installed, but not running.
Thus, if RedHat 5.1, 5.2 & 5.x are installed on the machine, only 1 can be running at a time. This is the version that was booted at system start uop.To determine which version is actually running, use the uname command:
uname -r
This returns the Kernel release number.
For RedHat 5, it will be 2.6.18-[something]
RH 5.1 is 2.6.18-53
RH 5.2 is 2.6.18-92
To translate kernel release numbers into Redhat Version numbers, see this link:
Red Hat Enterprise Linux Release Dates
The file /etc/redhat-release is standart way to get vendor version (including 5.X). I don't think you should ignore this way. Of course, you can use various tricks from other software to display the current version of OS, but anyway many of them are parsing the /etc files. As mentioned above you can use rpm query to get version. Another way to get such information: rpm -q <vendor-name>-release
BTW I agree with the commenters above that the way you knowing the version is the least of your problems if anyone can tamper with the standard /etc/redhat-release file or other system configuration files.
Additionally since RHEL 7.X versions you can also try hostnamectl | grep 'Operating System'

Resources