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
Related videos on Youtube
Author by
Aleksei Kovaltsuk
Updated on September 18, 2022Comments
-
Aleksei Kovaltsuk over 1 year
I have a situation with
ln
and cannot solve this even after I've read aboutln
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 about 6 yearswhat exactly did you try to do? what should be the meaning of
**.ko
? -
Aleksei Kovaltsuk about 6 yearshi. 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 about 6 yearsWhat 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 about 6 yearsRinzwind, sorry for unclear example, I am going to fix it now
-
Zanna about 6 yearsHave you assigned to the variable
$kernel_version
? If so, what is its value? -
Aleksei Kovaltsuk about 6 yearskernel_version = ‘uname -r‘
-
David Foerster about 6 yearsCould 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 about 6 yearsafter replacing the '$kernel_version' with the actual name worked! thank you!
-
Aleksei Kovaltsuk about 6 yearsthank you Yaron for update, I've read about it, occasionally that didn't solve a problem, but true name of $kernel did.
-
Aleksei Kovaltsuk about 6 yearsjust a simple question to the system, why error message doesn't describe the man problem? why it said invalid option - '/'?
-
Yaron about 6 years@AlekseiKovaltsuk - Happy that your problem was solved!
-
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.“ Soln
says:
There's aninvalid option
, find the strange thing in single quotes after the double hyphens so it's clear what character I mean:-- '/'
. -
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 stringuname -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 theln
command