Re: [opensuse] deleting soft links



On Thursday 03 January 2008 07:13, Kalvin Weng wrote:
You can use the command unlink .....I think.

No. That's something different. The "unlink" command provides direct access to
the unlink() system call. It is what the "rm" and "rmdir" commands ultimately
call, but with some safeguards on the way. The "unlink" command is not
intended for general use; use "rm" or "rmdir" instead.

Both the "unlink" command and the unlink() system call deal with hard
links(!). They don't know anything about symlinks. To the system, each file
or directory is identified with an "i-node" which has an "i-number". File
names and directory paths are just there for us mere mortals who have a hard
time remembering 32 bit i-numbers to identify a file or directory. ;-)

http://en.wikipedia.org/wiki/Inode
http://en.wikipedia.org/wiki/Hard_link
http://en.wikipedia.org/wiki/Symbolic_link



From "info unlink":

"12.8 `unlink': Remove files via the unlink syscall
==================================================

`unlink' deletes a single specified file name. It is a minimalist
interface to the system-provided `unlink' function. *Note Deleting
Files: (libc)Deleting Files. Synopsis: It avoids the bells and
whistles of the more commonly-used `rm' command (*note rm invocation::).

unlink FILENAME

On some systems `unlink' can be used to delete the name of a
directory. On others, it can be used that way only by a privileged
user. In the GNU system `unlink' can never delete the name of a
directory.
..."


From "man 2 unlink":

"NAME
unlink - delete a name and possibly the file it refers to

SYNOPSIS
#include <unistd.h>

int unlink(const char *pathname);

DESCRIPTION
unlink() deletes a name from the filesystem. If that name was the last
link to a file and no processes have the file open the file is deleted
and the space it was using is made available for reuse.

If the name was the last link to a file but any processes still have
the file open the file will remain in existence until the last file
descriptor referring to it is closed.

If the name referred to a symbolic link the link is removed.

If the name referred to a socket, fifo or device the name for it is
removed but processes which have the object open may continue to use
it.
..."




--
Stefan Hundhammer <sh@xxxxxxx> Penguin by conviction.
YaST2 Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Nürnberg, Germany
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: Moving /USR
    ... This was done from the command ... Once the upgrade was complete I just logged out and ... logged back in again and, bingo, I'm running Xorg now. ... you can't unlink them and create a new file with the same name. ...
    (uk.comp.os.linux)
  • Re: Moving /USR
    ... This was done from the command ... Once the upgrade was complete I just logged out and ... logged back in again and, bingo, I'm running Xorg now. ... you can't unlink them and create a new file with the same name. ...
    (uk.comp.os.linux)
  • Re: Partition Full / df command
    ... When you use the mvcommand to move a file the file is actually ... (man unlink). ... Since your download utility still held a reference on the file ... The kernel is unable to ...
    (linux.redhat)
  • Re: [patch] rm can have undesired side-effects
    ... these commands can also unlink a file and once ... are truely paranoid (as opposed to paranoid only ... the Unix paradigm of single command to do a single ... Low, Low, Low Rates! ...
    (freebsd-hackers)
  • Re: Moving /USR
    ... you can't unlink them and create a new file with the same name. ... usual on Unix systems the unlinked copy is only actually deleted when ... (Disclaimer: that specific command not ... paul@vienna> ls -l cat ...
    (uk.comp.os.linux)