Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

4.5.5 Links

There are two methods of associating a file foo with a different filename bar.

  • a hard link is a duplicate name for an existing file (ln foo bar),

  • a symbolic link, or "symlink", is a special file that points to another file by name (ln -s foo bar).

See the following example for the changes in link counts and the subtle differences in the result of the rm command.

     $ echo "Original Content" > foo
     $ ls -l foo
     -rw-r--r--    1 osamu    osamu           4 Feb  9 22:26 foo
     $ ln foo bar     # hard link
     $ ln -s foo baz  # symlink
     $ ls -l foo bar baz
     -rw-r--r--    2 osamu    osamu           4 Feb  9 22:26 bar
     lrwxrwxrwx    1 osamu    osamu           3 Feb  9 22:28 baz -> foo
     -rw-r--r--    2 osamu    osamu           4 Feb  9 22:26 foo
     $ rm foo
     $ echo "New Content" > foo
     $ cat bar
     Original Content
     $ cat baz
     New Content

The symlink always has nominal file access permissions of "rwxrwxrwx", as shown in the above example, with the effective access permissions dictated by the permissions of the file that it points to.

The . directory links to the directory that it appears in, thus the link count of any new directory starts at 2. The .. directory links to the parent directory, thus the link count of the directory increases with the addition of new subdirectories.


Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire