Ich habe versehentlich die Parameter meines ln umgekehrt und aufgerufen:
ln -s my_link my_dir
wo my_dir bereits existierte und my_link nicht. Ich habe my_dir gelöscht, kann aber my_link nicht löschen.
Wenn ich das übergeordnete Verzeichnis von my-link ls -l habe, erhalte ich 1 von 2 verschiedenen Antworten, entweder:
l????????? ? ? ? ? ? my_link
oder:
lrwxrwxrwx 1 username username 8 Mar 20 16:34 my_link
Wenn ich anrufe, rm my_link
bekomme ich:
rm: cannot remove `my_link': Not a directory
Ich bin mir nicht sicher, ob es relevant ist, aber my_link befindet sich auf einem im Netzwerk bereitgestellten Laufwerk.
Weiß jemand, was ich hier gemacht habe und wie man den defekten Link entfernt?
Bearbeiten: Ich habe meine bash_history durchgesehen und die Befehle gefunden, die ich ausgeführt habe. Es sieht so aus, als hätte ich my_dir nicht wirklich gelöscht, es hat einfach aufgehört zu sein. Und ich habe mehrere Versionen des falschen ln-Befehls ausgeführt.
Hier ist die unbearbeitete Liste der Befehle, die ich ausgeführt habe, bevor der Fehler gelöscht wurde:
ln -s test_dir ~/netdrive/test_dir/
ln -s test_dir ~/netdrive/test_dir
ln -s test_dir/ ~/netdrive/test_dir/
Sie werden feststellen, dass ich my_link und my_dir abgeschafft habe. Die tatsächlichen Namen sind beide test_dir, und dies hat wahrscheinlich zu meiner Verwirrung beigetragen (ein Fehler, den ich hoffentlich nie wieder machen werde).
Jetzt gibt es also kein Verzeichnis mehr ~ / test_dir, es gibt ein Verzeichnis ~ / netdrive / test_dir / und es gibt den defekten Link ~ / netdrive / test_dir / test_dir
Es ist das letzte, das ich löschen möchte. Ich hoffe, das klärt das Wasser eher als es zu trüben.
Bearbeiten 2 :
Mein Betriebssystem ist CentOS und ich bin mir ziemlich sicher, dass das Netzlaufwerk ein Samba ist.
Hier sind die letzten Zeilen der Ausgabe von strace -f -v unlink test_dir
:
unlink("test_dir") = -1 ENOTDIR (Not a directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_dev=makedev(8, 3), st_ino=1573552, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=2512, st_atime=2012/03/21-02:19:02, st_mtime=2012/03/15-13:42:39, st_ctime=2012/03/16-05:31:49}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc843b2f000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2512
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7fc843b2f000, 4096) = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_dev=makedev(8, 3), st_ino=1575882, st_mode=S_IFREG|0644, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=435, st_atime=2012/03/20-11:53:41, st_mtime=2011/12/07-16:51:00, st_ctime=2011/12/21-05:34:01}) = 0
mmap(NULL, 435, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc843b2f000
close(3) = 0
write(2, "unlink: ", 8unlink: ) = 8
write(2, "cannot unlink `test_dir'", 24cannot unlink `test_dir') = 24
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Not a directory", 17: Not a directory) = 17
write(2, "\n", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(1) = ?
Und die letzten paar Zeilen aus strace -f -v rm test_dir
:
newfstatat(AT_FDCWD, "test_dir", 0x7fff71464640, AT_SYMLINK_NOFOLLOW) = -1 ENOTDIR (Not a directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_dev=makedev(8, 3), st_ino=1573552, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=2512, st_atime=2012/03/21-02:19:02, st_mtime=2012/03/15-13:42:39, st_ctime=2012/03/16-05:31:49}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f039e56b000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2512
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7f039e56b000, 4096) = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_dev=makedev(8, 3), st_ino=1575882, st_mode=S_IFREG|0644, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=435, st_atime=2012/03/20-11:53:41, st_mtime=2011/12/07-16:51:00, st_ctime=2011/12/21-05:34:01}) = 0
mmap(NULL, 435, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f039e56b000
close(3) = 0
write(2, "rm: ", 4rm: ) = 4
write(2, "cannot remove `test_dir'", 24cannot remove `test_dir') = 24
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Not a directory", 17: Not a directory) = 17
write(2, "\n", 1
) = 1
close(0) = 0
close(1) = 0
close(2) = 0
exit_group(1) = ?
my_link -> my_link
innerhalb von erstelltmy_dir
.