Wednesday, February 16, 2011

It's all in a uname, if you use ` and not '

If you want know which Linux kernel you're running, you can just type "uname - r" (without the quotes) into the terminal -- we've been through that before.

You can also use uname to insert your kernel version into another command.  For instance, if you want to install the linux headers (which have to be the right ones for your kernel) you could use:
sudo apt-get install linux-headers-2.6.35-26-generic
Assuming that's the kernel you're running.

Unless you know the version off the top of your head, you can save yourself a step by putting uname into the command, as in:
sudo apt-get install linux-headers-`uname -r`
Seems simple, huh?  But there's a catch: those aren't single quotation marks surrounding uname -r.  They're backticks.

If you look closely, you'll see that they're ` and not '.  The backtick (aka grave accent) is often on the same key as the tilde (~) just under Esc on the upper left of the keyboard.

No comments: