- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create links between files in the Linux?
Before creating links, we need to understand what is link and how many types of link in the Linux system.
Links are shortcuts to access a file. It is a connection between file name and actual data in the system. We can say that a link is a pointer to a file.
Types of links
There are two types of links in the Linux system.
- Hard Links
- Soft Links or Symbolic links
Hard Links -
The hard link points to the index node of a file, the data of which is stored on the system and the size of link is equal to actual file size.
Soft Links or Symbolic Links -
The soft links are just shortcuts of actual files in the Linux system. It does not contain the contents of the actual file.
The ln command is used to create links between files in the Linux system. By default, the ln command creates a hard link of the file for creating symbolic links, we use -s or --symbolic option with the ln command.
The general syntax of the ln command is as follows.
$ ln [OPTION]... [-T] TARGET LINK_NAME $ ln [OPTION]... TARGET $ ln [OPTION]... -t TARGET... DIRECTORY $ ln [OPTION]... -t DIRECTORY TARGET...
Brief description of options available in the ln command.
|Sr.No.||Option & Description|
Create a backup of existing destination file with argument
Create a backup of existing destination file without argument
Forcefully remove existing destination files
Display a message while removing destination
Create hard links directly to symbolic links
Make symbolic links relative to link location
Create soft links instead of hard links
Specify the directory in which to create the links
Treat name of link as a normal file
Prompt what is being done
Displays a help message and then exits.
It gives info about the version and then exits.
To create a hard link of the file, we use the command specified by file name and link name as shown in below.
$ ln file.txt link.txt
The created link will be a hard link because by default, using the ln command the hard link will be created and the size of the link is equal to the actual size of the file.
To create symbolic link or soft link of a file, we use -s or --symbolic option with the ln command in the Linux system as shown in below.
$ ln --symbolic file.txt link.txt
The color of the symbolic link is different from the actual file or hard link, and also the contents of the file are only in the actual file the symbolic link is just pointing to the file.
- How to merge lines of files in the Linux system?
- How to Protect Files and Directories from Deleting in Linux
- How to sort lines of text files in Linux?\n
- How to unzip all zipped files in a Linux directory?
- How to create clickable links in a textView on Android?
- How to compare two sorted files line by line in the Linux system?
- How to create a process in Linux?
- How to search contents of multiple pdf files on Linux?
- How to split or break large files into pieces in Linux?
- How to compare the files available in two directories using diff command in Linux?
- How to remove files and directories in the Linux operating system using the terminal?\n
- How to remove sections from each line of files in the Linux system?\n
- How to create bottom bordered (underline) navigation links with CSS?
- How to create powerpoint files using Python
- How to find the files in Linux that have been changed in the last 24 hours?