104.6 Create and Change hard-symbolic links

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

Commands : ln, ls

The link(ln) command creates a link to a file, which point a file in different directory.

Hard Links

File data can have more than one name in the different location in the same file system.

A hard link creates another file referencing the same inode as the original file.

Applications treats the hard link as the real file.

Cannot be created between two directories or filesystem/partitions.

Deleting the hard link does not delete the original file.

Symbolic Links(Soft Links)

Allows referencing files from different directories.

Can reference files in a different file system.

Deleting original file will remove the data.

 Identify Hard and Soft Links.

Both links appear differently in shell.

ln file1 file1-hardlink

  • ls -l file1-hardlink will show additional inode

ln -s file2 file2-softlink

  • ls -ll file2-softlink will show a ā€˜lā€™ in the permission string to indicate symbolic link.
  • It will also show the filename as file2-softlink -> file2

Note:

ls -lia

Show inode number

Use links to support system administration tasks.

find / inum 16789

finds files linked to specific inodes.

Changing the name of the soft-link break the link.

Leave a comment

Your email address will not be published. Required fields are marked *