Create and Change Hard and Symbolic Links

Exam Objectives Covered:

  • Create links
  • Identify hard and/or soft links
  • Copying versus linking files
  • Use links to support system administration tasks

Links in Linux are synonymous with shortcuts in the Windows world. They are not identical, but the idea is similar.  Specifically, the command ‘ln’, is used to make links between files. There are two types of links, symbolic and hard. The following definitions come from Practice Labs:

Symbolic links: It is a pointer to the source file. The permissions that apply to the source file also apply to the symbolic link. It can point to a source file on the local or remote filesystem.

Hard links: It is another directory entry for the source file and carries that same properties, such as file permissions, of the source file. If you delete one file, the other file remains intact. A hard link must exist in the same local filesystem.

The interesting thing about links is that a hard link is tied to the original file, but not dependent on it. This means that if you create a hard link to a file and then delete the original, the linked file will still work. This is not the case with a symbolic link. If you create a symbolic link and remove the original file, the symbolic link will not have anything to link to. A way to be sure that your links are bound, or not, to the original file is by listing the directory, using ‘ls’, with the -i option. This prints the index number of each file.

To support system administration, links are useful when you do not want to make multiple copies of the same file. If you were to update a file, you would have to make the same changes on all the files. If you use hard links, then when you update the file, your changes are seen in all links.

Another situation in which links support system administration is when linking shared objects. The link can make it easier to reference frequently used libraries. It also aides in version control. Application developers can link to shared objects using major versions. Administrators can link shared objects to the major versions. This allows multiple versions to exist for compatibility reasons. If you list the contents of the ‘/lib64’ directory, you will see something like this:

libcrypt.so.1 -> libcrypt-2.17.so

The developer can reference the ‘libcrypt.so.1’ shared object, but the administrator can install any variant of the libcrypt library. This means that if an update were to come out or an older version was needed, it could be located in /lib64 under the naming conventions and linked to the single named variant.

Hard Links and Symbolic Links

To view examples of creating symbolic and hard links, take a look at the screenshots below. You will see the hard link and the original file have the same inode. The symbolic link has a different inode and therefore is not the same file.

To create a hard link:

Syntax: ln TARGET LINK_NAME
Example: ln original-file hard-link


To create a symbolic link:

Syntax: ln [-s|--symbolic] TARGET LINK_NAME
Example: ln -s original-file symbolic-link

Filesystem Hierarchy Standard (FHS)

I wanted to begin with the Filesystem Hierarchy Standard (FHS) which is currently at version 3.0. The standard can be referenced below as well as at http://refspecs.linuxfoundation.org/fhs.shtml.

Filesystem Hierarchy Standard 3.0

When I first began using Linux, I realized that all the files and directories were arranged in a particular way. I wondered why Linux always seemed to have this organization and what each directory was for. After many years of just “going with it” I finally came across this resource. It was originally written in 2004 but version 3.0 was released in 2015. Its goal is, “to support interoperability of applications, system administration tools, development tools, and scripts as well as greater uniformity of documentation for these systems.”

The hierarchy is as follows:

Directory Description
bin Essential command binaries
boot Static files of the boot loader
dev Device files
etc Host-specific system configuration
lib Essential shared libraries and kernel modules
media Mount point for removable media
mnt Mount point for mounting a filesystem temporarily
opt Add-on application software packages
run Data relevant to running processes
sbin Essential system binaries
srv Data for services provided by this system
tmp Temporary files
usr Secondary hierarchy
var Variable data

CompTIA Linux+

I am starting my journey to become CompTIA Linux+ certified! Technically, I started on February 1, but am just now writing this. I have always been curious about Linux and dabbled here and there; I just have never dived in deep enough to be proficient. I want to change that. As an end user, I can get by in a Linux GUI and somewhat on the command line. I want to have greater knowledge than that. I want to be able to administer Linux systems on a professional level with confidence and without having to have Google opened up all the time. I would like to be able to add ‘Linux Administrator’ to my résumé under skills someday.

For this test, I am again going to use ITPro.tv (https://itpro.tv/) combined with Safari Books Online (https://www.safaribooksonline.com/) and Quizlet (https://quizlet.com/). Between the videos, books, practice tests, practice labs, and online flashcards, I have a ton of resources to take the deep dive and stay constantly engaged. I feel the fastest and most successful method of learning is to have multiple inputs. This has proven very successful for me. I also compare and contrast real-world experiences to something I am learning and that helps reinforce the material for me.

I am excited for this opportunity and look forward to getting this accomplished!