ln: invalid option — '/'

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












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?










share|improve this question























  • what exactly did you try to do? what should be the meaning of **.ko?
    – Yaron
    Feb 21 at 9:18










  • 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
    – Aleksei Kovaltsuk
    Feb 21 at 9:20











  • 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".
    – Rinzwind
    Feb 21 at 9:22










  • Rinzwind, sorry for unclear example, I am going to fix it now
    – Aleksei Kovaltsuk
    Feb 21 at 9:23










  • Have you assigned to the variable $kernel_version? If so, what is its value?
    – Zanna
    Feb 21 at 9:29














up vote
2
down vote

favorite












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?










share|improve this question























  • what exactly did you try to do? what should be the meaning of **.ko?
    – Yaron
    Feb 21 at 9:18










  • 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
    – Aleksei Kovaltsuk
    Feb 21 at 9:20











  • 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".
    – Rinzwind
    Feb 21 at 9:22










  • Rinzwind, sorry for unclear example, I am going to fix it now
    – Aleksei Kovaltsuk
    Feb 21 at 9:23










  • Have you assigned to the variable $kernel_version? If so, what is its value?
    – Zanna
    Feb 21 at 9:29












up vote
2
down vote

favorite









up vote
2
down vote

favorite











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?










share|improve this question















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?







command-line kernel symbolic-link






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 at 9:43









Yaron

8,54271838




8,54271838










asked Feb 21 at 9:08









Aleksei Kovaltsuk

165




165











  • what exactly did you try to do? what should be the meaning of **.ko?
    – Yaron
    Feb 21 at 9:18










  • 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
    – Aleksei Kovaltsuk
    Feb 21 at 9:20











  • 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".
    – Rinzwind
    Feb 21 at 9:22










  • Rinzwind, sorry for unclear example, I am going to fix it now
    – Aleksei Kovaltsuk
    Feb 21 at 9:23










  • Have you assigned to the variable $kernel_version? If so, what is its value?
    – Zanna
    Feb 21 at 9:29
















  • what exactly did you try to do? what should be the meaning of **.ko?
    – Yaron
    Feb 21 at 9:18










  • 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
    – Aleksei Kovaltsuk
    Feb 21 at 9:20











  • 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".
    – Rinzwind
    Feb 21 at 9:22










  • Rinzwind, sorry for unclear example, I am going to fix it now
    – Aleksei Kovaltsuk
    Feb 21 at 9:23










  • Have you assigned to the variable $kernel_version? If so, what is its value?
    – Zanna
    Feb 21 at 9:29















what exactly did you try to do? what should be the meaning of **.ko?
– Yaron
Feb 21 at 9:18




what exactly did you try to do? what should be the meaning of **.ko?
– Yaron
Feb 21 at 9:18












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
– Aleksei Kovaltsuk
Feb 21 at 9:20





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
– Aleksei Kovaltsuk
Feb 21 at 9:20













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".
– Rinzwind
Feb 21 at 9:22




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".
– Rinzwind
Feb 21 at 9:22












Rinzwind, sorry for unclear example, I am going to fix it now
– Aleksei Kovaltsuk
Feb 21 at 9:23




Rinzwind, sorry for unclear example, I am going to fix it now
– Aleksei Kovaltsuk
Feb 21 at 9:23












Have you assigned to the variable $kernel_version? If so, what is its value?
– Zanna
Feb 21 at 9:29




Have you assigned to the variable $kernel_version? If so, what is its value?
– Zanna
Feb 21 at 9:29










2 Answers
2






active

oldest

votes

















up vote
6
down vote



accepted










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|improve this answer






















  • after replacing the '$kernel_version' with the actual name worked! thank you!
    – Aleksei Kovaltsuk
    Feb 21 at 9:37










  • 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
    Feb 21 at 9:45










  • just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
    – Aleksei Kovaltsuk
    Feb 21 at 9:47










  • @AlekseiKovaltsuk - Happy that your problem was solved!
    – Yaron
    Feb 21 at 9:47










  • @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: -- '/'.
    – dessert
    Feb 21 at 10:08


















up vote
0
down vote













  1. Use the $( ... ) notation instead of the old-style backticks `...` for command substitution. It looks better, and nests better. And is less likely to be mixed up with quotes.



  2. Quote your variables. With the string uname -r in kernel_version, /lib/modules/$kernel_version/extra/mISDN_core.ko expands to the two words /lib/modules/uname and -r/extra/mISDN_core.ko, when you clearly wanted only one filename.



    Quoted, "/lib/modules/$kernel_version/extra/mISDN_core.ko" would expand to /lib/modules/uname -r/extra/mISDN_core.ko as a single word, and you'd get an error from ln because a file by that name does not exist.




  3. Not exactly necessary here if you quoted the variables properly, since your filenames start with a slash, but in general you may want to consider adding the double-dash -- to signal the end of options. With filenames starting with dashes it has to be used so that the application can tell the difference between an option and a filename.



    As the classic example, consider what happens if you run rm * in a directory containing a file called -rf. rm -- * prevents the issue (as would rm ./*).



Without doing (1) or (2), ln indeed sees the string -r/kernel... as one of the arguments, and as GNU ln reads options from all arguments, not just the first ones, it takes -r as a known option, and then errors on /, since -/ is not an option it knows about.



So, in full, what you should do is:



kernel_version=$(uname -r)
ln -sf -- "/lib/modules/$kernel_version/extra/mISDN_core.ko"
"/lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko"





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1008309%2fln-invalid-option%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    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|improve this answer






















    • after replacing the '$kernel_version' with the actual name worked! thank you!
      – Aleksei Kovaltsuk
      Feb 21 at 9:37










    • 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
      Feb 21 at 9:45










    • just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
      – Aleksei Kovaltsuk
      Feb 21 at 9:47










    • @AlekseiKovaltsuk - Happy that your problem was solved!
      – Yaron
      Feb 21 at 9:47










    • @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: -- '/'.
      – dessert
      Feb 21 at 10:08















    up vote
    6
    down vote



    accepted










    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|improve this answer






















    • after replacing the '$kernel_version' with the actual name worked! thank you!
      – Aleksei Kovaltsuk
      Feb 21 at 9:37










    • 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
      Feb 21 at 9:45










    • just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
      – Aleksei Kovaltsuk
      Feb 21 at 9:47










    • @AlekseiKovaltsuk - Happy that your problem was solved!
      – Yaron
      Feb 21 at 9:47










    • @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: -- '/'.
      – dessert
      Feb 21 at 10:08













    up vote
    6
    down vote



    accepted







    up vote
    6
    down vote



    accepted






    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|improve this answer














    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|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 21 at 14:09

























    answered Feb 21 at 9:33









    Yaron

    8,54271838




    8,54271838











    • after replacing the '$kernel_version' with the actual name worked! thank you!
      – Aleksei Kovaltsuk
      Feb 21 at 9:37










    • 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
      Feb 21 at 9:45










    • just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
      – Aleksei Kovaltsuk
      Feb 21 at 9:47










    • @AlekseiKovaltsuk - Happy that your problem was solved!
      – Yaron
      Feb 21 at 9:47










    • @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: -- '/'.
      – dessert
      Feb 21 at 10:08

















    • after replacing the '$kernel_version' with the actual name worked! thank you!
      – Aleksei Kovaltsuk
      Feb 21 at 9:37










    • 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
      Feb 21 at 9:45










    • just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
      – Aleksei Kovaltsuk
      Feb 21 at 9:47










    • @AlekseiKovaltsuk - Happy that your problem was solved!
      – Yaron
      Feb 21 at 9:47










    • @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: -- '/'.
      – dessert
      Feb 21 at 10:08
















    after replacing the '$kernel_version' with the actual name worked! thank you!
    – Aleksei Kovaltsuk
    Feb 21 at 9:37




    after replacing the '$kernel_version' with the actual name worked! thank you!
    – Aleksei Kovaltsuk
    Feb 21 at 9:37












    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
    Feb 21 at 9:45




    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
    Feb 21 at 9:45












    just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
    – Aleksei Kovaltsuk
    Feb 21 at 9:47




    just a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
    – Aleksei Kovaltsuk
    Feb 21 at 9:47












    @AlekseiKovaltsuk - Happy that your problem was solved!
    – Yaron
    Feb 21 at 9:47




    @AlekseiKovaltsuk - Happy that your problem was solved!
    – Yaron
    Feb 21 at 9:47












    @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: -- '/'.
    – dessert
    Feb 21 at 10:08





    @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: -- '/'.
    – dessert
    Feb 21 at 10:08













    up vote
    0
    down vote













    1. Use the $( ... ) notation instead of the old-style backticks `...` for command substitution. It looks better, and nests better. And is less likely to be mixed up with quotes.



    2. Quote your variables. With the string uname -r in kernel_version, /lib/modules/$kernel_version/extra/mISDN_core.ko expands to the two words /lib/modules/uname and -r/extra/mISDN_core.ko, when you clearly wanted only one filename.



      Quoted, "/lib/modules/$kernel_version/extra/mISDN_core.ko" would expand to /lib/modules/uname -r/extra/mISDN_core.ko as a single word, and you'd get an error from ln because a file by that name does not exist.




    3. Not exactly necessary here if you quoted the variables properly, since your filenames start with a slash, but in general you may want to consider adding the double-dash -- to signal the end of options. With filenames starting with dashes it has to be used so that the application can tell the difference between an option and a filename.



      As the classic example, consider what happens if you run rm * in a directory containing a file called -rf. rm -- * prevents the issue (as would rm ./*).



    Without doing (1) or (2), ln indeed sees the string -r/kernel... as one of the arguments, and as GNU ln reads options from all arguments, not just the first ones, it takes -r as a known option, and then errors on /, since -/ is not an option it knows about.



    So, in full, what you should do is:



    kernel_version=$(uname -r)
    ln -sf -- "/lib/modules/$kernel_version/extra/mISDN_core.ko"
    "/lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko"





    share|improve this answer


























      up vote
      0
      down vote













      1. Use the $( ... ) notation instead of the old-style backticks `...` for command substitution. It looks better, and nests better. And is less likely to be mixed up with quotes.



      2. Quote your variables. With the string uname -r in kernel_version, /lib/modules/$kernel_version/extra/mISDN_core.ko expands to the two words /lib/modules/uname and -r/extra/mISDN_core.ko, when you clearly wanted only one filename.



        Quoted, "/lib/modules/$kernel_version/extra/mISDN_core.ko" would expand to /lib/modules/uname -r/extra/mISDN_core.ko as a single word, and you'd get an error from ln because a file by that name does not exist.




      3. Not exactly necessary here if you quoted the variables properly, since your filenames start with a slash, but in general you may want to consider adding the double-dash -- to signal the end of options. With filenames starting with dashes it has to be used so that the application can tell the difference between an option and a filename.



        As the classic example, consider what happens if you run rm * in a directory containing a file called -rf. rm -- * prevents the issue (as would rm ./*).



      Without doing (1) or (2), ln indeed sees the string -r/kernel... as one of the arguments, and as GNU ln reads options from all arguments, not just the first ones, it takes -r as a known option, and then errors on /, since -/ is not an option it knows about.



      So, in full, what you should do is:



      kernel_version=$(uname -r)
      ln -sf -- "/lib/modules/$kernel_version/extra/mISDN_core.ko"
      "/lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko"





      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        1. Use the $( ... ) notation instead of the old-style backticks `...` for command substitution. It looks better, and nests better. And is less likely to be mixed up with quotes.



        2. Quote your variables. With the string uname -r in kernel_version, /lib/modules/$kernel_version/extra/mISDN_core.ko expands to the two words /lib/modules/uname and -r/extra/mISDN_core.ko, when you clearly wanted only one filename.



          Quoted, "/lib/modules/$kernel_version/extra/mISDN_core.ko" would expand to /lib/modules/uname -r/extra/mISDN_core.ko as a single word, and you'd get an error from ln because a file by that name does not exist.




        3. Not exactly necessary here if you quoted the variables properly, since your filenames start with a slash, but in general you may want to consider adding the double-dash -- to signal the end of options. With filenames starting with dashes it has to be used so that the application can tell the difference between an option and a filename.



          As the classic example, consider what happens if you run rm * in a directory containing a file called -rf. rm -- * prevents the issue (as would rm ./*).



        Without doing (1) or (2), ln indeed sees the string -r/kernel... as one of the arguments, and as GNU ln reads options from all arguments, not just the first ones, it takes -r as a known option, and then errors on /, since -/ is not an option it knows about.



        So, in full, what you should do is:



        kernel_version=$(uname -r)
        ln -sf -- "/lib/modules/$kernel_version/extra/mISDN_core.ko"
        "/lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko"





        share|improve this answer














        1. Use the $( ... ) notation instead of the old-style backticks `...` for command substitution. It looks better, and nests better. And is less likely to be mixed up with quotes.



        2. Quote your variables. With the string uname -r in kernel_version, /lib/modules/$kernel_version/extra/mISDN_core.ko expands to the two words /lib/modules/uname and -r/extra/mISDN_core.ko, when you clearly wanted only one filename.



          Quoted, "/lib/modules/$kernel_version/extra/mISDN_core.ko" would expand to /lib/modules/uname -r/extra/mISDN_core.ko as a single word, and you'd get an error from ln because a file by that name does not exist.




        3. Not exactly necessary here if you quoted the variables properly, since your filenames start with a slash, but in general you may want to consider adding the double-dash -- to signal the end of options. With filenames starting with dashes it has to be used so that the application can tell the difference between an option and a filename.



          As the classic example, consider what happens if you run rm * in a directory containing a file called -rf. rm -- * prevents the issue (as would rm ./*).



        Without doing (1) or (2), ln indeed sees the string -r/kernel... as one of the arguments, and as GNU ln reads options from all arguments, not just the first ones, it takes -r as a known option, and then errors on /, since -/ is not an option it knows about.



        So, in full, what you should do is:



        kernel_version=$(uname -r)
        ln -sf -- "/lib/modules/$kernel_version/extra/mISDN_core.ko"
        "/lib/modules/$kernel_version/kernel/drivers/isdn/mISDN/mISDN_core.ko"






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 21 at 19:20









        wjandrea

        7,23342256




        7,23342256










        answered Feb 21 at 17:17









        ilkkachu

        981210




        981210



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1008309%2fln-invalid-option%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491