/etc/lsb-release vs /etc/os-release - linux

I needed to find out what Linux distro I'm running by using bash. Found this page, which was very helpful.
However my system has two /etc/*-release files
/etc/lsb-release
/etc/os-release
It seems os-release has a little more info, but it looks that both of these files essentially do the same thing. Does anyone know what is the difference between them? While we are at it, what does lsb in lsb-release stand for?

The /etc/lsb-release file is a file that some, but not all, Linux distributions put there for older programs to use. The "lsb" refers to the Linux Standard Base, a project working to define a common set of standards for any Linux distribution to follow, including things like filesystem layout. However, that file, /etc/lsb-release, isn't part of the standard. It's an extra thing that some distributions use, but not all.
The /etc/os-release file is the standard, however. Any distribution based on systemd, including Red Hat Enterprise Linux, CentOS, Fedora, Gentoo, Debian, Mint, Ubuntu, and many others, is required to have that file. Distributions that don't use systemd may also have the file.
If you need a reliable way of detecting what distribution you're running on, your best bet will be to read the /etc/os-release file. If it's not there you can try running the program called lsb_release. But just ignore the /etc/lsb-release file.
You can read more about os-release here and here. And just for fun, take a look at all the different files that Linux distributions used to use!

Related

Basic set of libraries in chroot (fedora linux)

I'm running an old version of my linux distro (fedora, but this is not very relevant) and for reasons which are completely irrelevant I'm not in a position to update it. However I do need a newer version of gcc and some other libraries than those supplied by my old distro.
I could compile a newer gcc and all the other libraries of course but I thought the simplest way would be to install a minimal set of packages from the latest distro version to a directory and then just chroot there. This way I'd take advantage of the binary packages present in the newest distro and all the infrastructure around it (like dependency installation, etc.) and I wouldn't need to compile everything from source.
My question is this: if I only would like to be able to compile with the most recent gcc and run those programs, what is the minimal set of packages I need? Since we are talking about fedora, what is the minimal set of rpms (beyond glibc and gcc)? Note that I don't need any X environment, networking, or anything like that, only the most basic terminal tools.
The minimal set varies depending on your user needs and what you're linking with. What I do when making a chroot environment is have a look at the distro I want to chroot and see if they have a base rpm/deb package that kickstarts everything. Then I install that in the chroot. From there I add libraries and applications as needed.
For an example where I create a chroot for RHEL on Arch see http://www.zenskg.net/wordpress/?p=267

Executable working in solaris but not in linux

I have an executable in Solaris which when i migrate to linux doesn't work.
bash: ./client: cannot execute binary file
I came through some points that I need to recompile the code in linux to make it work, but the issue is I have only executable and no source code.
I wanted to decompile the code from executable in solaris, but couldn't find any decompiler in the environment
Can anyone suggest a way out. I am stuck here.
Help much appreciated.
There is no support for running a Solaris binary on Linux. Given the fact it seems the binary if for x86, your best option is to run it on a VM. Solaris is well supported on VirtualBox.

The format of linux version

How should I read the format for a linux distribution?
For example 2.6.18-274.3.1.el5
What is each number mean?
First the first three 2 6 18, I can find the answer here
http://en.wikipedia.org/wiki/Linux_kernel#Version_numbering
What about the rest?
Thank you
Actually what you seem to be showing is the output of uname -a which contains the identification string for a kernel and generally NOT the distribution of the Linux version.
In you specific case, this is for Redhat Enterprise (or Centos) version 5 probably 32-bit. The kernel version is 2.6.18 with sub-patch release 274.3.1.
For the more general case over different Linux distributions, I have found the performing the command:
cat /etc/*release
and then grep-ing out for the details is far more effective. Notice there is a wildcard, as the filenames are not the same between Linux distributions either.
However, as everything in differing Linux distributions, there is no ONE format.

How can I compile php-cgi binary using a custom glibc for suse enterprise linux out of cygwin?

Pretty straight to the point I think. Is this do-able?
Background: I'm doing this because I need to run php-cgi on suse enterprise 9 and can't get LD_PRELOAD or LD_LIBRARY_PATH to use other-than-system version of glibc.
php-cgi: /lib/tls/libc.so.6: version `GLIBC_2.7' not found
I downloaded 2.7 from here
http://rpmfind.net/linux/rpm2html/search.php?query=libc.so.6(GLIBC_2.7)
more precisely
ftp://rpmfind.net/linux/sourceforge/r/ro/roblinux/64-32_pkg/core/i686/glibc-2.7-2rt.i686.rpm
and unpacked it using rpm2cpio.
I need php-cgi because I can't install php and want to try JavaBridge for running php out of tomcat.
How can I compile php-cgi binary using a custom glibc for suse enterprise linux out of cygwin?
Pretty straight to the point I think.
No, a very confused and circuitous question.
First, cygwin has absolutely nothing to do with your question: it's for running UNIX programs on Windows, which is not at all what you are asking about.
Second, your question appears to be: "how do I run pre-build php-cgi binary on a system that has older glibc than the one php-cgi has been built on?", and not about compiling anything.
To that question, the answer is: you can't (easily) -- UNIX systems do not support forward binary compatibility (build on a new system, run on an older one). Only backward compatibility is supported (old dynamically-linked binaries continue to run on newer systems).
Your best approach is to try to build php-cgi on your system (which would eliminate its dependency on GLIBC_2.7. If you can't, you should still be able to run such a binary against unpacked glibc-2.7 build, if that binary doesn't re-exec itself. The way to do that, assuming you unpacked glibc-2.7 into e.g. /tmp/glibc-2.7 is something like:
/tmp/glibc-2.7/lib/ld-linux.so.2 --library-path \
/tmp/glibc-2.7/lib:/lib:/usr/lib \
/path/to/php-cgi <args>
(The library path above may need some adjustments to make the loader find all the required libraries.)
Update:
is it practical to compile stuff for my linux box in cygwin
It is possible, but significantly more pain then simply compiling on the linux box itself (and so isn't really practical). You appear to lack any reason to want to do that, other than mis-guided belief that cygwin solves all problems.

Is there any way to find out which Linux Distribution is used?

I would like to show the user some help on specific operations in my program of the form:
Please type "apt-get install foobar" to install the foobar feature.
Is there anything to do this or do i have to leave it to the user and offer a dozend choices from Red Hat, Suse, Debian/Ubuntu, Mandriva, Slackware, Gentoo ....
cat /etc/lsb-release
root#pierr-desktop:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.10
DISTRIB_CODENAME=intrepid
DISTRIB_DESCRIPTION="Ubuntu 8.10"
lsb_release -a might help on debian and apparented.
No, there is no generic way to find out which Linux distribution you are running on.
There is the lsb_release command, which is specified in the Linux Standard Base specification. But obviously this command is only present on LSB-compliant distributions, and many smaller or specialized distributions are not LSB-compliant. (For example, the distribution I am running on my FritzBox router is not.)
And if you are assuming an LSB-compliant distribution anyway, then why not simply package your application as an LSB package? That way it works the same on all LSB-compliant distributions.
You could give
cat /etc/issue
a try too
Given that Linux can be built starting with one system and morphed into another, you may not be able to tell precisely which it currently is. Some distribution provide the lsb tools if they are LSB compliant, so that might help.
Some distributions provide a file /etc/dist-release. For example, I have a file /etc/arch-release that is empty.
You might also execute:
uname -a
That might indicate the distribution the kernel was built for, but that might be a long shot. My Arch linux kernel has no mention of Arch, but I believe my Gentoo install indicates "Gentoo Linux".
Some tools can be indicative of the distribution, such as apt-get, rpm, emerge, but you can usually install those tools on other distributions as well.
You can do it for most well know distros(Redhat, Fedaora, Gentoo, Suse, Debian, Ubuntu), those have special files to identify the distribution and version. i.e. /etc/debian_version.
But it would be a tedious task for you to list out all the package and things but if you really want to be user friendly
try with cat:
cat /proc/version
but with uname is maybe better:
uname -a

Resources