A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/ln-command-in-linux-with-examples/ below:

ln command in Linux with Examples

ln command in Linux with Examples

Last Updated : 11 Jul, 2025

The 'ln' command in Linux is a powerful utility that allows you to create links between files. These links can either be hard links or soft (symbolic) links. If you're unfamiliar with these concepts, check out our detailed guide on Hard and Soft Links in Linux to understand their differences, use cases, and how they affect file management.

Let us get a better understanding of the In command in Linux from this article.

What is the 'ln' Command in Linux?

The ln command is primarily used to create links for files in Linux, effectively allowing one file to reference another. Doing so allows you to manage files more efficiently without creating duplicates, making this command crucial for optimizing storage and managing files in Unix-like operating systems.

Syntax:
ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
ln [OPTION]... TARGET... DIRECTORY     (2nd form)
ln [OPTION]... -t DIRECTORY TARGET...  (3rd form)

Basically, ln command is used to create hard links and soft links for files in Linux.

Three Forms of the 'ln' Command

The ln command supports three forms, each with specific use cases:

1. 1st Form: 'ln [OPTION]... [-T] TARGET LINK_NAME'

This form is used to create a link with a specified name ('LINK_NAME') to a target file ('TARGET'). Essentially, you provide the source file and the desired destination link name.

2. 2nd Form: 'ln [OPTION]... TARGET... DIRECTORY'

In this form, you provide one or more source files ('TARGET...') and a directory ('DIRECTORY') where the links will be created. Each source file is linked within the specified directory.

3. 3rd Form: 'ln [OPTION]... -t DIRECTORY TARGET...'

Similar to the second form, but here, you specify the directory first ('-t DIRECTORY'), followed by the target files. It's a more flexible way to handle multiple files.

Most Useful Options for 'In' Command Applications of 'In' Command
Practical Example of creation and deletion of links in Linux

Let us look at some of the examples of In Command in Linux to better understand the concept.

Example 1: Creating a Symbolic Link. Example 2: Removing a Symbolic Link. Example 3: Creating a Hard Link.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4