HardLinks and Softlinks

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HardLinks and Softlinks
# 8  
Old 09-18-2011
A soft link is an directory entry that points, by name, to another directory entry, which may or may not exist. Since it's pointing by name the target can even reside on a different mount point.

Hard links, on the other hand, are directory entries that point to an inode used by another directory entry, and is still valid if the original entry is removed. Since all access information but the name is saved with the inode, both entries will always have the same access rights, timestamps, and user/group information. Also, due to sharing the same inodes, a hard link can't cross the boundary between mount points.
# 9  
Old 09-18-2011
I'll initially point you to the ln man page for all of the good details

Man Page for ln (FreeBSD Section 1) - The UNIX and Linux Forums

The -f option (force) has a different description depending on your flavour of *NIX. In general it causes the link to be created regardless. At least one of the man pages indicates that it "removes existing destination files", so see the version of the man page for your system to know exactly what the option should do.

I've always thought of the link command in this manner:

 ln <existing-file> <new-link-to-existing>

rather than source and destination. So, if you have a file foo, and want to create a link l_foo, the command would be:
ln foo l_foo

Whether or not you need the -f option depends on your system, whether or not you have write access to the existing file and maybe other factors.

A hard link is another directory reference to the exising file. It can be in the same directory as the first/other reference(s) or it can be in a different directory as long as that directory exists on the same physical filesystem. After you create the hard link to foo, executing ls -al foo will show that the link count (usually the value in column two of the output) has increased (probably 2).

Hope this makes things a bit clearer.
# 10  
Old 09-18-2011
kindly refer to my reply in my second post to see the comparison between soft and hard links

# 11  
Old 09-18-2011
Ok great thanks for the advice
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Solaris

Will softlinks occupy space in Solaris10

I have a pen drive1 with UFS file system and it has 43G used. It has a hell lot of soft links to other files which are located in a second pen drive2. We partitioned the file system on sun sparc machine, such that / has around 150G space.Now when we are copying the files from pen drive 1 to / on... (3 Replies)
Discussion started by: crackperl
3 Replies

2. UNIX for Dummies Questions & Answers

Create softlinks between 2 different hosts

Hi I want to create softlinks, my source files and folders are placed in one server(hostname: info-1) and i want to access those files from different host(hostname :info-2). file and folder names in info-1 host. file1 folder1 Thanks, Mallik. (1 Reply)
Discussion started by: tmalik79
1 Replies

3. UNIX for Dummies Questions & Answers

dump/restore of a fs with 100 of millions hardlinks

Hi :-) i have a dump of a backupdisk (~540GB / ext3). The Backups have some 100 millions of hardlinks (backups are created with storeBackup). The OS is linux. A restore of a directory ended after some days with the errormessage "no memory to extend symbol table" The restore of the complete... (0 Replies)
Discussion started by: turricum
0 Replies

4. AIX

IHS 6.1 on AIX - problem with symlinks / symbolic links / softlinks

Hello, I got an IHS 6.1 installed and want to publish a directory with an index of files, directories and symlinks / symbolic links / soft links, last ones being created with the usual Unix command "ln -s .... ....". In httpd.conf I've tried following for that directory: Options Indexes... (1 Reply)
Discussion started by: zaxxon
1 Replies

5. UNIX for Dummies Questions & Answers

How to list hardlinks?

Q1: Let's say I create a hard-link bar.c in /tmp to a file foo.c which resides in /var/tmp. Is there a easy way to find out which file /tmp/bar.c hardlinks to (and vice-versa - i.e which files have got hard-linked from /var/tmp/foo.c) when one does not (and wants to) know the location of the other... (0 Replies)
Discussion started by: mahatma
0 Replies

6. UNIX for Dummies Questions & Answers

search for hardlinks based on filename via find command

I am using command substitution into a find command in a script where I have built a menu to do a bunch of tasks within my unix account. When I choose the options for to find a file/files that have the same inode of the entered filename, ie hardlinks, nothing shows up. When I choose the appropiate... (2 Replies)
Discussion started by: hunternjb
2 Replies
Login or Register to Ask a Question