Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)
edited by

I have the symlink to an important directory. I somehow want to get rid of this symlink, while keeping the directory behind it.

I tried the command rm and get back 

rm: cannot remove 'foo'.

I also tried the rmdir and got back 

rmdir: failed to remove 'foo': 

Directory not empty

I then progressed through

 rm -f, rm -rf, and sudo rm -rf

Then I went to find my back-ups.

Help me to get rid of this symlink.

1 Answer

0 votes
by (36.8k points)

Use the below command: 

# this works:

rm foo

# versus this, which doesn't:

rm foo/

You need to delete your file, not delete the directory. I believe the difference between the rm and rmdir exists because of the differences in the way this C library treats each.

At any rate, the above first one should work, while the second one should complain about foo being a directory.

If it is not working then check your permissions. You need to write the permission to this containing directory to remove files.

To know about Linux join the Linux training

Related questions

0 votes
1 answer
asked Dec 12, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 9, 2021 in Linux by blackindya (18.4k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...