Deleting a Symbolic Link

Deleting a symbolic link should be easy, right? Try doing it with an FTP client. If you have shell access to your host, it is easy.

I used to have unused symbolic links all over the place. I could rename them, but I couldn't delete them. Recently, I remembered the PHP unlink function and used it to delete them all.


The steps to use it are:

1) Rename the symbolic link to something like "delete_me" in order to reuse the same PHP file.
2) Create the PHP file with the appropriate code. I used "unlink.php". Simple and easy to remember.
3) Upload the PHP file to the directory containing the link.
4) Type in the URL to the file.

The result is that the file disappears without a trace.

This is the PHP code I used.

<?php
unlink ('delete_me');
?>

You techies and coders will probably laugh at this, but you don't know how many times I've been asked to explain it.

Similar Posts:

15 Comments

  1. hari says:

    Luckily I have shell access to my server. :grin:

    My latest blog post: Boxi and Panjo – Late Night Movie

  2. hari says:

    I don't think this would work for files which are owned by anybody other than the "www" user which is what PHP runs as. If files are owned by the normal UNIX user, then this wouldn't work as it would deny permission.

    My latest blog post: Boxi and Panjo – Late Night Movie

  3. Sarika from Graphic Tees says:

    My site is in PHP and I have no idea what a symbolic link is. I'm not much of a techie as you can guess. Will google it right away.

  4. Phil Dufault says:

    This method scares me — why not get a better host with shell access?

    My latest blog post: Missing Google Maps Mobile v2.2.0 on a Windows Mobile phone

  5. [...] Por si alguien más se encuentra en este pequeño apuro, ahí os dejo el enlace a este truquito: Deleting a symbolic link. [...]

  6. Brian says:

    Just wanted to say thanks for this handy trick! Helped in a tough spot when I didn't have shell access and had a stuck symbolic link!

Leave a Reply

CommentLuv Enabled

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

Anti-Spam Protection by WP-SpamFree