Changing symlink path creates additional folder

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











up vote
-2
down vote

favorite
1












I tried to change an existing symlink which is accessable under cd ~/symlink_file_name to another folder with the following command:



ln -sfn /usr/home/myusername/testfolder symlink_file_name


(since the testfolder is also accessable via cd ~/testfolder and shows me with pwd the context: /usr/home/myusername/testfolder).



Running pwd gives me /usr/home/myusername/testfolder.



It works (and I get no additional response or error from ln command), but unfortunately it adds a folder myusername to the testfolder so that the symlink then points to:



/usr/home/myusername/testfolder/myusername


instead to:



/usr/home/myusername/testfolder


which i originally set it to (as you can tell from the ln command at the beginning of my post).



How can I prevent this that it creates the additional folder?










share|improve this question



















  • 1




    Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
    – roaima
    Sep 7 at 19:35











  • @roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
    – Paul
    Sep 7 at 19:53










  • pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
    – roaima
    Sep 7 at 19:55










  • try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
    – Kasper
    Sep 7 at 19:58







  • 1




    Sorry, I can't reproduce this at all.
    – roaima
    Sep 7 at 20:13














up vote
-2
down vote

favorite
1












I tried to change an existing symlink which is accessable under cd ~/symlink_file_name to another folder with the following command:



ln -sfn /usr/home/myusername/testfolder symlink_file_name


(since the testfolder is also accessable via cd ~/testfolder and shows me with pwd the context: /usr/home/myusername/testfolder).



Running pwd gives me /usr/home/myusername/testfolder.



It works (and I get no additional response or error from ln command), but unfortunately it adds a folder myusername to the testfolder so that the symlink then points to:



/usr/home/myusername/testfolder/myusername


instead to:



/usr/home/myusername/testfolder


which i originally set it to (as you can tell from the ln command at the beginning of my post).



How can I prevent this that it creates the additional folder?










share|improve this question



















  • 1




    Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
    – roaima
    Sep 7 at 19:35











  • @roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
    – Paul
    Sep 7 at 19:53










  • pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
    – roaima
    Sep 7 at 19:55










  • try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
    – Kasper
    Sep 7 at 19:58







  • 1




    Sorry, I can't reproduce this at all.
    – roaima
    Sep 7 at 20:13












up vote
-2
down vote

favorite
1









up vote
-2
down vote

favorite
1






1





I tried to change an existing symlink which is accessable under cd ~/symlink_file_name to another folder with the following command:



ln -sfn /usr/home/myusername/testfolder symlink_file_name


(since the testfolder is also accessable via cd ~/testfolder and shows me with pwd the context: /usr/home/myusername/testfolder).



Running pwd gives me /usr/home/myusername/testfolder.



It works (and I get no additional response or error from ln command), but unfortunately it adds a folder myusername to the testfolder so that the symlink then points to:



/usr/home/myusername/testfolder/myusername


instead to:



/usr/home/myusername/testfolder


which i originally set it to (as you can tell from the ln command at the beginning of my post).



How can I prevent this that it creates the additional folder?










share|improve this question















I tried to change an existing symlink which is accessable under cd ~/symlink_file_name to another folder with the following command:



ln -sfn /usr/home/myusername/testfolder symlink_file_name


(since the testfolder is also accessable via cd ~/testfolder and shows me with pwd the context: /usr/home/myusername/testfolder).



Running pwd gives me /usr/home/myusername/testfolder.



It works (and I get no additional response or error from ln command), but unfortunately it adds a folder myusername to the testfolder so that the symlink then points to:



/usr/home/myusername/testfolder/myusername


instead to:



/usr/home/myusername/testfolder


which i originally set it to (as you can tell from the ln command at the beginning of my post).



How can I prevent this that it creates the additional folder?







filesystems symlink path






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 7 at 20:06









roaima

40.6k547110




40.6k547110










asked Sep 7 at 19:08









Paul

62




62







  • 1




    Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
    – roaima
    Sep 7 at 19:35











  • @roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
    – Paul
    Sep 7 at 19:53










  • pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
    – roaima
    Sep 7 at 19:55










  • try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
    – Kasper
    Sep 7 at 19:58







  • 1




    Sorry, I can't reproduce this at all.
    – roaima
    Sep 7 at 20:13












  • 1




    Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
    – roaima
    Sep 7 at 19:35











  • @roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
    – Paul
    Sep 7 at 19:53










  • pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
    – roaima
    Sep 7 at 19:55










  • try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
    – Kasper
    Sep 7 at 19:58







  • 1




    Sorry, I can't reproduce this at all.
    – roaima
    Sep 7 at 20:13







1




1




Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
– roaima
Sep 7 at 19:35





Please provide a worked example in your question. Start with pwd (and its output) so we have some context. Then the ln... command (and any message it may give you - although I wouldn't particularly expect one). Then explain what's not right, what you expected, and how you tried to fix it.
– roaima
Sep 7 at 19:35













@roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
– Paul
Sep 7 at 19:53




@roaima I updated my post a little bit. Sorry but I'm pretty new to linux. Why should I paste the pwd output, and for which path?
– Paul
Sep 7 at 19:53












pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
– roaima
Sep 7 at 19:55




pwd will give us the directory context in which you're running the ln -s. By all means obfuscate BOTH commands similarly if you would like to hide the precise name of one or more of directories. But without the context we can't see where you've put symlink_file_name and so we can't reliably determine why you should get the behaviour you're seeing.
– roaima
Sep 7 at 19:55












try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
– Kasper
Sep 7 at 19:58





try to run the command pwd. inside this path /usr/home/myusername/testfolder what is the results?
– Kasper
Sep 7 at 19:58





1




1




Sorry, I can't reproduce this at all.
– roaima
Sep 7 at 20:13




Sorry, I can't reproduce this at all.
– roaima
Sep 7 at 20:13










1 Answer
1






active

oldest

votes

















up vote
0
down vote













To create symbolic link you should do ln -s path to source file name my file name



This will replace source file name with the name of the existing file for which you want to create the symbolic link.



To update symbolic link you should do ln -sfn path to source file name my file name






share|improve this answer






















  • thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
    – Paul
    Sep 7 at 19:44










  • @Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
    – Goro
    Sep 7 at 19:49











  • myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
    – Paul
    Sep 7 at 19:54











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f467611%2fchanging-symlink-path-creates-additional-folder%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













To create symbolic link you should do ln -s path to source file name my file name



This will replace source file name with the name of the existing file for which you want to create the symbolic link.



To update symbolic link you should do ln -sfn path to source file name my file name






share|improve this answer






















  • thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
    – Paul
    Sep 7 at 19:44










  • @Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
    – Goro
    Sep 7 at 19:49











  • myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
    – Paul
    Sep 7 at 19:54















up vote
0
down vote













To create symbolic link you should do ln -s path to source file name my file name



This will replace source file name with the name of the existing file for which you want to create the symbolic link.



To update symbolic link you should do ln -sfn path to source file name my file name






share|improve this answer






















  • thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
    – Paul
    Sep 7 at 19:44










  • @Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
    – Goro
    Sep 7 at 19:49











  • myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
    – Paul
    Sep 7 at 19:54













up vote
0
down vote










up vote
0
down vote









To create symbolic link you should do ln -s path to source file name my file name



This will replace source file name with the name of the existing file for which you want to create the symbolic link.



To update symbolic link you should do ln -sfn path to source file name my file name






share|improve this answer














To create symbolic link you should do ln -s path to source file name my file name



This will replace source file name with the name of the existing file for which you want to create the symbolic link.



To update symbolic link you should do ln -sfn path to source file name my file name







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 7 at 19:44

























answered Sep 7 at 19:40









Goro

5,05552459




5,05552459











  • thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
    – Paul
    Sep 7 at 19:44










  • @Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
    – Goro
    Sep 7 at 19:49











  • myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
    – Paul
    Sep 7 at 19:54

















  • thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
    – Paul
    Sep 7 at 19:44










  • @Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
    – Goro
    Sep 7 at 19:49











  • myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
    – Paul
    Sep 7 at 19:54
















thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
– Paul
Sep 7 at 19:44




thx for the quick answer. I already used the ln -sfn command with ln -sfn /usr/home/myusername/testfolder test which should create a symlink "test" in the current path pointing to "/usr/home/myusername/testfolder". And it does, but (for what ever reason) it also creates a subfolder "myusername" in the directory I point to and points to that folder like so: /usr/home/myusername/testfolder/myusername
– Paul
Sep 7 at 19:44












@Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
– Goro
Sep 7 at 19:49





@Paul. If you do right click on the created file> properties. In the basic tab you should see the link target and location. Not clear in the question what myusername folder means!?
– Goro
Sep 7 at 19:49













myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
– Paul
Sep 7 at 19:54





myusername is the name of my ssh user i connect to the server with. How do I do that via the terminal (since I have only SSH access to the server > no GUI)
– Paul
Sep 7 at 19:54


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467611%2fchanging-symlink-path-creates-additional-folder%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)