Sponsored Content
Full Discussion: HardLinks and Softlinks
Top Forums Shell Programming and Scripting HardLinks and Softlinks Post 302556440 by ahmad.diab on Sunday 18th of September 2011 02:17:00 PM
Old 09-18-2011
Code:
you can control the permission by using "chmod" command , to create a soft link use "ln -s" command

---------- Post updated at 21:17 ---------- Previous update was at 21:15 ----------

Code:
Creating Hard and Symbolic Links
To create a symbolic link or a hard link, you use the same command name, In, which has the following syntax:

In [-fns] <source> [<target>]


Hard link is the default output of the ln command-that is, if you issue the ln command without the - s option, a hard link will be created.
 

In this command, <source> is the original file and <target> is the link that will be created and linked to the <source>. The options for the command are listed here:

-f (force). Link the file without questioning the user.

-n. If the <target> is an existing file, do not overwrite the content of the file. The -f option overrides this option.

-s. Create a symbolic link. The default is a hard link.

The hard links and symbolic links are compared in Table 4-2 

Table 4-2: Comparison of hard and soft links  Characteristic
 Hard Link
 Soft Link
 
Existence of original file
 You cannot create a hard link to a file that does not exist.
 You can create a symbolic link to a file that does not exist.
 
File systems
 A hard link cannot span file systems-that is, the link and the file it points to have to be in the same file system.
 A soft link can span file systems.
 
Kind of original file
 A hard link can only point to a file that is not a directory.
 A soft link can point to a file or a directory.
 
I-node
 A hard link has the same inode number as the file it points to.
 A soft link has a different inode from the file it points to.

 

6 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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
LN(1)							    BSD General Commands Manual 						     LN(1)

NAME
ln, link -- make links SYNOPSIS
ln [-fhinsv] source_file [target_file] ln [-fhinsv] source_file ... target_dir link source_file target_file DESCRIPTION
The ln utility creates a new directory entry (linked file) which has the same modes as the original file. It is useful for maintaining mul- tiple copies of a file in many places at once without using up storage for the ``copies''; instead, a link ``points'' to the original copy. There are two types of links; hard links and symbolic links. How a link ``points'' to a file is one of the differences between a hard and symbolic link. The options are as follows: -f If the target file already exists, then unlink it so that the link may occur. (The -f option overrides any previous -i options.) -h If the target_file or target_dir is a symbolic link, do not follow it. This is most useful with the -f option, to replace a symlink which may point to a directory. -i Cause ln to write a prompt to standard error if the target file exists. If the response from the standard input begins with the char- acter 'y' or 'Y', then unlink the target file so that the link may occur. Otherwise, do not attempt the link. (The -i option over- rides any previous -f options.) -n Same as -h, for compatibility with other ln implementations. -s Create a symbolic link. -v Cause ln to be verbose, showing files as they are processed. By default, ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file sys- tems. A symbolic link contains the name of the file to which it is linked. The referenced file is used when an open(2) operation is performed on the link. A stat(2) on a symbolic link will return the linked-to file; an lstat(2) must be done to obtain information about the link. The readlink(2) call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories. Given one or two arguments, ln creates a link to an existing file source_file. If target_file is given, the link has that name; target_file may also be a directory in which to place the link; otherwise it is placed in the current directory. If only the directory is specified, the link will be made to the last component of source_file. Given more than two arguments, ln makes links in target_dir to all the named source files. The links made will have the same name as the files being linked to. When the utility is called as link, exactly two arguments must be supplied, neither of which may specify a directory. No options may be sup- plied in this simple mode of operation, which performs a link(2) operation using the two passed arguments. SEE ALSO
link(2), lstat(2), readlink(2), stat(2), symlink(2), symlink(7) COMPATIBILITY
The -h, -i, -n and -v options are non-standard and their use in scripts is not recommended. They are provided solely for compatibility with other ln implementations. STANDARDS
The ln utility conforms to IEEE Std 1003.2-1992 (``POSIX.2''). The simplified link command conforms to Version 2 of the Single UNIX Specification (``SUSv2''). HISTORY
An ln command appeared in Version 1 AT&T UNIX. BSD
December 30, 1993 BSD
All times are GMT -4. The time now is 10:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy