Excluding directory from grep

For some reason, I can never remember how to do this.

If you ever want to grep for something but leave out a particular directory, use the --exclude-dir=DIR

So if I wanted to search the current directory for the string img, but don’t want to look in the directories tmp or log.

grep -r --exclude-dir=log --exclude-dir=tmp "img" ./

Excluding directory from grep

Boot Error: Gave up waiting for root device

So today my computer threw this really strange error when I was booting it up.  Still don’t know what caused it but you can bet your bottom dollar that I’m backing up that hard disk now that I recovered it.  While I was booting up I was confronted with the following error:

Gave up waiting for root device

I’d never seen this before and the screen looked like this (though this isn’t my image):


I booted to a live cd and found that my root file system (sda2) wouldn’t mount, nor could it be repaired by gparted.  After a lot of trial and error with other solutions, I gave fsck a try (with a little help from here) and it worked like a charm.  Below is what I did:

  1. entered sudo fsck /dev/sda2/
  2. This scanned my disk and immediately reported that there were problems.  It asked if I wanted to fix them.
  3. I entered y to signify that it should do so
  4. fsck came up with well over 100 block count errors, asking me each time if I wanted to fix it.  I kept entering y and finally threw caution to the wind and held the key down until it finished.
  5. I restarted and it worked.

Of course this isn’t guaranteed to fix everyone’s issue but if you’re out of ideas, give it a try.  I’m sure glad that I did!

Boot Error: Gave up waiting for root device

How to download a file from sourceforge with command line

I often need to download a file from sourceforge to a server or some remote system via command line but I can never remember how. I decided to write it down so I don’t have to keep sifting through AskUbuntu when I need to.

All you need to do is use wget, paste in the link you get from clicking the download button and specify the file name with -O.

So if I wanted to download ClamAV (found here) I’d click on the download link, get the url and filename and paste them in like so.

wget "http://sourceforge.net/projects/clamav/files/latest/download" -O clamav-0.98.tar.gz

That’s all there is to it!

How to download a file from sourceforge with command line

Saving Package Markings TERMINAL STYLE!

Alright, so as a KDE user I don’t use synaptic.  Not that I wouldn’t want to it’s just… you know I use KDE so I guess I use…Muon?  Anyway Muon’s much better than the previous KDE software manager yet I still can’t get it to save my markings.  It’s always grayed out on the file menu and I can’t be bothered to figure out why.  SO what to do when I want  a fresh install?

I go command line on it:

dpkg --get-selections > ~/Desktop/packages

It’s consistent, fool proof and works with any distro.  …plus it’s command line and that always makes me feel smart…until I break something…hence the need for reinstalling the operating system.

Saving Package Markings TERMINAL STYLE!

Manual nvidia drivers install

So I ran into this problem after re-installing Kubuntu 10.04 (for reasons that I shall not go into ::rolls eyes::).  Anyway, having an Nvidia GeForce 8400GS, I figured I could use the standard autodetection that Ubuntu provides for proprietary graphics drivers (described here) but for some reason that was not the case, so I needed to go in manually.

  • First, using the terminal, I installed the latest nvidia drivers

sudo apt-get install nvidia-current

  • Then, I restarted my computer and realized that my resolution was all wonky.  When I went into my “nvidia x server settings,” it told me that no such drivers were enabled.
  • so I followed the directions in the error message and ran the following command:

sudo nvidia-xconfig

  • Then I restarted my x server with the command 

sudo restart kdm

NOTE: the “kdm” is only because I’m running KDE.  If you’re running gnome it’s “gdm” and after 11.10 it’s “lightdm”

  • then everything worked fine!
Manual nvidia drivers install