Links are very similar to shortcuts, which many of you may be familiar with. They allow files to have multiple identities across the filesystem.
There are two types of links - hard and symbolic links.
A hard link is an additional name for an existing file.
To create a hardlink, simply use the
Let's demonstrate this by an example.
$ echo 'Testing' > sample.txt $ ln sample.txt sampleHardLink.txt $ cat sampleHardLink.txt
The first line simply takes the word Testing and outputs it to a newly created file called sample.txt. The second line creates the hard link, and the third line uses the
more command to output the file contents of sampleHardLink.txt. We'll learn about the
echo command and redirections (
Now if I go edit sampleHardLink.txt, the changes will also show up in my sample.txt file. Note that I can place the hard link anywhere I'd like on my file system.
A symbolic link is actually very closely related to hard links, with added improvements.
To create a symbolic link, use the
$ ln -s targetFileOrDir linkName
Try experimenting with hard and soft links own your own to get a feel for their differences and features.
To remove any existing links or files associated with a link, use the
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price
Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.$ Check price