LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2004, 06:24 PM   #1
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 14.1 (multilib)
Posts: 1,220

Rep: Reputation: 57
If I delete a link is the file deleted


I am having difficulty understanding links.

If I create a link to a file; for instance, so that its icon is shown on the Desktop. If I then delete the link by rm <file> or by sending it to trash does the actual file get deleted.

I just sent a link to my whole windows hard disk to trash and then I realised it might cause a problem and unlinked it.

I had assumed that if I dragged aWould that be wrong. file from Konquerer to my desktop and created a link that I was just making a Windows-like shortcut. Is that wrong?

Thanks
 
Old 04-29-2004, 06:32 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Deleting a link should not remove the file. If your unsure, create a backup of the file, then link the actual file. Then remove the link and see if your file is still there.
 
Old 04-29-2004, 06:37 PM   #3
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 14.1 (multilib)
Posts: 1,220

Original Poster
Rep: Reputation: 57
That is reassurring. Thanks
 
Old 04-29-2004, 09:48 PM   #4
mysterio
Member
 
Registered: Sep 2003
Location: Springfield Ma.
Distribution: Mandrake 9.2,Knoppix 3.7,Slackware 10.0, FreeBSD. 5.3, OpenBSD 3.6, NetBSD 2.0, Debian
Posts: 275

Rep: Reputation: 30
If it's a soft or symlink it won't, but if it's a hard link I think it will delete the file.
 
Old 04-29-2004, 10:00 PM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally posted by mysterio
If it's a soft or symlink it won't, but if it's a hard link I think it will delete the file.
That is correct, forgot to mention that. Best thing to do though if in doubt, just make a backup copy of the linked file.. always play it safe, cause you never know right..
 
Old 04-30-2004, 02:24 AM   #6
levian
LQ Newbie
 
Registered: Aug 2003
Location: kadin, jkt
Distribution: Dolphin,Shrike,98
Posts: 20

Rep: Reputation: 0
Hi all,
I am trying to get and add more information about linking file.
I tried myself linking a file in hard and symbolic way. I found that we can not make a hard link to another partition, no matter what file system used in. By making a hard link we actually making another name (new file) of the same data that the first name (old file) refer to. The data stored in hard disk, whose certain range of address, is one, but the file name that refer to it can be more than one (by making a hard link). So then, if we delete one file, we will still have another.
Differ than hard link, symbolic link can be made to another partition which uses native linux file system. What the symbolic link actually does is only link a new file name to the old (real) file name, without knowing of its data. This means the sym link (new file) does not know in which area the data reside in the hard disk. Thus, if we delete the sym link, the real file name with its data will still remain. On the other hand, if we delete the real file, the sym link will become a broken link.
I hope that is correct, pls remind me if im wrong.

Cheers
 
Old 04-30-2004, 05:33 AM   #7
robartes
Member
 
Registered: Oct 2003
Location: Mechelen, BE
Distribution: Mandrake as base, most software hand rolled
Posts: 80

Rep: Reputation: 15
Quote:
Originally posted by mysterio
If it's a soft or symlink it won't, but if it's a hard link I think it will delete the file.
Actually, it won't It will just decrease the ref count of the original inode by one. But as there is still the directory entry for the original file referencing it, the ref count goes down to 1, not zero (assuming there was only one ref to the file), so the file remains happily alive.
 
Old 04-30-2004, 05:44 AM   #8
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 14.1 (multilib)
Posts: 1,220

Original Poster
Rep: Reputation: 57
The difference of opinion amongst experts is alarming.

Are the links made in kde by dragging and choosing copy/move/link/ hard or soft?
 
Old 04-30-2004, 06:11 AM   #9
robartes
Member
 
Registered: Oct 2003
Location: Mechelen, BE
Distribution: Mandrake as base, most software hand rolled
Posts: 80

Rep: Reputation: 15
Quote:
Originally posted by levian
Hi all,
I am trying to get and add more information about linking file.
I tried myself linking a file in hard and symbolic way. I found that we can not make a hard link to another partition, no matter what file system used in.
Cheers
Hard links (or just links) are actually directory entries which point to the same inode as the original file. Thus if you do:

Code:
ln a b
b is now a directory entry whose inode is the same as that of file a. This means that they point to the same data. That is why you cannot cross filesystem boundaries with hard links, as inode are file system specific.

Symlinking:

Code:
ln -s a b
creates a second file, with its own inode, with a special type that causes it to refer to the first file. It is effectively a different file - just one that points to the first one.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete Link? sikandar Red Hat 2 10-06-2004 01:19 AM
How to delete a symbolic link aroop Linux - Newbie 24 07-29-2004 02:52 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 03:46 AM
Can't delete symbolic link chichibabin Linux - General 1 01-20-2004 07:30 AM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 02:13 PM


All times are GMT -5. The time now is 05:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration