13

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 1

21

--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
  • golden, thanks for the detail! would +1 this if i could ... Commented Mar 20, 2015 at 2:31
  • @culturalanomoly Well, edit 1-2 posts and accept this one and you'll have enough rep to do so! ;) Welcome to Ask Ubuntu :) Commented Mar 20, 2015 at 2:33
  • 1
    btw, what'd you use to redact the sensitive bits on the image? Commented Mar 20, 2015 at 2:47
  • 1
    @culturalanomoly I use Shutter. It's an awesome piece of software that lets you takes all sorts of different screenshots and then has a built-in editor for doing stuff like, as you saw, blurring bits, drawing arrows, circling things, adding text. It's one of the most useful pieces of software I have installed. Commented Mar 20, 2015 at 3:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .