ln: invalid option -- '/'

7,185

I'd suggest replacing the $kernel_version variable with the actual value.

As described below, using the below command with backtick instead of single quote should solve the problem as well:

$ kernel_version=`uname -r`

As mentioned by @steeldriver the error seems to be due to use of single quote instead of backtick which surround the uname -r command.

hence the following sample command:

$ kernel_version='uname -r'
$ ln -sf /tmp/test/$kernel_version/example /tmp/newname
ln: invalid option -- '/'
Try 'ln --help' for more information.

Will be translated to:

$ ln -sf /tmp/test/uname -r/example /tmp/newname
ln: invalid option -- '/'
Try 'ln --help' for more information.

And as @steeldriver wrote: Presumably the error message is about invalid option '/' because -r is a valid option for the ln command

Note that using backtick would work without errors:

$ kernel_version=`uname -r`
$ ln -sf /tmp/test/$kernel_version/example /tmp/newname
$ 
$ ls -l /tmp/newname 
lrwxrwxrwx 1 user user 35 Feb 21 16:02 /tmp/newname -> /tmp/test/4.4.0-112-generic/example
Share:
7,185

Related videos on Youtube

Aleksei Kovaltsuk
Author by

Aleksei Kovaltsuk

Updated on September 18, 2022

Comments

  • Aleksei Kovaltsuk
    Aleksei Kovaltsuk over 1 year

    I have a situation with ln and cannot solve this even after I've read about ln in help.

    Running the following command:

    ln -sf  /lib/modules/$kernel_version/extra/mISDN_core.ko /lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko
    

    Provides the following error:

    ln: invalid option -- '/'
    

    How can I solve it?

    • Yaron
      Yaron about 6 years
      what exactly did you try to do? what should be the meaning of **.ko?
    • Aleksei Kovaltsuk
      Aleksei Kovaltsuk about 6 years
      hi. whole string is: ln -sf /lib/modules/$kernel_version/extra/mISDN_core.ko /lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN‌​_core.ko and I am trying to configure network in a box
    • Rinzwind
      Rinzwind about 6 years
      What is the idea of wildcards in your command? That will never work. You are supposed to change "#ker_ver" to the kernel you want this to do with and the same with the "**" That needs to be a name for a specific "ko".
    • Aleksei Kovaltsuk
      Aleksei Kovaltsuk about 6 years
      Rinzwind, sorry for unclear example, I am going to fix it now
    • Zanna
      Zanna about 6 years
      Have you assigned to the variable $kernel_version? If so, what is its value?
    • Aleksei Kovaltsuk
      Aleksei Kovaltsuk about 6 years
      kernel_version = ‘uname -r‘
    • David Foerster
      David Foerster about 6 years
      Could you please edit your post, when you want to clarify something or add information? It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.
  • Aleksei Kovaltsuk
    Aleksei Kovaltsuk about 6 years
    after replacing the '$kernel_version' with the actual name worked! thank you!
  • Aleksei Kovaltsuk
    Aleksei Kovaltsuk about 6 years
    thank you Yaron for update, I've read about it, occasionally that didn't solve a problem, but true name of $kernel did.
  • Aleksei Kovaltsuk
    Aleksei Kovaltsuk about 6 years
    just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
  • Yaron
    Yaron about 6 years
    @AlekseiKovaltsuk - Happy that your problem was solved!
  • dessert
    dessert about 6 years
    @AlekseiKovaltsuk ln tries hard to find every option you enter, and as the content of the variable contains single hyphens -, “this must be options” it thinks. But before that, there's a path beginning with a slash /. “This must also be an option then because there are others behind it, but stop, I don't know an option beginning like that! Let's inform the user I found an invalid option and which character confuses me here.“ So ln says : There's an invalid option, find the strange thing in single quotes after the double hyphens so it's clear what character I mean: -- '/'.
  • steeldriver
    steeldriver about 6 years
    @Yaron I don't think the issue is dashes in the uname output - it looks like the OP set kernel_version to the literal string uname -r (using single quotes) rather than the output of a command substitution (backticks). Presumably the error message is about option / because -r is a valid option for the ln command