Red Hat Linux Reference Guide

Linux Introduction

VI-EDITOR

Process Management

Linux Installation

Disk Partitions & File System Management

Logical Volume Management - LVM

User & Group Administration

Package Management

Network File System - NFS

Domain Naming System - DNS

Apache HTTP Web Server

KickStart Installations

FTP server

BOOT PROCESS

Dynamic Host Configuration Protocol - DHCP

Job Scheduling

File Links

Swap Management

Log Management

Performance Management

Linux Troubleshooting

Linux Summary

Start Preparation Smartly

We have the collection to start prepartion smartly.

Start Assessment

Red Hat Linux Reference Guide

  DevOps Tech Hub

116 Followers

Soft Link vs Hard Link


What is LINK?

  • A link is a pointer to a file.
  • This pointer associates a file name with a number called an i-node number
  • An i-node is the control structure for a file (on a UNIX/Linux file system)
  • If two file names have the same i-node number, they are links to the same file
  • Use the command “ls -i” to print i-node number of each file:

Type of Links:

There are two type of Links are available in Linux

  1. Hard Links
  2. Soft or Symbolic Links

Hard Link:

  • Hard link is a reference to the block data on a file system
  • More than one name can be associated with the same block  data
  • Hard links can only refer to data that exists on the same file system
  • Hard link can not be created for a directory
  • When a file has more than one link, you can remove any one link and still be able to access the file through the remaining links.
  • Hard links are alternate to the copy command as hard link not consume additional storage space on file system.
  • Below reference output shows that f1 and f2  files are hard linked files having same i-node number referencing to same data block.
[root@ ~]$ls -li f1
4194425 -rwxr--r-- 2 root 1002 33 Jun 28 01:57 f1
[root@ ~]$ln f1 f2
[root@ ~]$ls -li f2
4194425 -rwxr--r-- 2 root 1002 33 Jun 28 01:57 f2
[root@ ~]$[iwayQ@ ~]$cat f1
Data Added for testing Hard Link
[root@ ~]$cat f2
Data Added for testing Hard Link
[root@ ~]$

Symbolic Link:

  • A Symbolic Link is an indirect pointer to a file – a pointer to the hard link to the file
  • You can create a symbolic link to a directory
  • A symbolic link can point to a file on a different file system
  • A symbolic link can point to a non-existent file (referred to as a “broken link”)
  • The symbolic link file and the pointed to file have different status information (e.g. file size, last modification time etc.)
  • The Symbolic link to a directory has a file type of “l”  (the first letter of the permission field).
  • The permissions on the link are set to “rwx” for all.
  • chmod on the link applies to the actual directory (or file), the permissions on the link stay the same can point to a non-existent directory
  • Below example referencing that f1 and f2 files are soft linked files having different i-node numbers but referencing to same data block.
[root@ ~]$ls -li f1
4194425 -rwxr--r-- 2 root 1002 33 Jun 28 01:57 f1
[root@ ~]$ln -s f1 /mnt/f2
[root@ ~]$ls -li /mnt/f2
3450729 lrwxr--r-- 2 root 1002 33 Jun 28 01:57 f2
[root@ ~]$[iwayQ@ ~]$cat f1
Data Added for testing Hard Link
[root@ ~]$cat /mnt/f2
Data Added for testing Hard Link
[root@ ~]$



Previous Next