LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 02-21-2007, 10:24 PM   #1
ahelis
LQ Newbie
 
Registered: Dec 2005
Location: Taipei, Taiwan
Distribution: Redhat 7.0 & WS3,4
Posts: 18

Rep: Reputation: 0
Cannot remove symbolic directory links in RHEL3 WS


Title: Trouble removing symbolic links to directories in RHEL3 WS

O/S: RHEL 3WS
up2date version: 4.4.69-20

Introduction:
===============
I have searched this topic on LinuxQuestions.org and have found a lot of good information but not really relating to my problem. I use symbol links within my development web server to provide access to directories that are reused in different projects, mostly for convenience for developers using html text editors and Dreamweaver. This also fixes a problem on Windows clients using Dreamweaver when a new site is defined as a subfolder inside another defined site, and Dreamweaver complains about it.

First, I have no problems with creating and deleting symbolic links to individual files.

Example:
========
Code:
$ touch dummyFile.php
$ ln -s ./dummyFile.php dummy.ln.php
$ ls -l
-rw-rw-r--    1 web   web          0 Feb 22 11:34 dummyFile.php
lrwxrwxrwx    1 web   web         12 Feb 22 11:35 dummy.ln.php -> ./dummyFile.php
$ rm dummy.ln.php
Symbolic link is deleted just fine. Now we create a symbolic link to a directory.

Problem Example:
================
Code:
$ mkdir dir_dummy
$ ln -s ./dir_dummy dummy.ln.dir
$ ls -l
drwxrwxr-x    2 web   web       4096 Feb 22 11:34 dir_dummy
lrwxrwxrwx    1 web   web         12 Feb 22 11:35 dummy.ln.dir -> ./dir_dummy/
$ rm dummy.ln.dir
rm: cannot remove `dummy.ln.dir/': Not a directory
$ rmdir dummy.ln.dir
rmdir: `dummy.ln': Not a directory
I am the first to admit that I may not be using symbolic links correctly or should be using hard links for this exact purpose, but like many in unix, you try something and if it works, then you continue to use it until you find a problem. So, there could very well be a simple solution to remove this type of directory link or someone may know a better way to solve the core problem, other than just saying to create new top level folder for all new projects. In recent months, I have switched mostly to using Zend Studio which has built in support for multiple paths but several other developers want to stick to Dreamweaver.

Any suggestions,
 
Old 02-21-2007, 11:26 PM   #2
sai_kiran
LQ Newbie
 
Registered: Jan 2006
Posts: 11

Rep: Reputation: 0
Unhappy oops

I can do it on my system without problem..

Code:
$ ll -d test*
drwxr-x---    2 vsundar  vsundar      4096 Feb 22 13:08 test
lrwxrwxrwx    1 vsundar  vsundar         4 Feb 22 13:08 test1 -> test

$ rm test1
$ ll -d test*
drwxr-x---    2 vsundar  vsundar      4096 Feb 22 13:08 test
It should be a problem.

May be you can try using unlink.
 
Old 02-22-2007, 01:04 AM   #3
ahelis
LQ Newbie
 
Registered: Dec 2005
Location: Taipei, Taiwan
Distribution: Redhat 7.0 & WS3,4
Posts: 18

Original Poster
Rep: Reputation: 0
sai_kiran,

Using unlink doesn't work either. Same type of error message.

Code:
$unlink dummy.ln
unlink: cannot unlink `dummy.ln/': Not a directory

BTW, the parent directory has the following permissions:

drwxr-xr-x   42 web   web       4096 Feb 22 03:09 lib
I really don't think its permission related. Switching to root.

Code:
$su
Password:
# rm dummy.ln/
rm: remove directory `dummy.ln/'? y
rm: cannot remove directory `dummy.ln/': Is a directory

# rmdir dummy.ln/
rmdir: `dummy.ln/': Not a directory

# unlink dummy.ln/
unlink: cannot unlink `dummy.ln/': Not a directory
 
Old 02-24-2007, 05:39 AM   #4
ahelis
LQ Newbie
 
Registered: Dec 2005
Location: Taipei, Taiwan
Distribution: Redhat 7.0 & WS3,4
Posts: 18

Original Poster
Rep: Reputation: 0
Hello,

After a number of unsuccessful hours searching trying to find others on the Internet who may have experienced this same problem. I got back to trying different solutions and I have discovered a remarkably simple solution.

Code:
The following was the original problem with error message:

$ mkdir dir_dummy
$ ln -s ./dir_dummy dummy.ln.dir
$ ls -l
drwxrwxr-x    2 web   web       4096 Feb 22 11:34 dir_dummy
lrwxrwxrwx    1 web   web         12 Feb 22 11:35 dummy.ln.dir -> ./dir_dummy/
$ rm dummy.ln.dir
rm: cannot remove `dummy.ln.dir/': Not a directory
$ rmdir dummy.ln.dir
rmdir: `dummy.ln': Not a directory

My Solution to the problem:

$ mv dir_dummy dir_dummy_tmp (breaks symbolic link, turns red)
$ rm dummy.ln.dir
$ mv dir_dummy_tmp dir_dummy (restore orig dir name)
By renaming the target directory, the symbolic link becomes broken and then the sym link can be easily deleted without errors. Afterwards, just restore the target directory to its original name to ensure that other sym links remain functional.

Issue is closed.
 
Old 03-06-2007, 10:52 AM   #5
abhishekhp
LQ Newbie
 
Registered: Mar 2007
Posts: 1

Rep: Reputation: 0
unlink to remove symbolic links

Using unlink dirname works for me. Thanks

Last edited by abhishekhp; 03-06-2007 at 10:53 AM.
 
Old 03-24-2007, 02:51 AM   #6
DrDom
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
Completion messes things up

The reason you can't just "rm" the symbolic link to a directory is that the trailing slash which is appended by the TAB-completion screws things up. rm assumes the target is a directory without doing any further checking.

Anyway, try without the slash, and that should fix things. No need to resort to moving the link target. (That works, BTW, because it suppresses the shell's completion from appending the trailing slash.)

Someone should patch rm to remove this stupid behavior...

XOX DOM
 
  


Reply



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
Cannot remove symbolic link to directory. martint Linux - Newbie 6 09-17-2014 08:45 PM
How can I remove symbolic links? MichaelZ Linux - Newbie 5 11-19-2009 07:45 AM
Is there a way to search for and remove dead symbolic links? HGeneAnthony Linux - General 5 01-19-2007 02:09 AM
Symbolic Links suavecu Linux - Software 1 01-11-2006 10:04 PM
help with symbolic links sopiaz57 Linux - General 2 06-11-2004 06:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:56 AM.

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