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
Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.$ 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