What's the meanning of the options of linux command `uname`? - linux

From man uname:
-a, --all
print all information [...]
-m, --machine
print the machine hardware name
-p, --processor
print the processor type or "unknown"
-i, --hardware-platform
print the hardware platform or "unknown"
in my computer:
[liwm29#VM-12-11-centos bc_sns]$ uname -p
x86_64
[liwm29#VM-12-11-centos bc_sns]$ uname -m
x86_64
[liwm29#VM-12-11-centos bc_sns]$ uname -i
x86_64
I don't know the difference between them

Related

How to configure Ftrace on kernel 5.15.0-56-generic (ubuntu 22.04)?

I'm trying to configure and enable ftrace on my ubuntu machine but its doesn't work. I also tried the instructions from the link here. I'm sure I'm missing something minor but I can't tell what.
Configuration:
$ cat /boot/config-5.15.0-56-generic | grep CONFIG_FUNCTION_TRACER
CONFIG_FUNCTION_TRACER=y
$ cat /boot/config-5.15.0-56-generic | grep CONFIG_FUNCTION_GRAPH_TRACER
CONFIG_FUNCTION_GRAPH_TRACER=y
$ cat /boot/config-5.15.0-56-generic | grep CONFIG_STACK_TRACER
CONFIG_STACK_TRACER=y
$ cat /boot/config-5.15.0-56-generic | grep CONFIG_DYNAMIC_FTRACE
CONFIG_DYNAMIC_FTRACE=y
$ uname -a
Linux <redacted> 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Enable tracing (with root user)
$ echo function > /sys/kernel/debug/tracing/current_trace
$ echo do_sys_open > /sys/kernel/debug/tracing/set_ftrace_filter
$ echo 1 > tracing_on
debugfs is already mounted:
$ mount
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
After enabling the tracing I was expecting to see the traces in /sys/kernel/debug/tracing/trace or /sys/kernel/debug/tracing/trace_pipe files but I didn't see any traces.
Update: Instructions to generate the traces are working as expected. I was able to generate the traces successfully for do_sys_openat2 but with do_sys_open I don't see any traces.

udev rules for sd* and dm-* device not working as expected

# cat /etc/oracle-release
Oracle Linux Server release 7.8
uname -a
Linux 3.10.0-957.el7.x86_64 #1 SMP Thu Oct 4 20:48:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
cat 99-custom.rules
ACTION!="add|change", GOTO="rule_end"
ENV{ID_VENDOR}=="NETAPP*", RUN+="/bin/sh -c 'echo 4096 > /sys%p/queue/max_sectors_kb'"
LABEL="rule_end"
----2nd option using KERNEL option just for dm-* devices
ACTION!="add|change", GOTO="rule_end"
KERNEL=="dm-[0-9]*",ENV{ID_VENDOR}=="NETAPP*", RUN+="/bin/sh -c 'echo 4096 > /sys%p/queue/max_sectors_kb'"
LABEL="rule_end"
udevadm control --reload-rules && udevadm trigger
/sbin/udevadm trigger --type=devices --action=change
Issue : We don't see udev rule applied to all dm-* device
/sys/block/dm-19/queue/max_sectors_kb:512
/sys/block/dm-9/queue/max_sectors_kb:512
We even tried to remove ENV{ID_VENDOR}=="NETAPP*" from rule
What we need to apply max_sectors_kb to 4096 to all dm-* ( multipath devices )
and all sd* devices can be left default of 512
Any idea what could be wrong ?

How do I know what linux kernel version does a distribution use?

When I run
uname -r
I get 3.2.0-4-686-pae on my Debian7 and 4.4.26-gentoo on my Gentoo.
But what I can't find anywhere is what Linux kernel source versions do these distributions use. If I understand right all distributions take the kernel source code from here https://www.kernel.org. So how can I find out what Linux kernel versions from the site do use 4.4.26-gentoo or 3.2.0-4-686-pae, for example?
Try man uname and find -v for the kernel version used. ;)
So it is uname -v or uname -a if you just dont care about specifics and want to see it all. :p
$ uname -v
#1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19)
$ uname -a
Linux Phobos 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
Check out the difference between the uname -r part and the uname -v part in uname -a (the first version number in -a)
$ uname -r
3.16.0-4-amd64
you have some way to know linux kernel version :
good way
uname -r
bad way to see kernel version ( you should see version of vmlinu* initrd files if they have version number of kernel )
ls /boot | grep "vmlinu*"; ls /boot | grep "initrd*"
you can try this way to know all of kernel versions on your machine :
ls /lib/modules/
uname -r is the easiest way.
though there are utilities like screenfetch or neofetch that give you more information in a clear and pretty manner.
Just run screenfetch and it'll display details.
(screenfetch is usually pre-installed on most distros these days).
If it is not installed, just run sudo apt install screenfetch (on debian based distros like ubuntu) or sudo pacman -S screenfetch ( on Arch based distros.
If you are looking for original Linux kernel version that matches browse-able
https://elixir.bootlin.com/linux/vx.y.z/
or LINUX_KERNEL_CODE you check when developing kernel code, "uname" is not the right answer!
There are two methods (I use my Ubuntu 16.04 as example):
dmesg
dmesg | grep "Linux\ version"
[ 0.000000] Linux version 4.4.0-210-generic (buildd#lgw01-
amd64-009) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-
6ubuntu1~16.04.12) ) #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021
(Ubuntu 4.4.0-210.242-generic 4.4.262)
The original kernel version is 4.4.262! And 4.4.0-210-generic is Ubuntu's kernel number.
Install the kernel source use command like
sudo apt-get install linux-source
Look at the newly installed file ('uname -r' => 4.4.0-210-generic)
/lib/modules/4.4.0-210-generic/build/include/generated/uapi/linux/version.h
#define LINUX_VERSION_CODE 263423
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
That version code is 0x0404FF indicating 4.4.[>=255] (where FF is for when patch exceeds 255).
-------- interesting reading below--------
It is interesting to look at the file
/lib/modules/4.4.0-210-generic/build/include/generated/utsrelease.h
#define UTS_RELEASE "4.4.0-210-generic"
#define UTS_UBUNTU_RELEASE_ABI 210
Now we know where uname and /proc/version get their number.
On my Ubuntu 20.04 5.4.0-80-generic
dmesg | grep "Linux\ versin"
[ 0.000000] Linux version 5.4.0-80-generic (buildd#lcy01-
amd64-030) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04))
#90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021
(Ubuntu 5.4.0-80.90-generic **5.4.124**)
and LINUX_KERNEL_CODE is
$ cat /lib/modules/5.4.0-80-generic/build/include/generated/uapi/linux/version.h
#define LINUX_VERSION_CODE 328828
where 328828 = 0x05047C, indicating 5.4.124.

sysctl: setting key "kernel.softlockup_panic": Invalid argument

When I am trying to set kernel.softlockup_panic value to 30 instead of 0. I am getting Invalid argument error
# sysctl -w kernel.softlockup_panic=30
Error message
# sysctl: setting key "kernel.softlockup_panic": Invalid argument
kernel.softlockup_panic = 30
Can anyone please guide?
I am using SLES12 64bit OS
# uname -a
Linux linux-r1qg 3.12.28-4-default #1 SMP Thu Sep 25 17:02:34 UTC 2014 (9879bd4) x86_64 x86_64 x86_64 GNU/Linux
I Have used syctl for other purposes. Guess this params is not supported by kernel .
you can check this thru either of the commands
sudo sysctl -a | grep softlockup
cat /proc/sys /etc/sysctl.conf

Finding if kernel is 32-bit or 64-bit on Linux

When I run uname -a, I get:
Linux 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
and I understand that x86_64 is supposed to imply 64-bit kernel, but why does this number appear 3 times? What does each instance signify?
Uname has separate commands to print "machine, processor and hardware platform" -- all of these are all the same in your case. The following outputs, respectively, may make it clear:
~$ uname -m # print machine
x86_64
~$ uname -p # print processor
x86_64
~$ uname -i # print hw platform
x86_64
use uname -m command to display only name of the kernel.
in your case
uname -m
x86_64
means 64-bit
uname -a
will give you all details about your system. It includes machine hardware name, processor type & hardware platform too.
So,
x86_64 is machine name.
x86_64 is processor type.
x86_64 is hardware platform.
Use:
uname --help
to get more idea about its options.

Resources