\documentclass{cmlab} \RCS $Revision: 1.1 $ \usepackage{alltt,key} \newcommand*{\labTitle}{Links: Hard Links and Symbolic Links} \begin{document} \section{Aim} \label{sec:aim} You will understand hard and soft links to the point where you can use them easily to solve many problems. \section{Background} \label{sec:background} Links (paritcularly symbolic links) are incredibly useful in many situations for the system adminstrator. They can solve problems such as installing software in a partition that has enough space, but which must appear in another location (perhaps in a partition that does not have enough space). But there are very many other applications. A \emph{directory} is a file that is has two entries for each file: a \emph{file name} and an \emph{inode number}. The inode number uniquly identifies a data structure that contains all the information about the file except its file name. To see the directory entries as they are stored in the directory, type: \begin{alltt} ls -Ui \emph{directory-name} \end{alltt} A \emph{hard link} is another directory entry for a file that has another directory entry in the same parition. Each of these links has the same inode number. If the links are in the same directory, they must have different file names. To create a hard link \emph{link} to the file \emph{source}, type: \begin{alltt} ln \emph{source} \emph{link} \end{alltt} A \emph{soft link} is a small file that contains the name of another file. The \section{Limitations of hard and soft links} \label{sec:limitations} \subsection{Hard links} \label{sec:hard-link-limitations} \begin{itemize} \item A hard link must be to a file that is not a directory and must be within the same disk partition. \item The source file must exist. \item It is hard to find all the links to the file if they are scattered in different places on the partition. \end{itemize} \subsection{Symbolic links} \label{sec:sym-link-limitations} A symbolic link has few limitations, but there are some; the source file must be visible from the position of the link. Some applications such as the ftp server have a different root directory from the main directory system (using the \emph{chroot} system call). Another case is where a partition is mounted in a different place from usual. In such cases you need to use a \emph{relative} symbolic link. A relative symbolic link is linked to a name that does not start with a \texttt{/}. \section{All about Symbolic Links} \label{sec:symbolic-links} To create a symbolic link, you type: \begin{alltt} ln -s \emph{source} \emph{link} \end{alltt} The result will look something like this: \end{document}