SYS: Create hard and soft links.

Share this link

Note: This is an RHCSA 7 exam objective.

Hard and Soft Links

To create a hard link pointing to a existing file (here /path/file1) (both locations have to be in the same file system), type:

# ln /path1/file1 /path2/file2

Note1: It is not possible to create a hard link pointing to a directory.
Note2: In RHEL 7, only the owner of a file can create a hard link pointing to it. To get the RHEL 6 behavior back, add fs.protected_hardlinks = 0 in the /etc/sysctl.conf file and execute the command sysctl -p.

To create a soft link pointing to a existing file or directory (here /path/file1), type:

# ln -s /path1/file1 /path2/file2

Check the result:

# ls -i /path2/file2

Additional Resources

Sander van Vugt provides a video about Understanding Links in the Linux File System (3min/2016).

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading...

Leave a Reply

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 10 minutes.
Create a XFS file system of 100MB. Mount it under /mnt. Then, increase its size by 50MB.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a httpd virtual server called "dummy" with DocumentRoot assigned to /opt.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...