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
The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.$ Check price
This foam seat cushion relieves lowerback pain, numbness and pressure sores by promoting healthy weight distribution, posture and spine alignment. Furthermore, it reduces pressure on the tailbone and hip bones while sitting. Perfect for sitting on the computer desk for long periods of time.$ Check price