Kernel command line

Also known as: kernel parameters

On this page 7

The kernel command line is the text string of parameters that a bootloader hands to the Linux kernel at boot, telling it which root file system to mount, which init program to start, how to configure consoles and which subsystems to enable or tune. In system initialization on Linux, it is the first configuration the kernel reads, long before any configuration file on disk becomes available.

The parameters, also called kernel parameters, are space-separated words or key=value pairs such as root=UUID=..., quiet or systemd.unit=rescue.target. Because they act before user space exists, they are the primary tool for recovery, debugging and hardware workarounds, and a single wrong value can leave a machine unable to boot.

How the kernel command line reaches the kernel

The kernel command line travels from the bootloader to the kernel in memory, not from a file the kernel opens. A bootloader such as GRUB or systemd-boot assembles the string from its configuration, places it in a memory area described by the boot protocol, and jumps to the kernel entry point. On UEFI systems with a unified kernel image, the string can instead be embedded in the image itself and protected by Secure Boot signatures.

Once running, the kernel parses the string in two passes. Early parameters, registered with early_param, are processed before memory management and most drivers start, which is why options such as mem= or earlyprintk work at all. Ordinary parameters are matched against built-in handlers and module parameters later. Anything the kernel does not recognize is forwarded to the init process, either as an argument or as an environment variable.

The running system exposes the exact string in `/proc/cmdline`, which is the authoritative way to confirm what the kernel actually received. The table below summarizes where the string comes from on common setups.

Boot methodWhere the string is definedHow it is changed
GRUB 2GRUB_CMDLINE_LINUX in /etc/default/grubRegenerate grub.cfg with the distribution tool
systemd-bootoptions line in loader entry filesEdit the entry or /etc/kernel/cmdline
Unified kernel imageEmbedded .cmdline sectionRebuild and re-sign the image
Kernel built-inCONFIG_CMDLINE at compile timeRecompile the kernel
Device treechosen/bootargs nodeEdit the device tree or bootloader variables
Sources of the kernel command line by boot method

Parameter syntax and namespaces

Kernel parameters follow a simple but strict syntax: words are separated by spaces, values are attached with an equals sign, and lists inside a value use commas. Double quotes allow spaces inside a value. A double dash (`–`) ends kernel parsing, and everything after it is passed unchanged to init.

Parameters for drivers compiled into the kernel use a `module.parameter=value` form, for example i915.enable_psr=0. The same setting for a loadable module is normally placed in /etc/modprobe.d, but the dotted form on the command line also works because the module loader reads it. Init systems define their own namespaces, so systemd reads `systemd.`-prefixed options and the initramfs reads `rd.`-prefixed options.

The following table lists widely used parameters and the stage that consumes them.

ParameterConsumerEffect
root=Kernel or initramfsSelects the root file system device
ro / rwKernelMounts root read-only or read-write initially
init=KernelRuns a different program as PID 1
console=KernelDirects messages to a terminal or serial port
quiet / loglevel=KernelControls how many messages appear on screen
rd.breakinitramfsStops in a shell before switching root
systemd.unit=systemdBoots into a specific target
splashPlymouthShows the graphical boot screen
Common kernel parameters and their effect

The kernel command line is one of several configuration layers during boot, and confusing them is a frequent source of settings that seem to be ignored. It acts earliest and is volatile per boot, while sysctl and module configuration apply later from files on disk.

MechanismWhen it appliesTypical use
Kernel command lineBefore and during kernel startupRoot device, early hardware options, init choice
initramfs configurationBefore the real root is mountedStorage, encryption and network root setup
sysctl settingsAfter user space startsRuntime tunables under /proc/sys
modprobe.d optionsWhen a module loadsPersistent driver parameters
systemd targetDuring service startupWhich group of units to start
How boot-time configuration layers differ

Some tunables exist in both worlds. A setting under /proc/sys can often be given on the command line with the `sysctl.` prefix in recent kernels, which helps when the value must be in force before the sysctl service runs. As a rule, use the command line only for what cannot wait until user space.

Editing kernel parameters safely

There are two ways to change kernel parameters: a temporary edit for a single boot and a persistent change in the bootloader configuration. Temporary edits are made at the boot menu, for example by pressing e on a GRUB entry, appending the parameter and booting. They vanish on the next restart, which makes them the safest way to test a new value.

Persistent changes require editing the bootloader source and regenerating the boot configuration. Distributions differ in the tool: some use update-grub, others grub2-mkconfig, and tools such as grubby or kernelstub edit entries directly. Forgetting the regeneration step is the most common reason a change has no effect.

SituationRecommended approachReason
Testing a new valueTemporary boot menu editReverts automatically on reboot
Permanent hardware workaroundBootloader default optionsApplies to every installed kernel
One kernel version onlyEdit that specific entryAvoids affecting other kernels
Signed unified kernel imageRebuild with new cmdlineEmbedded string cannot be edited at boot
Fleet of serversConfiguration managementKeeps parameters consistent and audited
Choosing how to apply a kernel parameter

Limitations, risks and common mistakes

The kernel command line has an architecture-dependent length limit, commonly 2,048 bytes on x86 and sometimes less in older bootloaders, so long lists of options may be truncated silently. It is also readable by every user through /proc/cmdline, so it must never contain secrets such as passwords or keys.

  • Typos are silently ignored: an unknown parameter is passed to init instead of producing an error.
  • Duplicate parameters usually resolve to the last occurrence, which can override intended values.
  • Security-sensitive options such as init=/bin/sh or disabling mitigations bypass protections, so bootloader menus should be password-protected on exposed machines.
  • Copying parameters from forums without understanding them often leaves obsolete workarounds active for years.
  • Editing only one entry may leave fallback or newly installed kernels without the fix.

In plain words

When a Linux computer starts, a small program called the bootloader starts the kernel, which is the core of the operating system. Along with it, the bootloader passes a short line of instructions, much like a note attached to a package: where the main disk is, whether to show messages, and which program should start next.

The kernel reads this note before anything else is ready. That is why it is so useful when something is broken, and why a wrong instruction can stop the computer from starting. The key idea is simple: the kernel command line is the very first set of instructions the system follows.

A real-world example

An administrator at a small hosting company forgets the root password on a virtual server running a systemd-based distribution. She opens the serial console, interrupts GRUB, presses e on the default entry and appends rd.break to the line that starts with linux. The machine stops in an initramfs emergency shell before the real root is mounted.

She remounts /sysroot read-write, changes into it with chroot, sets a new password, schedules an SELinux relabel and reboots. Because the parameter was added only for that boot, the next start is completely normal. The whole recovery takes about ten minutes and requires no rescue media and no change to the stored configuration, which is exactly the advantage of a temporary kernel command line edit.