I can't find 'fdinfo' in the /proc file system - linux

I've read about the great uses of /proc/<pid>/fd and specifically fdinfo in this article.
But I can't find it on my Linux system: Red Hat Enterprise Linux ES release 4, kernel 2.6.9.
Where can I find the missing fdinfo ?

The article clearly says, "All of these tricks should work on a recent Linux kernel, though some will fail on older systems like RHEL version 4." As you can see, fdinfo is not available on your system.

/proc/<pid>/fd is present in Linux since 2.6.22 kernel version. You may want to upgrade your kernel.

Related

Can I upgrade my kernel with a kernel for an other distribution?

I have a raspberry on Raspbian and a vm on Kali linux.
My question is simple :
Kali is based on Debian.
Kali last kernel is 4.19 but Debian last kernel is about 4.9.
So, can I add debian sources.list to my Kali and upgrade my kernel to Debian 4.9 ?
I tried and it seems to work.
Is the upgrade of kernel possible only with distributions that have the same packet manager (yum, apt...) ?
Thanks !
Proc
Yes, since as you noted both are based on the Debian distro. Sticking with the same distro and package manager is the safest route. While many distros offer interoperability options (e.g. Alien) the conventional wisdom is summed up rather well here:
Because different distribution families use different packaging systems (Debian: *.deb / CentOS: *.rpm / openSUSE: *.rpm built specially for openSUSE), a package intended for one distribution will not be compatible with another distribution. However, most distributions are likely to fall into one of the three distribution families covered by the LFCS certification.
From https://www.tecmint.com/linux-package-management/
Also, a handy super-reference for distros and packaging: Distrowatch

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

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!

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.

which version of linux kernel starts to support sd/sdio version 3.00?

--Hello there,
Here is a question about linux kernel sd/mmc subsystem.
At present, the version of linux kernel we use is 2.6.29.4.
Now, there is a SD/MMC controller which supports SD/SDIO version 3.00 integrated into the SoC, so, we need to update linux kernel to support SD/SDIO version 3.00.
Does anybody know from which version linux kernel starts to support SD/SDIO version 3.00?
Or, are there any ways to achieve our goal?
Thanks in advance.
For future reference, you can always quickly answer to this and similar questions by searching in kernel source. Most useful commands are git grep and git log -S<symbol>.
Just clone kernel source code:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
and then run command like this to find what you want:
git log -SSDIO_SD_REV_3_00
Which gives following result (just one commit!):
commit a303c5319c8e6ab0e744ebca118da8420043b2c3
Author: Philip Rakity <prakity#marvell.com>
Date: Mon Nov 14 19:14:38 2011 -0800
mmc: sdio: support SDIO UHS cards
This patch adds support for sdio UHS cards per the version 3.0
spec.
...
Now, you can use git describe to get kernel version closest to that commit:
git describe --contains a303c5319c8e6ab0e744ebca118da8420043b2c3
which prints:
v3.3-rc1~72^2~51
In other words, it became official in kernel version 3.3.
The Linux Kernel version 3.3 starts the support of SD/SDIO version 3.00.
See this commit
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/include/linux/mmc/sdio.h?h=linux-3.3.y&id=b4625dab2c618eb87e177761dda3182b4cfaa604
Kernel 3.3 (found the SDIO_SD_REV_3_00 define)
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/include/linux/mmc/sdio.h?h=linux-3.3.y
Kernel 3.2 (NOT found the SDIO_SD_REV_3_00 define):
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/include/linux/mmc/sdio.h?h=linux-3.2.y

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