Author Archives: Rafik Younan

Rafik Younan

Source control is essential to any software developer. SVN has always been the standard after CVS, but as soon as Linus Travolds introduced Git to the world, back in 2005, everything changed.

Git is a distributed source control software, and although it wasn't the first distributed system, it certainly proved itself; if it works for the largest open source software project (Linux Kernel) certainly it is that good.
But if you are comfortable with SVN and its centralized nature, git is flexible enough to support a work-flow similar to SVN.

In this article we will setup a git server on a Linux machine accessible through a network and ssh. This server can have many repositories for multiple users. The setup is excellent for small team that needs private git repositories without all the bells and whistles of large git cloud repository services like Github.

Following is our agenda:

Git User Setup
Single Repo Setup
Allow Team Access

Git User Setup

We will run the following commands inside the terminal of the git server. You will need a root privilege to execute these commands, so you can use sudo before each command that you can't run or print the following command first:

$ sudo bash

But be careful, using the previous command can damage your system if you don't know what the commands do.

$ mkdir /srv/git.repo
$ adduser --home /srv/git.repo --shell /bin/bash --no-create-home git
Adding user 'git' ...
Adding new group 'git' (1000) ...
Adding new user 'git' (1000) with group 'git' ...
Not creating home directory '/srv/git.repo'.
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for git
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]

You will be asked some user details, you can go ahead and ignore them hitting Enter till you finish all of them.

Now you have created a new user on the server with username, password and home directory.
We will use this home directory to store each project repository as a different folder.
Single Repo Setup

So far so good. Now we need to add a repository.
The work flow is simple, you initialize a local git repository on any machine accessible to the git repo server.

$ git init /path/to/project/folder
$ cd /path/to/project/folder
$ git add .
$ git commit -m "Initial project commit."

Initializing and working with a local git repository is outside the scope of this article, so you can find more information on that on the official git documentation.

Next you need to make a special clone of this repository on the git repo server from our previous setp.

$ su git
$ cd
$ git clone --bare /path/to/project/folder projectname.git

This will create a special git repository with the name projectname.git. In this repository you wouldn't see all the files and folders that you have commited in your own local project, instead these are the files needed by git to represent the project and the changes done to its files and folders.

Next step is to make sure that you can access the repository using ssh protocol. Because the setup of ssh vary from system to system, you will need to search the web to find how to activate the ssh daemon on the git repo server. You can test if the daemon is enabled or not by trying the following command.

$ ssh git@localhost

If the command asked for "git" password, then the ssh daemon works and you can proceed to the following step.
Allow Team Access

The following steps need to be done for each team member who needs access the repository.
Please note that this will allow each team member to access all repositories on the git repo server. If you need a separate account to different teams you will have to repeat the first step with a user for each different team.

Each team member will generate an ssh key, and send their public ssh key to the git repo server in order to authenticate their and allow to "push" their changes to the repo.

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.

As you can see, you don't need to provide any input, just hit Enter where promoted for input until you generate the key.

$ ssh-copy-id git@SERVER_IP

This command will send your public ssh key to the git repo server, so you need to replace the SERVER_IP with the actual IP of the server or the server domain name if it's accessible through DNS.
This command will ask you for "git" user password on the server, that's why each team member must know the "git" password, but doesn't need to remember it.
A workaround would be to manually add each team member public ssh key to the ~/.ssh/authorized_keys file on the git home folder.

To add the new repository as a remote to your current working repo use the following command.

$ git remote add origin ssh://git@SERVER_IP:/srv/git.repo/projectname.git

Final Notes

If you find yourself lost at any point or need help, you will find plenty of online resources to get help from. I personally recommend the official git documentation. as a good place to get started.

In a small to medium size team, working on the same remote repository in an SVN like workflow can work, but needs continuous integration and high level of communication in order to ensure that all conflicts are discovered and resolved as soon as possible.

Rafik Younan
Great! You have finally installed a GNU/Linux operating system besides Windows. Every time you start your machine, you think, should I use the new shiny operating system (GNU/Linux), or go along with the familiar one (Windows)? Sometimes the choice is easy, you just want to surf the Internet or watch videos, read books, do a research or just listen to some music, so you choose GNU/Linux; on the other hand, there are times when you want to respond to an important email, or follow up on some old business thread, and you think I have no choice, I have to open Windows! Well not necessary!
In this article you will know how to keep your emails, contacts and calendars, synced between both operating systems without taking up extra space on your hard disk. Moreover, you'll understand an important concept concerning hard disk partitions and mounting system in GNU/Linux.

Assumptions & Prerequisites

Email client, any email client. Most popular email clients for Windows are Outlook and Thunderbird. I'll assume you are using Outlook as your main email client, if you use only Thunderbird you can skip the first step. If you use other email clients most probably the steps will work for you too.

Through the steps, we will install Thunderbird normally on both Windows and GNU/Linux.Most GNU/Linux distributions comes with email client pre-installed, you will need to install Thunderbird if they have other email client, because it offers easier migration for data from Outlook, and you can install it easily on Windows.

I'll assume that you have at least two partitions that are accessible for Windows. "C" partition for Windows files and folders and "D" partition for personal or professional data. Of course GNU/Linux should be installed on third partition, and Windows would always seems to be unaware of it.

Overview

On Windows, we will only use Thunderbird as the main email client, and let it import all data from other email clients (Outlook for example). Once we have all data imported to WThunderbird (Windows Thunderbird), we will move its data to another location on the hard disk, and let the GLThunderbird (GNU/Linux Thunderbird) see the same data as WThunderbird. And voilà, when you receive an email on Windows, you can check it on GNU/Linux, and when you make a reminder on GNU/Linux, you get alerts on Windows. And you've synced email!

 

Step 1: Put Thunderbird Up and Front

OS: Windows
You'll need to install Thunderbird on Windows if you don't already have it. After normal installation with all the default configuration, you can set up different email accounts, add signature for each account, and other configurations. Thunderbird will get all your email for all accounts and download them to it's local data folder.

Now we will import the data from other email clients. From menu tool-bar click (Tools > Import), and a wizard will guide you through the process of importing information from other email clients.

After making sure that all data are imported successfully, close Thunderbird and other email clients if open. And for other email clients, I recommend forgetting about them, because some email client configuration can prevent Thunderbird from retrieving emails, and you end up with emails out of your reach on GNU/Linux.

Step 2: Move Thunderbird Data

OS: Windows
Make sure that Thunderbird is completely closed. Open "My Computer" and go to "C:\\Users\<Your User Name>\AppData\Roaming\Thunderbird". You will find a folder with a name that begins with "default". Copy that folder to the "D:" partition, and remember its path (ex: D:\\Thunderbird\default.jd34I30d).

You'll need to find the path to "thunderbird.exe", usually it's something like "C:\\Program Files\Mozilla\Thunderbird".
In the command line enter the following commands:

cd C:\\Program Files\Mozilla\Thunderbird
thunderbird.exe -P

Choose to create new profile. Name the profile and click "brows", choose the just moved/copied profile folder (ex: "D:\\Thunderbird\default.jd34I30d) and save.

When you start Thunderbird you should see absolutely nothing, and
      that's OK. Thunderbird is now using different data folder.

Step 4: Common Ground

OS: Linux

We now need to enable your GNU/Linux  to *see* the "D:" partition. For this we need to learn more about how GNU/Linux handle different partitions and hard disk devices.

Technical Background

GNU/Linux reads every hardware device it can detect and create a special file to represent this device. You can find all devices by running the following command on terminal:

ls /dev/sd*

The most notable files/devices are /dev/sdxy where x is a letter and y is a number. sd stands for SCSI device which represent most modern hard disks. The x letter represent the entire device, and each partition on the device is represent with the number y. So /dev/sda1 is partition 1 on the first hard disk, /dev/sda2 is partition 2 and so on.

GNU/Linux installation process takes at least a single partition and put all its folders and data on this partition. You can change this default and expand the system installation across several partitions, but this is out of our scope in this article.

On system start-up, GNU/Linux determine what partitions it needs to *load* - from here after we will call this process as *mount*, the proper name of this process. Mounting partitions means reading the files and folders on this partition and placing them in an accessible place.

We will understand more about this process while working on our step-by-step guide.

Mount the Partition

First thing we need to do is to find whether the system has automatically loaded the "D:" partition for us, or we need to tell it to.

Find out what partitions are mounted:

$ mount

You should have an output similar to the following:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=213782,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=411308k,mode=755)
/dev/sda5 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1603700k)

The main format of the output is <Descriptor File> on <Mount Point> type <File System Type> (<Mount Options>)

Descriptor File is the block device or remote file system, includes /dev/sdxy files that are currently loaded.
Mount Point is where you can find the actual files and folders represented by the file descriptor.
File System Type includes NTFS, FAT32 and famous GNU/Linux types like ext2, ext3 and ext4.
Mount Options,  you don't need to worry about that for now, we will use the defaults in our case.

In our example I have the system installed on partition 5, you can notice that from this line

/dev/sda5 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)

From file browser, try to open  the "D:" partition from file browser. This is trial and error process as GNU/Linux doesn't read the Windows partition names. After opening the right partition remember the path, it will be something like "/media/<long name with alphanumerical characters>/"

Now enter the mount command again and notice the newly added record:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=213782,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=411308k,mode=755)
/dev/sda5 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1603700k)
/dev/sda3 on /media/Er345vf43 type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096)

The last line means that our partition is number 3.
Now some command line magic:

sudo umount /dev/sda3
sudo mkdir /media/d
sudo cp /etc/fstab /etc/fstab.bkp
sudo vi /etc/fstab

The last command opens a terminal text editor, for now you'll only need to type the following sequence of characters:
<Shift + g>, <o>
These commands go to the end of file and add a new line.
Type the following record:

/dev/sda3	/media/d	/	ntfs	defaults	0	0

Press the following sequence of characters:
<Esc>, <:>, <x>, <Enter>
These commands let you write the updated file and exit the editor.

This new line tells the system to automatically mount the partition "/dev/sda3" to folder "/media/d" on start-up, so that we will be sure that Thunderbird can find it's new data folder.

To test everything, run the following commands:

sudo mount -a
ls /media/d

The last command should list all files and folders located at "D:\\" on Windows.
Now we have the Thunderbird profile directory readable on system start-up, we can tell Thunderbird to read its data from the new profile.

Step 3: Thunderbird Meets Thunderbird

OS: Linux

In Linux, you should install Thunderbird, but don't configure your email accounts, settings and other configuration, you've already done that on Windows, no need to repeat yourself.

Make sure that Thunderbird is closed. In terminal enter the following command:

thunderbird -p

Create new profile, add a name and choose the directory you moved/copied from Windows.
Start Thunderbird and you've got all your data here in GNU/Linux and finally you've synced emails.