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 (2 votes, average: 5.00 out of 5)
Loading...

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz

Upcoming Events (CET)

There are no events.

RHCSA7: Task of the day

Allowed time: 10 minutes.
Archive and compress the content of the /opt directory (create files if none exists).
Uncompress and unarchive the resulting file in /root

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a fileio backstore of 100MB called /opt/shareddata with CHAP authentication (username=usr/password=pwd), xfs filesystem and standard firewall configuration.

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 ...