ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Clarifying Symbolic Links

    IT Discussion
    5
    25
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wirestyle22W
      wirestyle22
      last edited by wirestyle22

      I am told to think of symbolic links as shortcuts but I have never tried to refer to a shortcut instead of a file and symbolic links seem to behave very differently from shortcuts. Below I'm just trying to check if my understanding is correct.

      Example:

      #create a symbolic link of file file1 and name it ian in the same directory
      ln -s file1 ian

      Any changes made to ian will automatically apply to file1 and anything that points to ian will always reference file1. This allows me to change a file I am referencing directly, let's say I changed file1 to file2 and everything within the config remains the same, ie it will all still reference ian.

      Am I understanding this correctly? Are there other use cases for this and if so can you explain what they are and why? Thanks.

      Q: What would happen if I deleted file1 but kept ian alive? Can a symbolic link exist if the file itself does not?
      A: Interesting. The link exists but is broken. Nothing exists inside of ian anymore. This is starting to get too real to life. 😄

      scottalanmillerS 2 Replies Last reply Reply Quote 0
      • matteo nunziatiM
        matteo nunziati
        last edited by

        file names are just metadata in unix like OSes. when you create a file you can reference it by a number of file names. names include paths for the sake.

        when you create an hard link you just increase by one the reference count of the pointers to a file content. hard links are nice but not necessarily the right thing. Maybe you just want a lightweight version of them, named symbolic link. among other things symlinks do not increase the ref count for a file.

        basically now you are referencing a given file by 2 names.

        more here(it is freebsd but applies to linux too)

        1 Reply Last reply Reply Quote 0
        • scottalanmillerS
          scottalanmiller @wirestyle22
          last edited by

          @wirestyle22 said in Clarifying Symbolic Links:

          I am told to think of symbolic links as shortcuts but I have never tried to refer to a shortcut instead of a file ...

          Never? Loads of things on Windows do this automatically. It's everywhere.

          wirestyle22W 1 Reply Last reply Reply Quote 0
          • wirestyle22W
            wirestyle22 @scottalanmiller
            last edited by

            @scottalanmiller said in Clarifying Symbolic Links:

            @wirestyle22 said in Clarifying Symbolic Links:

            I am told to think of symbolic links as shortcuts but I have never tried to refer to a shortcut instead of a file ...

            Never? Loads of things on Windows do this automatically. It's everywhere.

            No, I have always referenced the file directly unless this is occurring without my knowledge (possible).

            scottalanmillerS 1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller @wirestyle22
              last edited by

              @wirestyle22 said in Clarifying Symbolic Links:

              Q: What would happen if I deleted file1 but kept ian alive? Can a symbolic link exist if the file itself does not?

              Yes, a symbolic link is a text file that contains the name of the file that it references. So for example, in your example, your text file ian contants "file1" in it. That exists, even if file1 does not. The text file has no logic, it can't tell if the file references does or does not exist. It doesn't care. It has one job to do, when asked a file name, it returns the file it holds in itself. That is all. Same as a shortcut.

              1 Reply Last reply Reply Quote 1
              • scottalanmillerS
                scottalanmiller @wirestyle22
                last edited by scottalanmiller

                @wirestyle22 said in Clarifying Symbolic Links:

                @scottalanmiller said in Clarifying Symbolic Links:

                @wirestyle22 said in Clarifying Symbolic Links:

                I am told to think of symbolic links as shortcuts but I have never tried to refer to a shortcut instead of a file ...

                Never? Loads of things on Windows do this automatically. It's everywhere.

                No, I have always referenced the file directly unless this is occurring without my knowledge (possible).

                So, for example, if you want a handy access to a program you would move the program itself to your desktop or into the menu rather than having a symlink there to just point to it?

                1 Reply Last reply Reply Quote 1
                • scottalanmillerS
                  scottalanmiller
                  last edited by

                  Things in Windows that are normally shortcuts are the Windows menu, the quick launch bar and the desktop (many things on the desktop.) Loads of applications, including video games, make shortcuts on your desktop automatically. This is nearly as common as not.

                  wirestyle22W 1 Reply Last reply Reply Quote 1
                  • wirestyle22W
                    wirestyle22 @scottalanmiller
                    last edited by

                    @scottalanmiller said in Clarifying Symbolic Links:

                    Things in Windows that are normally shortcuts are the Windows menu, the quick launch bar and the desktop (many things on the desktop.) Loads of applications, including video games, make shortcuts on your desktop automatically. This is nearly as common as not.

                    If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                    scottalanmillerS 1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller
                      last edited by

                      A common usage of symlinks is for versioning. Example...

                      Folder "Application" contains several versions of an application:

                      app-1.02
                      app-1.03
                      app-1.04
                      

                      You will often do this so that you are not deleting versions when upgrading. A symlink called current might point to the version that you are currently running. One called last will often point to the one you were running before current.

                      1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller @wirestyle22
                        last edited by

                        @wirestyle22 said in Clarifying Symbolic Links:

                        If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                        What do you think a shortcut does in Windows?

                        wirestyle22W 1 Reply Last reply Reply Quote 0
                        • scottalanmillerS
                          scottalanmiller
                          last edited by

                          For all intents and purposes, a Windows shortcut = UNIX symbolic link. They are both text files containing the name of the file that they point to. They both behave essentially identically.

                          1 Reply Last reply Reply Quote 0
                          • wirestyle22W
                            wirestyle22 @scottalanmiller
                            last edited by wirestyle22

                            @scottalanmiller said in Clarifying Symbolic Links:

                            @wirestyle22 said in Clarifying Symbolic Links:

                            If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                            What do you think a shortcut does in Windows?

                            In windows I can name a shortcut ian that is referring to file1 and then when configuring a piece of software that needs to refer to it I can use the shortcut instead of the file? That is something I've never done in windows. I hope I'm being clear, I'm trying to be.

                            scottalanmillerS 1 Reply Last reply Reply Quote 0
                            • scottalanmillerS
                              scottalanmiller @wirestyle22
                              last edited by

                              @wirestyle22 said in Clarifying Symbolic Links:

                              @scottalanmiller said in Clarifying Symbolic Links:

                              @wirestyle22 said in Clarifying Symbolic Links:

                              If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                              What do you think a shortcut does in Windows?

                              In windows I can name a shortcut ian that is referring to file1 and then when configuring a piece of software that needs to refer to it I can use the shortcut instead of the file?

                              Of course, what did you think a shortcut did? That's the only thing that it does.

                              wirestyle22W 1 Reply Last reply Reply Quote 0
                              • wirestyle22W
                                wirestyle22 @scottalanmiller
                                last edited by wirestyle22

                                @scottalanmiller said in Clarifying Symbolic Links:

                                @wirestyle22 said in Clarifying Symbolic Links:

                                @scottalanmiller said in Clarifying Symbolic Links:

                                @wirestyle22 said in Clarifying Symbolic Links:

                                If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                                What do you think a shortcut does in Windows?

                                In windows I can name a shortcut ian that is referring to file1 and then when configuring a piece of software that needs to refer to it I can use the shortcut instead of the file?

                                Of course, what did you think a shortcut did? That's the only thing that it does.

                                I just never considered doing that because why would you? I don't understand the use case

                                scottalanmillerS 1 Reply Last reply Reply Quote 0
                                • scottalanmillerS
                                  scottalanmiller @wirestyle22
                                  last edited by

                                  @wirestyle22 said in Clarifying Symbolic Links:

                                  @scottalanmiller said in Clarifying Symbolic Links:

                                  @wirestyle22 said in Clarifying Symbolic Links:

                                  @scottalanmiller said in Clarifying Symbolic Links:

                                  @wirestyle22 said in Clarifying Symbolic Links:

                                  If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                                  What do you think a shortcut does in Windows?

                                  In windows I can name a shortcut ian that is referring to file1 and then when configuring a piece of software that needs to refer to it I can use the shortcut instead of the file?

                                  Of course, what did you think a shortcut did? That's the only thing that it does.

                                  I just never considered doing that because why would you? I don't understand the use case

                                  Okay so... let's say you have an application that runs on your server. You have twenty users on the server. Five of those users need to use that application and want it on their desktops so that they can find it. Do you make five copies of that application, one for each user, and store them on their individual desktops?

                                  wirestyle22W 1 Reply Last reply Reply Quote 0
                                  • scottalanmillerS
                                    scottalanmiller
                                    last edited by

                                    Shortcuts and symlinks should not feel like an "odd niche use case". They are so normal that you probably clicked on a few during the course of this conversation and didn't realize it. Just like apropos is a symbolic link itself. Symlinks are so common and so useful, that you actually would struggle to function without them. Just their creation is often automated, so you don't actually think about it all of the time.

                                    1 Reply Last reply Reply Quote 0
                                    • wirestyle22W
                                      wirestyle22 @scottalanmiller
                                      last edited by

                                      @scottalanmiller said in Clarifying Symbolic Links:

                                      @wirestyle22 said in Clarifying Symbolic Links:

                                      @scottalanmiller said in Clarifying Symbolic Links:

                                      @wirestyle22 said in Clarifying Symbolic Links:

                                      @scottalanmiller said in Clarifying Symbolic Links:

                                      @wirestyle22 said in Clarifying Symbolic Links:

                                      If I am configuring something inside of windows afaik I can't refer to the shortcut of the file, just the file. That is what symbolic links enable you do to do though, correct?

                                      What do you think a shortcut does in Windows?

                                      In windows I can name a shortcut ian that is referring to file1 and then when configuring a piece of software that needs to refer to it I can use the shortcut instead of the file?

                                      Of course, what did you think a shortcut did? That's the only thing that it does.

                                      I just never considered doing that because why would you? I don't understand the use case

                                      Okay so... let's say you have an application that runs on your server. You have twenty users on the server. Five of those users need to use that application and want it on their desktops so that they can find it. Do you make five copies of that application, one for each user, and store them on their individual desktops?

                                      I understand what you're saying, I'm speaking totally in regards to the configuration of a piece of software, not accessing a program.

                                      scottalanmillerS 1 Reply Last reply Reply Quote 0
                                      • scottalanmillerS
                                        scottalanmiller @wirestyle22
                                        last edited by

                                        @wirestyle22 said in Clarifying Symbolic Links:

                                        I understand what you're saying, I'm speaking totally in regards to the configuration of a piece of software, not accessing a program.

                                        Why pick that one use case?

                                        wirestyle22W 1 Reply Last reply Reply Quote 0
                                        • scottalanmillerS
                                          scottalanmiller
                                          last edited by

                                          So let's use the config use case. Let's say that there are ten stock configuration files for an application. When run, you have to supply the application with a configuration in order for it to run. You have one hundred users. You might make a symbolic link named ian that points to userdefault6.conf as that's the configuration file you want. The files for betty and monica point to that one, too. But joe, bernard, rebecca and johnstamos all point to userdefault4.conf.

                                          wirestyle22W 1 Reply Last reply Reply Quote 1
                                          • wirestyle22W
                                            wirestyle22 @scottalanmiller
                                            last edited by

                                            @scottalanmiller said in Clarifying Symbolic Links:

                                            @wirestyle22 said in Clarifying Symbolic Links:

                                            I understand what you're saying, I'm speaking totally in regards to the configuration of a piece of software, not accessing a program.

                                            Why pick that one use case?

                                            I'm trying to understand the use case: Windows vs. Linux. It makes more sense to me to use a shortcut in a GUI, but what is the use case for the CLI?

                                            scottalanmillerS stacksofplatesS 2 Replies Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post