Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-07-2007, 03:07 AM   #1
LQ Newbie
Registered: Oct 2007
Posts: 11

Rep: Reputation: 0
Question Can I recover from creating a symbolic link with the same name as an existing folder?

Suppose you are running Ubuntu and you have a Samba share called /share and a folder called /Archive, and to give network access to /Archive you want to create a soft link to it in /share. Being a newbie, you screw up the ln command. Instead of

ln -s /Archive /share/Archive

you reverse the order of the params and type

ln -s /share/Archive /Archive

At first it says permission denied, so you brilliantly add "sudo" and do it again. It works! Instead of your original /Archive folder with its tons of files, you now have a useless link called /Archive that points to /share/Archive which doesn't exist.

Let's be realistic and say I did this instead of you. Am I totally hosed, or is there a way to fix this and re-point /Archive to the physical location that it originally pointed to?
Old 10-07-2007, 03:40 AM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
I don't know of any version of ln that is broken in such a way, to accomplish what you indicate occurred.

However you managed to delete the directory, you will need to restore from backup.
Old 10-07-2007, 03:53 AM   #3
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
I have attempted to recreate the series of events.
  1. created a folder /share
  2. created a folder /Archive
  3. ran ln -s /share/Archive /Archive (received permissions issue)
  4. ran sudo ln -s /share/Archive /Archive

This, however does not link /Archive to a non existant /share/Archive.

It links /Archive/Archive to a non existant /share/Archive

You can remove by sudo rm /Archive/Archive

Always be careful with rm commands especially when using sudo!

If this is not the case for you, then I can only sympathise and agree that you would need to restore (if you have a backup)
Old 10-07-2007, 04:20 AM   #4
LQ Newbie
Registered: Oct 2007
Posts: 11

Original Poster
Rep: Reputation: 0

Thank you for such fast responses! What happened was exactly as Disillusionist stated. It was a misinterpretation on my part. I deleted the Archive subfolder, created the link properly and everything is fine.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"creating symbolic link" "operation not permitted" wheni Linux - Newbie 3 05-08-2011 01:36 AM
ln: creating symbolic link `/dev/dvd' to `/dev/hdc': Permission denied qazwsx27 Fedora 3 06-14-2005 02:09 PM
make install-init creating wrong symbolic link ServerStorm Linux - Software 1 01-18-2005 02:32 PM
Creating new symbolic link to libstdc kills KDE DavidLock Linux - Newbie 2 05-21-2004 03:31 AM
creating symbolic link for samba woonaks Linux - General 2 10-22-2003 10:12 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration