Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a couple of soft symbolic links that have lost their link status and have become normal files containing


I searched quite a bit to find a way to restore their link status but couldn't find any.

share|improve this question

closed as unclear what you're asking by Tog, Moses, Dave M, Flimzy, Carl B Nov 14 '13 at 6:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

You can fix this with a trivial Perl script:


use strict;
my $progname = $0; $progname =~ s@^.*/@@;

# accept path of bogued "link" file on command line
my $file = shift()
  or die "$progname: usage: $progname <file>\n";

my $content = '';
my $target = '';

# read the bogued file to find out where the symlink should point
open my $fh, '<', $file
  or die "$progname: unable to open $file: $!\n";

# parse the target path out of the file content
$content = <$fh>;
die "$progname: $file content in bogus format\n"
  unless $content =~ m@^link (.*)\r?\n$@;
$target = $1;

close $fh;

# delete the bogued file
unlink $file
  or die "$progname: unable to unlink $file: $!\n";

# replace it with the correct symlink
system('ln', '-s', $target, $file);

Drop the script into a file e.g., then invoke it as perl /path/to/bogued/symlink, and it will read the target out of the file and then replace the file with a symlink to that target.

Of course, this does nothing to address whatever's actually causing the problem, but it should at least make life simpler until you've been able to work out the cause and correct it.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .