What is Soft Link And Hard Link In Linux?

Creating Soft, or Symbolic Link

$ mkdir test
$ cd test
$ echo "Welcome to OSTechNix" >source.file
$ cat source.file
Welcome to OSTechNix
$ ln -s source.file softlink.file
$ cat softlink.file
$ ls -lia
total 12
15745326 drwxr-xr-x 2 sk users 4096 Dec 13 14:55 .
15728642 drwx------ 49 sk users 4096 Dec 13 14:50 ..
15746561 lrwxrwxrwx 1 sk users 11 Dec 13 14:55 softlink.file -> source.file
15746185 -rw-r--r-- 1 sk users 21 Dec 13 14:53 source.file
$ rm source.file
$ cat softlink.file
cat: softlink.file: No such file or directory

Creating Hard Link

$ echo "Welcome to OSTechNix" >source.file
$ cat source.file
Welcome to OSTechNix
$ ln source.file hardlink.file
$ cat hardlink.file
Welcome to OSTechNix
$ ls -lia
total 16
15745326 drwxr-xr-x 2 sk users 4096 Dec 13 15:22 .
15728642 drwx------ 49 sk users 4096 Dec 13 14:50 ..
15745555 -rw-r--r-- 2 sk users 21 Dec 13 15:20 hardlink.file
15745555 -rw-r--r-- 2 sk users 21 Dec 13 15:20 source.file
$ rm source.file
$ cat hardlink.file

--

--

--

Tunisian software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

RadioBOSS 6.1.0.5 Free Download [Advanced]

RadioBOSS 6.1.0.5 Free Download [Advanced]

Weekly Community Update 05 April 2021–11 April 2021

HADOOP CLUSTER TASK— Steps to Contributing limited storage as Slave Node to the cluster

MLOps — What can DevOps bring to AI/ML?

Guide to choosing the modern-day MSP software

Microservice Design Patterns: Single Database Per Service

Apache Mesos 1.5: Storage, Performance, Resource Management, and Containerization Improvements

How do I learn MEAN stack?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Salmen Zouari

Salmen Zouari

Tunisian software engineer

More from Medium

Command-Line Interface — Homebrew

Bash-Scripting: Why Every Linux User Should Learn It.

Image by Boskampi (https://pixabay.com/de/users/boskampi-3788146/) on pixabay.

VScode Shortcuts + random tips

My WSL setup for productive development.