Bookmark this page

Guided Exercise: Make Links Between Files

Create hard links and symbolic links and compare the results.

Outcomes

  • Create hard links and symbolic links between files.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start files-make

Instructions

  1. Use the ssh command to log in to the servera machine as the student user. The system's configuration supports the use SSH keys for authentication; therefore, you do not require a password.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$
  2. Create a hard link called /home/student/links/file.hardlink for the file /home/student/files/target.file. Verify the link count for the original file and the new linked file.

    1. View the link count for the file /home/student/files/target.file.

      [student@servera ~]$ ls -l files/target.file
      total 4
      -rw-r--r--. 1 student student 11 Mar  3 06:51 files/target.file
    2. Create a hard link called /home/student/links/file.hardlink. Link it to the file /home/student/files/target.file.

      [student@servera ~]$ ln /home/student/files/target.file \
      /home/student/links/file.hardlink
    3. Verify the link count for the original file /home/student/files/target.file and the new linked file, /home/student/files/file.hardlink. The link count should be 2 for both files.

      [student@servera ~]$ ls -l files/target.file links/file.hardlink
      -rw-r--r--. 2 student student 11 Mar  3 06:51 files/target.file
      -rw-r--r--. 2 student student 11 Mar  3 06:51 links/file.hardlink
  3. Create a symbolic link called /home/student/tempdir that points to the /tmp directory on the servera machine. Verify the newly created symbolic link.

    1. Create a symbolic link called /home/student/tempdir and link it to the /tmp directory.

      [student@servera ~]$ ln -s /tmp /home/student/tempdir
    2. Use the ls -l command to verify the newly created symbolic link.

      [student@servera ~]$ ls -l /home/student/tempdir
      lrwxrwxrwx. 1 student student 4 Mar  3 06:55 /home/student/tempdir -> /tmp
  4. Return to the workstation system as the student user.

    [student@servera ~]$ exit
    logout
    Connection to servera closed.
    [student@workstation ~]$

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish files-make

Revision: rh199-9.3-8dd73db