Operating System - HP-UX
1752756 Members
4918 Online
108789 Solutions
New Discussion юеВ

Re: cannot delete non-existent link

 
SOLVED
Go to solution
Arnold_14
Advisor

cannot delete non-existent link

Hi all,

I have this kinda odd situation. Under one of the directories, I have:

lrwxrwxrwx 1 xcalibur xcalibur 33 Apr 19 10:32 logs ->
/p105/logs/xcalibur/pro/warehouse

So logs is just a sym. link. I'm trying to erase the syslink:

#rm logs
#

No error messages, nothing. But then if I do an 'ls' in that directory again, I still can see the logs link.

'cd' to logs also fails:
# cd logs
ksh: logs: not found
#

Help
Thanks
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: cannot delete non-existent link

Almost certainly you have control characters embedded in the filename. Cd to the directory that contains the symbolic link.
Do an ls -b. That will displays the unprintable characters in octal notation.

You should then be able to do something like rm -i lo* or rm -i *lo* dependingd upon where the bogus characters are located. THe -i asks you to confirm with 'y' before removing each file. Man ls, rm for details.
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: cannot delete non-existent link

If the "rm logs" had no errors, then maybe you have a resident program that keeps recreating this link.

You could try renaming the upper directory, then try removing "log".

HTH

-- Rod Hills
There be dragons...
KapilRaj
Honored Contributor

Re: cannot delete non-existent link

Can u try

rm -i *log* and then delete this / It can be a FS corruption as well. Try unmount and fsck

Kaps
Nothing is impossible
Dani Seely
Valued Contributor

Re: cannot delete non-existent link

Hey Arnold,
Here's a MUCH simpler way to remove the link and can be used the same with files ...

1) Obtain the inode number of the link/file
ls -li (note, in this case it's logs)
You would be returned something like this:
123 lrwxrwxrwx 1 xcalibur xcalibur 33 Apr 19 10:32 logs ->
/p105/logs/xcalibur/pro/warehouse

2) Perfrom a find by the inode number and remove the link/file
find / -inum 123 -exec rm {} \;

That's it! Very simple, VERY easy.
Together We Stand!
Rodney Hills
Honored Contributor

Re: cannot delete non-existent link

Dani,

You seem to be making an assumption that all inums are unique. They are not. The same inum value can appear in multiple file systems. Your example of "find / -inum 123"
could have the potential of eliminating files not meant to be deleted...

-- Rod Hills
There be dragons...
Dani Seely
Valued Contributor

Re: cannot delete non-existent link

Thanks for the note Rodney. I still stand by my suggestion that using the inode number is the easiest way to resolve this issue, however, let me clarify my previous statement a little to help shed some light on Rodney's comments:

Each filesystem has its own set of inodes, and there can be duplicate inode numbers between filesystems. Thus, if you were to substitute my 2nd step in my previous note with the step below, you can ensure the correct file that is assigned the inode number in my 1st step in my previous note gets removed:

2) Perfrom a find by the inode number, on the filesystem that the link/file exists on, and remove the link/file
find /tmp -inum 123 -exec rm {} \;

This step 2 is assuming the /tmp filesystem is the filesystem where the logs link exists.

For background info on inodes, they are allocated randomly, with no attempt to group related inodes such as those of files in the same directory. There is one inode for each file and each inode can be identified by its inode number, which equals its index in the inode list.

Thanks Rodney for catching this.
Together We Stand!
Rob Sletten
Occasional Contributor

Re: cannot delete non-existent link

I had a similar problem and I used the find command but the -inum 205 matched about 10 files on the system, so I used the -size parameter to specify of those 10 the file I wanted deleted, so my final command was

ls -i
find / -inum 205 -size 675c -exec rm {} \;