LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Installing Nvidia driver in Wheezy...Can someone explain this code? (https://www.linuxquestions.org/questions/debian-26/installing-nvidia-driver-in-wheezy-can-someone-explain-this-code-4175467615/)

m_yates 06-27-2013 12:48 PM

Installing Nvidia driver in Wheezy...Can someone explain this code?
 
I'm setting up a Mythtv box at home using Debian Wheezy and I wanted the Nvidia drivers for VDPAU. In the past, I have installed Nvidia drivers manually downloaded from the Nvidia web site. This time, I found the following line of code from the Debian wiki:

Code:

aptitude -r install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') nvidia-kernel-dkms
To my surprise, this worked in one step. Upon reboot, the Nouveau driver was blacklisted and the Nvidia driver was installed and working.

I'm posting this with the hope that I can learn something, because I don't understand what the code above is doing. It seems I will never progress from being a newbie. I understand that the command is to install linux-headers for the currently installed kernel. What I don't understand is what the sed command is doing? Can someone break it down?

ButterflyMelissa 06-27-2013 01:53 PM

If you'd type in
Quote:

uname -r
you get the version of your kernel, the sed command filters out the type...

And example

Quote:

uname -r
gives 3.2.0-48-generic
the line

Quote:

uname -r|sed 's,[^-]*-[^-]*-,,'
returns "generic" - the type of kernel I use here...

Sed has a lot more to offer as some tutorials indicate...

Thor

cynwulf 06-28-2013 03:21 AM

what uname -r returns and how useful it is really depends on the distro. With most Debian kernels, this would have worked just as well:

Code:

# aptitude -r install linux-headers-$(uname -r) nvidia-kernel-dkms
Or even
Code:

# aptitude -r install linux-headers-`uname -r` nvidia-kernel-dkms

273 06-28-2013 04:20 AM

Quote:

Originally Posted by cynwulf (Post 4980094)
what uname -r returns and how useful it is really depends on the distro. With most Debian kernels, this would have worked just as well:

Code:

# aptitude -r install linux-headers-$(uname -r) nvidia-kernel-dkms
Or even
Code:

# aptitude -r install linux-headers-`uname -r` nvidia-kernel-dkms

Might the method suggested by the wiki be advantageous because it installs the metapackage rather than the package for the specific kernel installed at that point in time? I have to say I don't want to go through the hassle of testing it but I wondered whether installing the package specific to the installed kernel may mean it is not updated when the kernel is?

cynwulf 06-29-2013 06:06 AM

Quote:

Originally Posted by 273 (Post 4980113)
Might the method suggested by the wiki be advantageous because it installs the metapackage rather than the package for the specific kernel installed at that point in time? I have to say I don't want to go through the hassle of testing it but I wondered whether installing the package specific to the installed kernel may mean it is not updated when the kernel is?

You're absolutely right. I keep forgetting about the meta packages as I always run off my own kernels.

Code:

$ uname -r|sed 's,[^-]*-[^-]*-,,'
smp

Code:

$ uname -r
3.9.8-686-smp



All times are GMT -5. The time now is 10:22 PM.