Star Hype News.

Premium celebrity moments with standout appeal.

general

What does linux-headers-`uname -r` do?

By John Thompson

What does the following command do?

sudo apt-get --reinstall install linux-headers-`uname -r`

sudo executes the statement with elevated priviledges. apt-get is a command to retrieve a specific package/program. What does the rest of the switches/flags do?

I'm trying to reset my wireless adapter's drivers to "factory default" settings.

1 Answer

--reinstall install:

Normally, this is written install --reinstall, but both work just fine. This simply is telling apt-get to reinstall the package(s).

linux-headers-:

linux-headers- is the beginning of a package name. If you run dpkg -l | grep linux-headers- you can see a full list of any packages installed that begin with that:

enter image description here

Header files are, from the GNU site:

A header file is a file containing C declarations and macro definitions to be shared between several source files. You request the use of a header file in your program by including it, with the C preprocessing directive ‘#include’.

And, as you can see from the response from dpkg -l | grep linux-headers-, the packages that start with linux-headers- are the header files for the Linux kernel.

`uname -r`:

This is what is known as Command Substitution. (The link is to the faqs.org page about the BASH command substitution capabilities.)

This runs the uname -r command, which returns the current kernel version:

enter image description here

and then puts what is returned from the uname -r command into the sudo apt-get --reinstall install linux-headers-`uname -r` command.

From the faqs.org page:

Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed as follows:

$(command)

or

`command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted.

Also, see this Unix/Linux Q/A about understand BASH backticks.

Now, you don't see this happen - you just see the results. However, if you did see the command after the uname -r response was put into the command, this is somewhat it would look like (changing for your current kernel version obviously):

sudo apt-get --reinstall install linux-headers-3.16.0-31-generic


Simplified version:

You're telling apt-get to reinstall the linux-headers package for your current kernel version.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy