nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Hard links / symbolic links - is this what I need?

This is a discussion on Hard links / symbolic links - is this what I need? within the Linux software forums, part of the Linux Getting Started category; I run a dual booting laptop with Win XP SP2 on one partition and Ubuntu 7.04 on another. Each system ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 06-21-2007, 05:04 AM
Junior Member
User
 
Join Date: Jun 2007
My distro: Debian / Ubuntu 7.04
Posts: 3
Rep Power: 0
DavidFox is on a distinguished road
Default Hard links / symbolic links - is this what I need?

I run a dual booting laptop with Win XP SP2 on one partition and Ubuntu 7.04 on another. Each system can see all the files on the other system. I run Evolution as my email / PIM programme on both systems, v 2.8.2 on XP and v 2.10.1 on Ubuntu.

I want to have just 1 set of data files - calendar; contacts list; email in/out boxes; ..etc.. - shared between the two systems as my time is more or less equally shared between the two systems.

It has been suggested to me that I can achieve this by having the data files on XP and setting up a series of symbolic links in the relevant directories in Ubuntu, linking to the XP files. I gather from reading the reference data on Links that I need a symbolic link rather than a hard link because I'm working across system boundaries.

It will involve quite a bit of work to set this up and I want to get a better understanding of whether the links will actually achieve what I want before I embark on a complicated set-up process.

I don't yet understand how linking works. For example, if my data files are on the XP partition and I am working in Ubuntu, and I send an email or enter a new contact - will the linking cause the new data to be entered to the file on the XP partition rather than to the file within the Ubuntu partition, or does it get entered in both files? What if I'm in XP and do the same thing?

In general terms, what's the difference between a hard link and a symbolic link, and when do you use each type?

Can somebody point me at a tutorial that gives a plain English description of what links are, what they do and how to correctly use them?

In responding, please bear in mind that I have very limited understanding of Linux terminology. I've had 20 years of computing experience, mostly with Win systems, so please don't bury me under Linux geek-speak.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-21-2007, 01:33 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Welcome to forum!

First you need to use soft links. Soft links are just like windows shortcuts. Whenever you click on shortcut system will follow same real path.
Quote:
I don't yet understand how linking works. For example, if my data files are on the XP partition and I am working in Ubuntu, and I send an email or enter a new contact - will the linking cause the new data to be entered to the file on the XP partition rather than to the file within the Ubuntu partition, or does it get entered in both files? What if I'm in XP and do the same thing?
If you are in Ubuntu ALL data will enter into Windows partition file as linux soft link will actually pointing to Windows file. Linux will just follow the link.
If you are in XP ALL data will enter into Windows file system as there is no soft link (shot cut).

Quote:
In general terms, what's the difference between a hard link and a symbolic link, and when do you use each type?
Use hard link when you are on the same partition (such as C: aka /dev/sda1)
Use soft link when you want link files between two partitions (between C: and D: aka /dev/sda1 and /dev/sda2). In your case Windows is on first partition (C and Linux is on second partition, so you must use soft link.
Quote:
Can somebody point me at a tutorial that gives a plain English description of what links are, what they do and how to correctly use them?
Hmm
It is bit hard to find any tutorial or information without technical details such as inode. You can think links as a shortcut.

Ok here is example:
Your actual file name is /webroot/home/www/domain.com/http/index.html

Now to access index.html you need to type full path such as
vi /webroot/home/www/domain.com/http/index.html

To save your time your create soft link aka shortcut in your home directory called /home/monk
Code:
ln -s /webroot/home/www/domain.com/http/index.html /home/monk/index.html
Now you just type
Code:
vi /home/monk/index.html
And linux will follow link to open actual file /webroot/home/www/domain.com/http/index.html as
/home/monk/index.html point to => /webroot/home/www/domain.com/http/index.html

So when ever you update /home/monk/index.html file, /webroot/home/www/domain.com/http/index.html file will also get updated. But if you delete soft link /home/monk/index.html, the original file remains as it is.


Rules
  1. HARD link NOT ALLOWED for directory (it is only for the file)
  2. Soft link are allowed for both directory and files
  3. You CANOT use hard link files between two partitions
  4. You can use soft link botj files and directories between two partitions
Hope this helps. If you any other question feel free to hit reply button.
__________________
May the force with you!

Last edited by monk; 06-21-2007 at 01:38 PM..
Reply With Quote
  #3 (permalink)  
Old 06-22-2007, 06:37 AM
Junior Member
User
 
Join Date: Jun 2007
My distro: Debian / Ubuntu 7.04
Posts: 3
Rep Power: 0
DavidFox is on a distinguished road
Default

Monk - many thanks for your explanation. I now have a better understanding of what the soft link can achieve, but I'm not yet clear on how to implement it as I'm planning to.

Specifically, I have the following situation. Let's look at Calendars. On Ubuntu I have: ~/.evolution/calendar/local/system/calendar/calendar.ics
On XP I have c:/Documents and Settings/david/.evolution/calendar/local/system/calendar/calendar.ics
Not surprisingly, the same sub-directory structure and same file name within Evolution on both systems. A similar situation exists with Tasks, Email, ..etc..
In this situation:
1. Where do I locate the link?
2. Given that the file name is identical in each system, how do I word the link?

In determining the path within XP, another issue arose - the spaces in the directory name. I tried to use Terminal to determine the path but got stuck after /media/hda1/. 'ls' shows the directory Documents and Settings, but no matter what I enter after a 'cd' command I get "No such file or directory". I had to go back into XP to work out what the path was. How, within Linux, do I correctly enter a Windows directory name that contains spaces?

A final complication. Within XP I have two drives, c: and d:. I keep the c: drive for the OS and the d: drive for my working files. Usually when I use Terminal to look into the XP drive, cd /media/hda1 takes me to the c: drive, but occasionally it takes me to the d: drive. How do I specify which drive I go to? This may have some bearing on how the soft link gets worded.
Reply With Quote
  #4 (permalink)  
Old 06-22-2007, 03:59 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Make a backup of data before running following commands:

Code:
cd /media/hda1/
cd "Documents and Settings"
ls
ls -l
pwd
Note how double quotes are used!

Now you can run ln -s command bu you must remove Linux ~/.evolution and link the same. So first backup Email data on Windows, If anything goes wrong you can just restore and start again
Make sure evolution app is not running. On Linux, enter:
Code:
cd
mv .evolution .evolution.old
ln -s "/media/hda1/Documents and Settings/david/.evolution" .
Again note . at the end of last command
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #5 (permalink)  
Old 06-22-2007, 04:47 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

Vivek,

The solution you gave will solve the purpose.

As far as I remember, I have tried this in Fedora/SuSE and I have some issues with this.

The situation is something like this:

What if we create a normal user ( ex: ricc ) and try to use the *.ics file?

It will not be able to write to the file. Because Linux doesn't allow write access to other users. What we can do is manually change the ownership permissions for the file by making the user the owner of the file.

But this is not permanent. Esp when /media/hda1 ( or whatever the Windows Partition is mounted to) is remounted, it changes back to the default permission.

We will need a script to change the permissions back to what we want or else the user will not be able to write to the *.ics file.

Hope I am clear.

ricc
Reply With Quote
  #6 (permalink)  
Old 06-22-2007, 05:24 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

ricc,

You can always modify /etc/fstab file and set user permission. Look for umask and uid. For multiple users (a bad idea, IMHO) you can use Linux group management and setup gid. man mount documents all options.
__________________
May the force with you!
Reply With Quote
  #7 (permalink)  
Old 06-25-2007, 06:40 AM
Junior Member
User
 
Join Date: Jun 2007
My distro: Debian / Ubuntu 7.04
Posts: 3
Rep Power: 0
DavidFox is on a distinguished road
Default

Monk / Nixcraft / Ricc - my thanks to each of you for the advice. I've developed a problem with Evolution loading within Win XP, which I'll have to sort out before I resume this file-sharing exercise; Evolution will currently only run under Linux so file sharing has temporarily ceased to be an issue. I've got a heavy work programme for the next week or two so I'm not sure how soon I'll get back to this.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Script per informazione di hard disk RamPD Shell scripting 0 04-07-2008 08:22 PM
Hard Link Query sharadgana Getting started tutorials 2 03-25-2008 01:11 AM
USB Hard Drive Multi-Boot ceptune48 Linux hardware 0 12-31-2007 05:26 PM
hard disk backup zafar466 Linux software 1 06-29-2007 02:47 AM
SATA Hard Disk not detected rajuk Linux software 4 10-24-2005 02:57 PM


All times are GMT +5.5. The time now is 03:00 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36