john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Symlink symbolic link shortcut hard link

A symbolic link contains no data of its own, only a reference to another file. It can even contain a reference to a directory.
It does not take up space and most programs will be "fooled" into believing they have actual access.

ls -al

lrwxrwxrwx 1 root root 20 2009-02-19 13:00 link-to-webpages -> /trac-root/webpages/

SOFT LINK ln -s Source link-to-Source

A Symbolic link can have permissions, be copied or moved just like a file (or directory). Note that the above is a "relative path" so

ln -s SourceDirectory link-to-SourceDirectory

mv link-to-SourceDirectory /folder/anotherfolder

A symbolic link sometimes should have a universal path ln -s /folder/SourceDirectory link-to-SourceDirectory

chown -h ubuntu:ubuntu symlink_name # modify the owner of the symlink, not the target


PERMISSIONS are established by the target file/directory, the link cannot have permissions


HARD LINK ln source link-to-source

The reason why hard links are sometimes used in preference to symbolic links is that some programs are not fooled by a symbolic link: if you, say, have a script that uses cp to copy a file, it will copy the symbolic link instead of the file it points to14.1. A hard link however will always be seen as a real file.

Hard links however cannot be made between files on different file-systems. They also cannot be made between directories.


  • « heroku tdd flask postgres sql mock
  • heroku continued custom domain new relic monitor ping keepalive »

Published

Mar 10, 2014

Category

linux

~215 words

Tags

  • hard 6
  • link 4
  • linux 249
  • shortcut 3
  • symbolic 1
  • symlink 2