How to fix flashing screen after nvidia driver update in Ubuntu

Recommended Ubuntu book

Just tried updating to the latest nvidia drivers and the screen was flashing after reboot. I have tried reinstalling drivers from other repositories but nothing worked. Had to use nouveau to get back to boot and still looking for a solution to get my desktop back to previous state. Anyhow, here is how to switch to nouveau:

At the flashing screen press “Ctrl + Alt + F1” to get to terminal at Ubuntu log in screen.

Log in using your credentials.

Stop X11 by entering this command:

sudo stop lightdm

Remove all nvidia packages by entering this command:

sudo apt-get purge nvidia-*

Install nouveau package by entering this command:

sudo apt-get install xserver-xorg-video-nouveau


sudo reboot


sudo shutdown -r now

Hope it helps!

How to find files within daterange in Ubuntu

Recommended Ubuntu book

I got a virus that hit all php files on one of my servers and had to find all the files that got affected withing the date of the attack. There are a few methods that you can use:

1) To find the files modified within the last day, type:

find /directory_path -mtime -1 -print

where -1 is 24 hours, -2 – 48, and so on.

2) To find the files within modified date range is trickier. You have to create 2 files with start and end dates like listed below, just replace 20111110 and 20111120 with needed dates.

touch -t 201111101059 /tmp/file1
touch -t 201111201200 /tmp/file2
find . -newer /tmp/file1 -a ! -newer /tmp/file2

That’s it.

How to install gitweb in Ubuntu

Recommended Ubuntu book

After being told that I live in the stone age for using svn, I decided to try out git. Finally I got some time to continue learning git and setting the new environment. As a step one, we learned how to install git on Ubuntu. Then, I decided that I wanted to host my own repositories and we learned how to set up gitosis on Ubuntu. Now, after updating to Ubuntu 11.10 – Oneiric Ocelot, I am ready to continue setting up everything I need to start conveniently using git. So, in this post, I will be setting up the gitweb and documenting the process.

Gitweb is a convenient GUI that allows us to quickly see the project and diffs right in the browser. Before we move on to installing git web, make sure you have installed apache. Now, lets move on to installing gitweb:

sudo apt-get install gitweb

Now lets look in our /var/www folder:

cd /var/www


I didn’t have gitweb folder here, so I created it:

sudo mkdir /var/www/gitweb

gitweb files should be in /usr/share/gitweb and we need them in our /var/www/gitweb, so lets create a symbolic link that will point to the files:

cd /var/www/gitweb

sudo ln -s /usr/share/gitweb/* .

To check if these are symbolic links, you can type:

ls -l

it should show what these files are linked to.

Next, locate the path to your git repositories. As per our install, we have it in /home/git/repositories. So, lets edit gitweb config to point to the right directory:

sudo gedit /etc/gitweb.conf

and replace:

$projectroot = "/var/cache/git";

to our path to git repositories, /home/git/repositories in my case to:

$projectroot = "/home/git/repositories";

Save the file and lets move on to next step – editing apache configuration. Open apache config for gitweb:

sudo gedit /etc/apache2/conf.d/gitweb

And edit it as follows (replace the paths if yours are different):

    RewriteEngine on
    RewriteRule ^/gitweb/([a-zA-Z0-9_\-]+\.git)/?(\?.*)?$ /cgi-bin/gitweb.cgi/$1 [L,PT]

    Alias /gitweb /home/git/repositories

    Options Indexes FollowSymlinks ExecCGI
    DirectoryIndex /cgi-bin/gitweb.cgi
    AllowOverride None

and save. Now its time to restart apache to apply the changes:

sudo /etc/init.d/apache2 restart

I got an error at first saying:

Syntax error on line 1 of /etc/apache2/conf.d/gitweb:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.!

Which was because I needed to add rewrite package to apache:

sudo a2enmod rewrite

This time apache started with no errors.

Now you should be able to go to http://localhost/gitweb and see the gitweb page. If you have no public repositories yet, you may see “404 – No projects found” notice. To test it out, I went to my repo folder:

cd /home/git/repositories/

and changed the permissions on my gitosis-admin.git:

sudo chmod -R 755 gitosis-admin.git

Refresh the localhost/gitweb and ta-da! It shows a repository where I could click around and check things out. Since I didn’t want this repo to show publicly, I had to change the permissions back to:

sudo chmod -R 750 gitosis-admin.git

This is it for now. In the next git series posts I will try to go over creating new repositories, adding users, general git usage, installing redmine for project management and anything else I may find useful.

How to restore Unity when it disappears in Ubuntu 11.10

Recommended Ubuntu book

Well, after playing around the compizConfig Setting Manager I somehow screwed up the whole system. Unity along with any kind of menu was gone. Terminal Windows did not come up when pressing ALT+F# and even ctrl+alt+delete were not working. The only way terminal was able to come up was by pressing Ctrl+Alt+T . I did

unity --reset

but it did not work. What worked for me was typing:


and enabling it again, disabling everything else that was conflicting. Hope this helps in case you are looking for the solution. 🙂

How to configure Unity in Ubuntu 11.10

Recommended Ubuntu book

I have been poking around the new Unity settings in Oneiric Ocelot.

First, check if you have compizconfig settings manager. If not, install by typing the following command in the terminal window:

sudo apt-get install compizconfig-settings-manager

Then go to unity dash and start typing compiz – it should show you the settings manager. Click it and go to “Desktop” options. I guess unity is a part of compiz now and this is where you can find “Ubuntu Unity Plugin” settings to edit the appearance.

I am kind of upset to see that there is no option to move the dock around. 🙁

Ubuntu Oneiric Ocelot – 11.10 review

Recommended Ubuntu book

Ububtu Oneiric Ocelot - 11.10

Ububtu Oneiric Ocelot - 11.10

As you all may know, the new version of Ubuntu was released on October 13, 2011, which is just over a week ago as of the time of writing this post. I wanted to upgrade right away, but decided to wait a bit for the user response as upgrades don’t always go smooth. Well, this one worked like a charm for me.

It took a little over an hour to perform the full upgrade. I made a backup just in case, which I also recommend doing. So far just a few programs need to be reinstalled. A ton of packages got deleted, but it’s mostly because they have a newer and improved versions.

As for the changes, the first thing I noticed was the desktop. It does look a lot better due to improved unity shell. I remember how much I hated it with the last upgrade when it just got added to Ubuntu and I am still not a big fan of it. It is, however, a lot more convenient and clean. I went from “definitely removing” to “may be I’ll poke around and keep it for a while”. I also don’t like the dock sitting on the right side, but I still have to look if I can relocate and change the size of it. The dash interface became a lot more usable too.

There are a few other small, but noticeable improvements, such as a new gnome login screen, login manager now uses LightDM.  Overall performance got slightly improved. Default mail client is now mozilla Thunderbird. Ubuntu now has a better support of 32 bit apps on 64 bit systems. It has a new backup client, which I still have to look into as it looks like they give you 5gb of online storage for free. Improved software center looks a lot better. These are just a few changes that I was pleased with.

There are other changes, but I think these are the biggest ones, at least for me. I like where it is going and will be waiting patiently for the next release. I want to see more improvements to unity as it looks like they put more focus on it now and it is here to stick.

How to install gitosis on Ubuntu

Recommended Ubuntu book

In the previous post we went over installing git on Ubuntu, we are now installing a package called gitosis so we can host git repositories.
First, make sure you have python-setuptools package installed since gitosis needs python. Open the terminal window and type:

sudo apt-get install python-setuptools

Now we need to get gitosis, type these commands one after another to create src folder in your user directory, clone the source and install it:

cd ~/
sudo mkdir src
cd src/
sudo git clone git://
cd gitosis/
sudo python install

Next, lets create a user that will own the repositories.

sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \

Now we need a public ssh key, we’ll create a local one, it will ask you for a passphrase, enter the one you like:

ssh-keygen -t rsa

Now we need to let the git user use this key:

cp ~/.ssh/ /tmp/
sudo -H -u git gitosis-init < /tmp/

Now lets change the permission on on post-update hook:

sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

Now lets clone gitosis-admin repository (you can get the hostname by typing hostname command in the terminal), navigate to the folder you want the repository to reside in and type:

sudo git clone git@YOUR_SERVER_NAME:gitosis-admin.git

That’s it, you got a local gitosis-admin repo with a config file and a keydir directory.

I will post how to use git and will try to install gitweb (convenient web interface) next.

Edit: I wrote another post on how to install gitweb in Ubuntu if you wish to move on to the next step. 🙂

How to install git on Ubuntu

Recommended Ubuntu book

As I finished installing svn server, I was given and advice to use git instead. So I started to look into it and decided to give it a try. This post is a start of a process.

You need git first. So, lets start installing it. Open the terminal and type:

sudo apt-get install git-core

Thats’s it. Short and up to the point. You can now check the version to make sure it is installed:

git --version

At the time of writing I have 🙂

In case you need a server, move on to the next point – installing gitosis on Ubuntu.

svn post-commit hook in Ubuntu

Recommended Ubuntu book

So, I’ve been messing around the scripts in Ubuntu. It’s fun… 2 am here and I finally got the post-commit hook to work the way I wanted it to. Had to learn quite a bit about bash scripts and php calling the bash scripts. 🙂

As I started in previous post – adding svn hooks in Ubuntu, this is a part 2 of that post. I am using SVNManager, and loading these hooks in the same /repo-templates folder I created in previous post.

To start, remove previous post-commit file from the folder if you created one as I made a new one. Then, lets create the files and make them executable:

sudo touch post-commit
sudo touch post-commit-email
sudo touch post-commit-send
sudo chmod +x post-commit post-commit-email post-commit-send

Lets start editing the post-commit file first:

sudo gedit post-commit

Here is what I got:


$REPOS/hooks/post-commit-email $REPOS $REV

Next, I created post-commit-email file in php, change the path to php if needed (to get the path, type ‘which php’ in terminal). Also, make sure you get the right database connection and password:

sudo gedit post-commit-email

$repos = $argv[1];
$rev = $argv[2];

$repos_name = basename($repos);

$con = mysql_connect("localhost","svnmanager","mypassword");

mysql_select_db("svnmanager", $con);

$result = mysql_query("SELECT DISTINCT, FROM repositories as rep
            LEFT JOIN groupprivileges as grppr ON grppr.repositoryid =
            LEFT JOIN groups as grp ON = grppr.groupid
            LEFT JOIN usersgroups as usrgrp ON usrgrp.groupid =
            LEFT JOIN users as usr ON = usrgrp.userid
            WHERE = '".$repos_name."' AND IS NOT NULL");

while($row = mysql_fetch_array($result)) {
  $email_addr = $row['email'];
  $email_id = $row['id'];
  $arr[$email_id] = $email_addr;

$result = mysql_query($q = "SELECT DISTINCT, FROM repositories as rep
            LEFT JOIN userprivileges as usrpr ON usrpr.repositoryid =
            LEFT JOIN users as usr ON = usrpr.userid
            WHERE = '".$repos_name."' AND IS NOT NULL");

while($row = mysql_fetch_array($result)) {
  $email_addr = $row['email'];
  $email_id = $row['id'];
  $arr[$email_id] = $email_addr;

$emails = "";
$flag = 0;
foreach ($arr as $key => $val) {
  if($flag) {
	$emails .= ',';
  $emails .= $val;
  $flag = 1;


exec($repos.'/hooks/post-commit-send '.$repos.' '.$rev.' '.$repos_name.' '.$emails.'');


At last, post-commit-send file:

sudo gedit post-commit-send



CHANGELOG=`svnlook log -r $REV $REPOS`
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGED=`svnlook changed -r $REV $REPOS`
DIFF=`svnlook diff -r $REV $REPOS | head --lines=$LIMITDIFF`
echo "-------------------- SVN Commit Notification --------------------
Repository: $REPOSNAME
Revision:   $REV
Author:     $AUTHOR
Date:       $DATE
Log Message:
Diff: (only first $LIMITDIFF lines shown)

#echo $SENDTO >> $REPOS/hooks/error_log 
# Send email
cat $TMPFILE | mail -r "$SENDFROM" -s "$SUBJECT" "$SENDTO"
# Cleanup

Change the email if needed and make sure that the backtick character is correct as it may change when you copy from this page. I got the last file from this post and modified it a bit.

Let me know if this worked for you. 🙂

How to add svn hooks with SVNManager in Ubuntu

Recommended Ubuntu book

So, once we set up our svn and SVNManager in Ubuntu, it would probably be nice to get emails every time a user in the repository makes a commit.
Svnmanager supports the post create script, which will be fired every time a new repository gets created. Lets start:

sudo gedit /var/www/svnmanager/config.php

at the end of the config, uncomment and edit the line to:

$post_create_script = "/bin/bash /var/www/newrepo-script";

Now lets create the newrepo-script:

$post_create_script = "/bin/bash /var/www/newrepo-script";

And add these lines:

cp -R /var/www/repo-templates/* $1/hooks/

which pretty much just tells to copy the content of the templates folder to the newly created repository’s /hooks/ directory. /hooks directory will execute the hooks that we place there on each event that we create. We will add post-commit hook for this example.

cd /var/www
sudo mkdir repo-templates

now the hook

sudo gedit post-commit

Add these lines and save:


/usr/bin/svnnotify                    \
    --repos-path    "$REPOS"                \
    --revision      "$REV"                  \
    --subject-cx                            \
    --with-diff                             \
    --handler       HTML::ColorDiff         \
    --to     \
    --from          root@localhost

Feel free to edit the email addresses. Now we need to make the script executable:

sudo chmod +x post-commit

Make sure that you have svnnotify package. Type:

which svnnotify

and if it shows the path, make sure it is the same as we made in post-commit file, if not, edit post-commit file. If path doesn’t show, chances are you don’t have the package installed. Install it by:

sudo apt-get install libsvn-notify-perl

This should do it. If you want to send the emails to every user in the repository, you may have to edit the hook. I found another good tutorial about it here.

Update: I created the hook the way I wanted it, for complete code visit this page – svn post-commit hook in Ubuntu.