Hard and Symbolic links on Linux

Hard and Symbolic links on Linux

What is Linux?

Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn?t function.

what are hard and symbolic links on Linux ?

A soft link does not contain the data in the target file.

A soft link points to another entry somewhere in the file system.

A soft link has the ability to link to directories, or to files on remote computers networked through NFS.

Deleting a target file for a symbolic link makes that link useless.

A hard link preserves the contents of the file.

A hard link cannot be created for directories, and they cannot cross filesystem boundaries or span across partitions.

In a hardlink you can use any of the hardlink names created to execute a program or script in the same manner as the original name given.

How to create a hard links in Linux or Unix

To create a hard links on a Linux or Unix-like system:

  1. Create hard link between sfile1file and link1file, run: ln sfile1file link1file
  2. To make symbolic links instead of hard links, use: ln -s source link
  3. To verify soft or hard links on Linux, run: ls -l source link

How to Create Symbolic Links

To use the ln command, open a terminal window and enter the command with the following format:

ln [-sf] [source] [destination]        

  • By default, the?ln?command creates a hard link.
  • Use the?-s option to create a soft (symbolic) link.
  • The?-f option will force the command to overwrite a file that already exists.
  • Source is the file or directory being linked to.
  • Destination?is the location to save the link – if this is left blank, the symlink is stored in the current working directory.

For example, create a symbolic link with:

ln -s test_file.txt link_file.txt        

This creates a symbolic link?(link_file.txt)?that points to the?test_file.txt.

To verify whether the symlink has been created, use the ls command:

ls -l link_file.txt        


the difference between hard and symbolic links on linux

Aucun texte alternatif pour cette image



要查看或添加评论,请登录

ahmed zghal的更多文章

  • Welcome To Staffy Code Base

    Welcome To Staffy Code Base

    Empowering Your Workforce "Welcome to the future of workplace management with Staffy, the cutting-edge mobile…

    1 条评论
  • What is like being a Designer (UI/UX)

    What is like being a Designer (UI/UX)

    Overview Spotify is a digital music service that gives you access to millions of songs, podcasts, and videos from…

  • Portfolio Project: TunisianDoom

    Portfolio Project: TunisianDoom

    Introduction: this is a simple game made by me Mohamed Ahmed Zghal, it is a game meant to make you have fun and explore…

  • What happens when you type google.com in your browser and press Enter

    What happens when you type google.com in your browser and press Enter

    Nowadays in the digital era, we use the internet for just about everything. We can study, connect with our friends and…

  • Internet of Things (IoT)

    Internet of Things (IoT)

    What is IOT ? The internet of things, or IoT, is a system of interrelated computing devices, mechanical and digital…

  • The concept of Recursion

    The concept of Recursion

    Recursion, what is it and why use it? ? Recursion is a programming technique using a function that calls itself one or…

  • Python3: Mutable, Immutable... everything is object!

    Python3: Mutable, Immutable... everything is object!

    1 >>> Introduction In object-oriented programming languages like Python, an object is an entity that contains data…

  • The differences between static and dynamic libraries

    The differences between static and dynamic libraries

    Why use libraries? As mentioned before, libraries allow us to store function definitions, aka pieces of code that will…

  • What happens when you type `ls -l *.c` in the shell

    What happens when you type `ls -l *.c` in the shell

    Let’s take a look at what happens when you type ls *.c in the shell.

  • All the steps of compilation

    All the steps of compilation

    C is a compiled language. Its source code is written using any editor of a programmer’s choice in the form of a text…

社区洞察

其他会员也浏览了