Tag Archives: sudo chmod

How to add 2nd Hard drive to Ubuntu

To add/mount the second hard drive into Ubuntu, open up the terminal window and type:

sudo fdisk -l

Where sdb is our newly added Secondary Harddisk!

To create the partition on the second Hard drive, use the following command and follow the “on screen” instructions:

sudo fdisk /dev/sdb

Use the partprobe command to update the kernel with the changes:

sudo partprobe /dev/sdb

Where /dev/sdb is my device name, you can use your’s!

Now we need to format our newly created partition using the following command:

sudo mkfs /dev/sdb1 -t ext4

Verify the newly created partition:

sudo fdisk -l

Next you need to create a directory for a mount point:

cd /mnt/
sudo mkdir 2ndHDD 
sudo chmod 0777 2ndHDD
ls -l

Next, mount the newly created sdb1 parition into 2ndHDD directory:

sudo mount /dev/sdb1 /mnt/2ndHDD -t ext4

Updated: Run this command once more:

sudo chmod 0777 2ndHDD

Now, we make a test that we can write a file on to the new drive:

touch /mnt/2ndHDD/test.txt
ls /mnt/2ndHDD/* 

Next time, when we will reboot the computer, it will be gone. If we want to mount new hard drive permanently then we need to edit the fstab file:

sudo nano /etc/fstab

Add this line at the end of the fstab file(you can adjust it according to your requirement):

/dev/sdb1 /mnt/2ndHDD ext4 defaults 0 0

Use this command or else reboot your computer:

sudo mount –a

Hope this will help you!

Please Remember me in your prayers!


Mercurial Server on Ubuntu 12.04 LTS with Web Access

First we shall verify the version of the Ubuntu server that is running on our machine!

lsb_release -a

Install the Apache if you haven’t it already on your server!

sudo apt-get install apache2

Test the apache directly from the shell by doing a wget to the localhost. You will see the 200 OK response code.

Now install the Mercurial using the following command:

sudo apt-get install mercurial

Check the version of installed mercurial server:

hg --version

Let’s configure the master hgrc configuration file in order to remove the SSL restriction, allow to push the repository through web and trust the apache user (www-data).

sudo nano /etc/mercurial/hgrc

Add these lines to the hgrc file:

allow_push = *
push_ssl = false
allow_archive = gz, zip, bz2
users = www-data

Now configure the directory where Mercurial will keep all its repositories and serve them through Apache!

cd /
sudo mkdir mercurial
sudo mkdir mercurial/repositories
sudo chown -R www-data:www-data /mercurial

Let’s configure the hgweb.config!

cd /mercurial
sudo nano hgweb.config

Enter the following lines:

style = gitweb
/mercurial/repositories = /mercurial/repositories

Let’s configure the hgweb.cgi script in order to serve the repositories via Apache:

sudo cp /usr/share/doc/mercurial/examples/hgweb.cgi /mercurial
cd /mercurial
sudo chmod a+x hgweb.cgi

Open hgweb.cgi with nano:

sudo nano hgweb.cgi

Find the line that reads config=”…..” and replace with the following line:

Now we shall configure the Apache so it runs the hgweb.cgi when the /mercurial virtual directory is requested.

cd /etc/apache2
sudo mkdir mercurial
cd mercurial
sudo nano mercurial.conf

Type the following in the mercurial.conf file:

Move to the apache sites directory and edit the default file:

cd /etc/apache2/sites-available
sudo nano default

Enter the command in order to link the mercurial.conf file to Apache:

Include /etc/apache2/mercurial/mercurial.conf

Restart the apache server:

sudo apache2ctl restart

Now create a first repository as test, inside the /mercurial/repositories:

cd /mercurial/repositories
sudo mkdir first_repo
cd first_repo
sudo hg init

Change the owner of the repository to the Apache user:

sudo chown -R www-data:www-data /mercurial

To configure the security, we have to tell the Apache that allow only those users who are registered in the password file.

cd /mercurial
sudo htpasswd -mc hgusers arbab 
sudo chown www-data:www-data hgusers

Note: repeat command for more users without adding c.

Time to Test, Launch your browser pointing to http://servername/mercurial:

In order to add the “Description” and “Contact” detail, do the following steps:

cd /mercurial/repositories/first_repo/
cd .hg
sudo nano hgrc

Add these lines to hgrc:

contact = Arbab Nazar
description = First Mercurial Repository!

Refresh your browser, now you will see the contact and the descriptio 🙂

To solve the push permission denied error:

cd /mercurial/repositories
cd first_repo
sudo chmod -R 777 .hg

Again do it!!!

sudo chown -R www-data:www-data /mercurial

Congrats! now we have a working Mercurial server on Ubuntu 12.04 :-)

Hope this will help you!

Please Remember me in your prayers!

%d bloggers like this: