How to Display or Modify Linux Kernel Parameters

This post will guide you how to view Linux kernel parameters in your CentOS or Ubuntu Linux system. How do I modify Linux kernel parameters for you currently booted kernel in your CentOS or Ubuntu Linux opearating system or other Linux distributions.

What is Linux Kernel?


The Linux kernel is a free and open-source, monolithic, Unix-like operating system kernel. The Linux family of operating systems is based on this kernel and deployed on both traditional computer systems such as personal computers and servers, usually in the form of Linux distributions, and on various embedded devices such as routers, wireless access points, PBXes, set-top boxes, FTA receivers, smart TVs, PVRs, and NAS appliances.

check linux kernel parameters1

Display Current Linux Kernel Parameters


If you want to display current kernel parameters for currently booted kernel in your Linux, and you can use one of the following commands:

$ cat /proc/cmdline

Or

$ dmesg | grep “Command line”

Outputs:

devops@devops:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.0.0-27-generic root=UUID=ce8f14cf-e782-4dc8-9506-829989f3775e ro quiet splash


devops@devops:~$ dmesg |grep "Command line"
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.0.0-27-generic root=UUID=ce8f14cf-e782-4dc8-9506-829989f3775e ro quiet splash

The above outputs from /proc/cmdline file shows the parameters passed to the current kernel at the time when your Linux system is started. And you can see that the current running kernel is using vmlinuz-5.0.0-27-generic kernel image.

Display all Kernel Parameters Currently Available


If you want to see all kernel parameters currently that can be used in your Linux system, and you can issue the following command to get a list of all kernel parameters:

$ sysctl -a

Outputs:

devops@devops:~$ sysctl -a
abi.vsyscall32 = 1
debug.exception-trace = 1
debug.kprobes-optimization = 1
dev.cdrom.autoclose = 1
dev.cdrom.autoeject = 0
dev.cdrom.check_media = 0
dev.cdrom.debug = 0
dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.20 2003/12/17
dev.cdrom.info =
dev.cdrom.info = drive name: sr0
dev.cdrom.info = drive speed: 32
dev.cdrom.info = drive # of slots: 1
dev.cdrom.info = Can close tray: 1
dev.cdrom.info = Can open tray: 1
dev.cdrom.info = Can lock tray: 1
dev.cdrom.info = Can change speed: 1
dev.cdrom.info = Can select disk: 0
dev.cdrom.info = Can read multisession: 1
dev.cdrom.info = Can read MCN: 1
dev.cdrom.info = Reports media changed: 1
dev.cdrom.info = Can play audio: 1
dev.cdrom.info = Can write CD-R: 0
dev.cdrom.info = Can write CD-RW: 0
dev.cdrom.info = Can read DVD: 1
dev.cdrom.info = Can write DVD-R: 0
dev.cdrom.info = Can write DVD-RAM: 0
dev.cdrom.info = Can read MRW: 1
dev.cdrom.info = Can write MRW: 1
dev.cdrom.info = Can write RAM: 1
dev.cdrom.info =
dev.cdrom.info =
dev.cdrom.lock = 0
dev.hpet.max-user-freq = 64
dev.mac_hid.mouse_button2_keycode = 97
dev.mac_hid.mouse_button3_keycode = 100
dev.mac_hid.mouse_button_emulation = 0
dev.parport.default.spintime = 500
dev.parport.default.timeslice = 200
dev.raid.speed_limit_max = 200000
dev.raid.speed_limit_min = 1000
dev.scsi.logging_level = 0
dev.tty.ldisc_autoload = 1
fs.aio-max-nr = 65536
fs.aio-nr = 2661
fs.binfmt_misc.status = enabled
fs.dentry-state = 21571 4832 45 0 1106 0
fs.dir-notify-enable = 1
fs.epoll.max_user_watches = 196382
fs.file-max = 95421
fs.file-nr = 5408 0 95421
fs.inode-nr = 21898 2020
fs.inode-state = 21898 2020 0 0 0 0 0
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 8192
fs.lease-break-time = 45
fs.leases-enable = 1
fs.mount-max = 100000
fs.mqueue.msg_default = 10
fs.mqueue.msg_max = 10
fs.mqueue.msgsize_default = 8192
fs.mqueue.msgsize_max = 8192
fs.mqueue.queues_max = 256
fs.nr_open = 1048576
fs.overflowgid = 65534
fs.overflowuid = 65534
fs.pipe-max-size = 1048576
fs.pipe-user-pages-hard = 0
fs.pipe-user-pages-soft = 16384
sysctl: permission denied on key 'fs.protected_fifos'
sysctl: permission denied on key 'fs.protected_hardlinks'
sysctl: permission denied on key 'fs.protected_regular'
sysctl: permission denied on key 'fs.protected_symlinks'
fs.quota.allocated_dquots = 0
fs.quota.cache_hits = 0
fs.quota.drops = 0
fs.quota.free_dquots = 0
fs.quota.lookups = 0
fs.quota.reads = 0
fs.quota.syncs = 0
fs.quota.writes = 0
fs.suid_dumpable = 2
kernel.acct = 4 2 30
kernel.acpi_video_flags = 0
kernel.auto_msgmni = 0
kernel.bootloader_type = 114
kernel.bootloader_version = 2
sysctl: permission denied on key 'kernel.cad_pid'
kernel.cap_last_cap = 37
kernel.core_pattern = |/usr/share/apport/apport %p %s %c %d %P
kernel.core_pipe_limit = 0
kernel.core_uses_pid = 0
kernel.ctrl-alt-del = 0
kernel.dmesg_restrict = 0
kernel.domainname = (none)
kernel.firmware_config.force_sysfs_fallback = 0
kernel.firmware_config.ignore_sysfs_fallback = 0
kernel.ftrace_dump_on_oops = 0
kernel.ftrace_enabled = 1
kernel.hardlockup_all_cpu_backtrace = 0
kernel.hardlockup_panic = 0
kernel.hostname = devops
kernel.hotplug =
kernel.hung_task_check_count = 4194304
kernel.hung_task_check_interval_secs = 0
kernel.hung_task_panic = 0
kernel.hung_task_timeout_secs = 120
kernel.hung_task_warnings = 10
kernel.io_delay_type = 1
kernel.kexec_load_disabled = 0
kernel.keys.gc_delay = 300
kernel.keys.maxbytes = 20000
kernel.keys.maxkeys = 200
kernel.keys.persistent_keyring_expiry = 259200
kernel.keys.root_maxbytes = 25000000
kernel.keys.root_maxkeys = 1000000
kernel.kptr_restrict = 1
kernel.max_lock_depth = 1024
kernel.modprobe = /sbin/modprobe
kernel.modules_disabled = 0
kernel.msg_next_id = -1
kernel.msgmax = 8192
kernel.msgmnb = 16384
kernel.msgmni = 32000
kernel.ngroups_max = 65536
kernel.nmi_watchdog = 0
kernel.ns_last_pid = 3426
kernel.numa_balancing = 0
kernel.numa_balancing_scan_delay_ms = 1000
kernel.numa_balancing_scan_period_max_ms = 60000
kernel.numa_balancing_scan_period_min_ms = 1000
kernel.numa_balancing_scan_size_mb = 256
kernel.osrelease = 5.0.0-27-generic
kernel.ostype = Linux
kernel.overflowgid = 65534
kernel.overflowuid = 65534
kernel.panic = 0
kernel.panic_on_io_nmi = 0
kernel.panic_on_oops = 0
kernel.panic_on_rcu_stall = 0
kernel.panic_on_unrecovered_nmi = 0
kernel.panic_on_warn = 0
kernel.panic_print = 0
kernel.perf_cpu_time_max_percent = 25
kernel.perf_event_max_contexts_per_stack = 8
kernel.perf_event_max_sample_rate = 100000
kernel.perf_event_max_stack = 127
kernel.perf_event_mlock_kb = 516
kernel.perf_event_paranoid = 3
kernel.pid_max = 32768
kernel.poweroff_cmd = /sbin/poweroff
kernel.print-fatal-signals = 0
……

Modifying Linux Kernel Parameters


If you want to modify the Linux Kernel parameters for your Linux kernel, and you can modify the kernel configuration file called sysctl.conf located in the /etc/directory with your text editor vi or vim, type:

$ sudo vim /etc/sysctl.conf

And you can add the kernel parameters into this file, for example, you can adding the following settings to enable packet forwarding for IPv4:

net.ipv4.ip_forward =1

save and close the file. And you can run the following command to load in sysctl settings from /etc/sysctl.conf file.

$ sudo sysctl -p

Outputs:

devops@devops:~$ sudo sysctl -p
net.ipv4.ip_forward = 1

Checking The Kernel Version


If you want to check which kernel version your server is currently running, you can the following command from the command line, type:

$ uname -a

Outputs:

devops@devops:~$ uname -a
Linux devops 5.0.0-27-generic #28~18.04.1-Ubuntu SMP Thu Aug 22 03:00:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

From the above outptus, you would noticed that the current kernel version is 5.0.0-27.

Conclusion


You should know that how to check what are the current kernel parameters settings in your CentOS or RHEL or Ubuntu Linux system.

You might also like:

Sidebar



back to top