Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»Bash Shell»How to Create Symbolic Link of File in Linux

    How to Create Symbolic Link of File in Linux

    RahulBy RahulNovember 25, 20141 Min ReadUpdated:May 9, 2019

    Command:

    ln -s /tmp/original.txt /tmp/linkfile.txt

    Example

    Create Soft Link

    Use following command to create a soft link of Apache configuration file under /etc directory. While creating softlink of file inode number will be different that original file.

    ln -s /etc/httpd/conf/httpd.conf /etc/httpd.conf
    

    Check soft link and original file inode number.

    ls -li /etc/httpd/conf/httpd.conf /etc/httpd.conf
    
    4035744 lrwxrwxrwx 1 root root 11 Jan 10 03:19 /etc/httpd.conf -> /etc/httpd/conf/httpd.conf
    6130556 -rw-r--r-- 1 root root 24 Nov 16 11:29 /etc/httpd/conf/httpd.conf
    

    Create Hard Link

    Use following command to create a hard-link of Apache configuration file under /etc directory. While creating hard-link of file inode number will be same as original file.

    ln /etc/httpd/conf/httpd.conf /etc/httpd.conf
    

    Check soft link and original file inode number.

    ls -li /etc/httpd/conf/httpd.conf /etc/httpd.conf
    
    6130556 -rw-r--r-- 2 root root 24 Nov 16 11:29 /etc/httpd.conf
    6130556 -rw-r--r-- 2 root root 24 Nov 16 11:29 /etc/httpd/conf/httpd.conf
    

    You can read this tutorial to understand differences between soft link and hard link on the Linux file system.

    hardlink link softlink
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Sublime Text 3 on Ubuntu 18.04 & 16.04
    Next Article How To Install Phalcon PHP Framework on Ubuntu 18.04 & 16.04

    Related Posts

    How to Backup Website to Amazon S3 using Shell Script

    Updated:March 24, 20222 Mins Read

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    Creating Menu in Shell Script (Linux Select Command)

    Updated:May 31, 20222 Mins Read

    Bash Break and Continue

    Updated:November 9, 20213 Mins Read

    Bash String Concatenate

    Updated:January 5, 20222 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.