2

I cannot delete a directory containing a colon (using Ubuntu) on a network drive (filesystem: CIFS). How can I delete this directory? (no root privileges, but do have read/write permission)

Output of rmdir ':5N0A210'/ and rmdir ':5N0A210':

rmdir: failed to remove ':5N0A210': No such file or directory

Output of ls -li:

123011781 drwxr-sr-x 2 username domain users      0 May 31 10:00 :5N0A210

Output of ls -1b:

:5N0A210

Output of find . -inum 123011781 -delete:

find: cannot delete ‘./:5N0A210’: No such file or directory

Output of rename 's|:|-|g' *:

Can't rename :5N0A210 -5N0A210: No such file or directory

I just realized I can create directory ':test' and also able to delete with no errors.

I can also create ':5N0A210' and delete it, but it is shown immediately after I refresh GUI. ls -li shows the same inode number as before.

I can also create ':4N0A210' (changed '5' to '4') and delete it with no errors.

All testing was done in same directory as ':5N0A210'.

5
  • You said the client is Ubuntu. What is the server? Jul 17, 2018 at 21:06
  • @roaima I'm not sure. How would I check?
    – lnrdedix
    Jul 17, 2018 at 23:21
  • colon is a reserved character for CIFS so I'm not sure you'll be successful. Any idea how the file got created like that in the first place?
    – Jeff Schaller
    Jul 18, 2018 at 0:52
  • @JeffSchaller I was copying some files from a flash drive to the directory the :5N0A210 resides in (not inside :5N0A210). I had canceled the copy midway.
    – lnrdedix
    Jul 18, 2018 at 16:58
  • @JeffSchaller Then why am I able to create ':4N0A210'?
    – lnrdedix
    Jul 18, 2018 at 16:58

2 Answers 2

0

From the directory in which :5N0A210 is located:

rm -rf ./\:5N0A210

rm -rf ':5N0A210'

rm -rf ./:5N0A210

rm -rf :5N0A210

These all work in my environment.

UPDATE

You can also just remove it from the server side using the above commands. If you don't have access to the server, have someone who does have that access remove it.

4
  • rm -rf \:5N0A210 works with no output. echo $? returns 0. Directory is still there (according to ls -al)
    – lnrdedix
    Jul 17, 2018 at 18:56
  • @Inrdedix Answer updated. Jul 17, 2018 at 19:12
  • Just tried all 4 separately. No output, return code 0. Are you testing with CIFS?
    – lnrdedix
    Jul 17, 2018 at 23:20
  • @Inrdedix I did it both on a cifs share and from the server itself. It doesn't matter as long as you have the permissions. The exit code being 0 also doesn't mean anything other than that the command ran without any errors. Remove setuid with chmod g-s on the directory and try it again. Worst case, go to the server itself and delete or ask someone with access to do it. Jul 17, 2018 at 23:48
0

There are a series of reserved characters that are not allowed in Windows filenames \ / : * ? " < > |. CIFS follows this rule, which means you cannot use any of those characters in a filename.

SAMBA can be configured with vfs catia to translate such characters into visually similar alternatives, but this isn't the default and may not be configured in your instance. (If it is, a simple shell character wildcard ? would be enough to match the colon, ie rmdir ?5N0A210. But you've already tried that and it failed.)

The only other solution is to remove the directory directly on the server hosting the filesystem. If this is Windows then a filesystem check will forceably rename the directory. If it's Unix/Linux with SAMBA then a simple rmdir (or rm -rf) will suffice.

3
  • What's interesting is that I can also create ':4N0A210' and delete it with no errors.
    – lnrdedix
    Jul 18, 2018 at 17:00
  • rmdir ?5N0A210 does match the name, but it still gives an error (rmdir: failed to remove ':5N0A210': No such file or directory).
    – lnrdedix
    Jul 18, 2018 at 17:02
  • @lnrdedix you have to run that on the server, not the client. Jul 18, 2018 at 18:46

You must log in to answer this question.

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