2

I am going through a hard time trying to delete three empty directories that were created after an aborted process of "wiping free disk space" of bleachbit, I've used every suggested method and none seem to work, I tried shredding them with bleachbit and deleting using commands like rm -d, rm -f, rm -r, I tried renaming them, moving them, I even replaced Ubuntu 16.04 with 17.04 on the off chance that what's wrong will be fixed, but they're still there.

The directories are in separate partition and not in the home directory. Their names are as follows:

  1. -9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR
  2. CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC
  3. qoRSRba1C8bPYrpk_5OW6Qi9mPC.zhyzqUwivpQfArgb9

Whenever I try something I get this message that says:

No such file or directory

here are some of the output:

me@MyPC:~$ rm -f /media/me/702E29F142F/-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0‌​z1A62Sh25BS0pYZEby6J‌​DVvtMZavFTCUgQUpjuJU‌​CZ0pKspQLd40O3Zc9rzg‌​GRFcxNBKOgr7KnVwZw_A‌​4kkx4R9zq1oON8aP4y00‌​EY0AuIJYRdCs9v9oYNKr‌​FasQoMXwuLiw5lh0Z8J6‌​Jh8u8pjDNnP31p0oBYsj‌​TQTPUE1MXVqgAuWNjrht‌​EFuouXKR

me@MyPC:~$ rmdir -- $ 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC'
rmdir: failed to remove '$': No such file or directory
rmdir: failed to remove 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC': No such file or directory

me@MyPC:~$ rmdir -- 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC'
rmdir: failed to remove 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC': No such file or directory

me@MyPC:~$ rmdir 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC'
rmdir: failed to remove 'CD09GzmqmJfZ2rBA5rtBsWR1EAewq-fZWJCJhlO6r1aC': No such file or directory

me@MyPC:~$ rmdir -- -9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR
rmdir: failed to remove '-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR': No such file or directory

me@MyPC:~$ sudo rmdir -- -9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR
rmdir: failed to remove '-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR': No such file or directory



me@MyPC:/media/me/702E29F142F2362F$ rmdir -- $'qoRSRba1C8bPYrpk_5OW6Qi9mPC.zhyzqUwivpQfArgb9'
rmdir: failed to remove 'qoRSRba1C8bPYrpk_5OW6Qi9mPC.zhyzqUwivpQfArgb9': No such file or directory

When I try moving it to trash or deleting using Nautilus, it looks like this:

Nautilus showing a similar "No such file or directory" error

9
  • Could you add the whole path of these files and tell us what file system type they're stored on?
    – Byte Commander
    Aug 23, 2017 at 22:25
  • /media/me/702E29F142F/-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR, all are in the same path which is the partition i use to keep all my files and data, and checking their properties i see this "Type: Folder (inode/directory)".
    – AliOuld
    Aug 23, 2017 at 22:28
  • Okay, so it's a separate data partition on your internal hard disk. What file system is that partition formatted with? Maybe ext4, NTFS, FAT32? Show the output of mount | grep '/media/me/702E29F142F' please.
    – Byte Commander
    Aug 23, 2017 at 22:36
  • the partition formatted with NTFS.
    – AliOuld
    Aug 23, 2017 at 22:44
  • me@MyPC:~$ rm -d /media/me/702E29F142F/-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR rm: cannot remove '/media/me/702E29F142F/-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0z1A62Sh25BS0pYZEby6JDVvtMZavFTCUgQUpjuJUCZ0pKspQLd40O3Zc9rzgGRFcxNBKOgr7KnVwZw_A4kkx4R9zq1oON8aP4y00EY0AuIJYRdCs9v9oYNKrFasQoMXwuLiw5lh0Z8J6Jh8u8pjDNnP31p0oBYsjTQTPUE1MXVqgAuWNjrhtEFuouXKR': No such file or directory
    – AliOuld
    Aug 23, 2017 at 23:01

2 Answers 2

5

Some of your names start with -, so pass -- first or use an absolute path.

For empty directories, use the rmdir command and write -- as a separate word before name of the first directory to remove. If -- has not been passed (this applies to the commands you've tried as well as rmdir) then words that begin with - will be interpreted as collections of options controlling how the command behaves rather than as filenames for the command to operate on.

You will have to write your commands based on the directory names you have. Because of possible errors in formatting the filenames in the Stack Exchange visual editor, this is a case where I don't recommend copying directly from this answer. However, as an example which I expect you to modify as needed, if you have a directory whose name is:

-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0‌​z1A62Sh25BS0pYZEby6J‌​DVvtMZavFTCUgQUpjuJU‌​CZ0pKspQLd40O3Zc9rzg‌​GRFcxNBKOgr7KnVwZw_A‌​4kkx4R9zq1oON8aP4y00‌​EY0AuIJYRdCs9v9oYNKr‌​FasQoMXwuLiw5lh0Z8J6‌​Jh8u8pjDNnP31p0oBYsj‌​TQTPUE1MXVqgAuWNjrht‌​EFuouXKR

And it is empty, and you are in its parent directory (you can use cd to go there and pwd to check what directory you are currently in), then you can remove it like this:

rmdir -- -9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0‌​z1A62Sh25BS0pYZEby6J‌​DVvtMZavFTCUgQUpjuJU‌​CZ0pKspQLd40O3Zc9rzg‌​GRFcxNBKOgr7KnVwZw_A‌​4kkx4R9zq1oON8aP4y00‌​EY0AuIJYRdCs9v9oYNKr‌​FasQoMXwuLiw5lh0Z8J6‌​Jh8u8pjDNnP31p0oBYsj‌​TQTPUE1MXVqgAuWNjrht‌​EFuouXKR

Or, if it's owned by root or you otherwise don't have permissions to remove it:

sudo rmdir -- -9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0‌​z1A62Sh25BS0pYZEby6J‌​DVvtMZavFTCUgQUpjuJU‌​CZ0pKspQLd40O3Zc9rzg‌​GRFcxNBKOgr7KnVwZw_A‌​4kkx4R9zq1oON8aP4y00‌​EY0AuIJYRdCs9v9oYNKr‌​FasQoMXwuLiw5lh0Z8J6‌​Jh8u8pjDNnP31p0oBYsj‌​TQTPUE1MXVqgAuWNjrht‌​EFuouXKR

Notice that there is a space after the -- argument. That is important.

Or you can use the full path of the directory. Then you don't have to worry about what directory you are in when you run the command and the -- is optional. For example (based on what you showed in a comment):

rmdir /media/me/702E29F142F/-9tDCcQrfg8u8e.AlOYZ7DX0q-ZRR77j9q8Gq0‌​z1A62Sh25BS0pYZEby6J‌​DVvtMZavFTCUgQUpjuJU‌​CZ0pKspQLd40O3Zc9rzg‌​GRFcxNBKOgr7KnVwZw_A‌​4kkx4R9zq1oON8aP4y00‌​EY0AuIJYRdCs9v9oYNKr‌​FasQoMXwuLiw5lh0Z8J6‌​Jh8u8pjDNnP31p0oBYsj‌​TQTPUE1MXVqgAuWNjrht‌​EFuouXKR

(Or with sudo rmdir, as above.)

Some names may contain characters that require quoting.

If that doesn't help and you continue getting the same No such file or directory message, then the problem is that you aren't successfully naming the directories. Presumably their names contain unusual characters.

It's not obvious that this is the case based on what you have shown but it is a common problem so I'm including it just in case. If your directory names contain spaces or other characters treated specially by the shell like line breaks, *, or $, then you should enclose the names in single quotes. This will be sufficient so long as the names themselves do not contain any single quotes.

More generally, if you've used cd to get to the directory that contains these directories, you should be able to get a list of entries in that directory (including the subdirectories you're interesting in removing) by running:

ls -1b

This differs from an ordinary ls command in two useful ways:

  • The -b flag causes the paths to be printed with escape sequences which can be pasted between $' '. No space should appear between the initial $ and the opening ' character.
  • The -1 flag makes ls list one entry per line. That can help decrease confusion about where one filename ends and the next begins.

This should enable you to write commands that remove, rename, etc. these directories. If they are truly empty, you can then use the rmdir command to remove them. You may need to run this command as root, which you can do with sudo.

Here's a deliberately oversimplified illustration of what commands you might run. Supposed ls -1b listed:

abc\ def
ghi\njkl
pqr\b\b\bstuv
$$$$$$$\b\b\b$$$

In the first case there is a space. In the second case there is a newline (a line break). In the third case, there are three backspace characters. In the fourth case, which there are both $ and backspace characters.

To remove those directories you could use:

rmdir -- $'abc\ def'
rmdir -- $'ghi\njkl'
rmdir -- $'pqr\b\b\bstuv'
rmdir -- $'$$$$$$$\b\b\b$$$'

As above, you may need sudo.

rmdir can take multiple filenames but if you use one command per removal then it may be easier to understand whatever error messages you receive, if any.

In those particular examples, the directory names did not start with - and the -- flag was not necessary. But it did not do any harm.

$' ' versus plain ' '

Unlike quoting with ' ', quoting with $' ' causes backslash escapes like \n and \b to be expanded.

'ghi\njkl' identifies a file whose name is literally:

  • ghi\njkl

In contrast, $'ghi\njkl' identifies a file whose name is:

  • ghi jkl

If you're running a graphical file browser, you may be able to drag from it.

With some graphical file browsers (such as Nautilus, i.e., "Files") and some terminals (such as GNOME Terminal), there is an even easier way to get a usable absolute path to a file in a terminal command that you are writing.

This will work on most Ubuntu systems that have a graphical user interface installed but it will pretty much never work when you're logging in remotely via SSH.

You can drag the folder from the file browser window into the terminal window to paste the full path to it in the terminal. With your mouse over the terminal window, release the button.

For this to be useful, the best approach is to write the command you want to run first. For example, write this and include a space at the end but don't press Enter yet:

rmdir --

Then drag the folder from the file browser window into the terminal window. If your file browser and terminal emulator support it, you should see a path pasted, with \ or ' based quoting automatically provided. You can then press Enter to run the command. Even if the command does not succeed, this will usually give a more useful error message than No such file or directory.

7
  • I followed every step and tried every suggestion and none was useful, nevertheless I am thankful for your help, i think i have no choice but accept those directories until i get the chance to format that partition.
    – AliOuld
    Aug 23, 2017 at 23:42
  • first i typed this command 'ls -1b' that showed the contents of /media/me/702E29F142F2362F among them those three culprits and it appears that their names are the same, and then i used the command rmdir -- with single quotes, or rmdir -- without single quotes, or rrmdir -- $'directory', and every time got the same output "No such file or directory"
    – AliOuld
    Aug 24, 2017 at 0:02
  • @AliOuld Can you copy all the text from the terminal, starting from the line that shows the prompt of a command you have run, all the way down to the last character of text shown on the terminal, and paste it into your question? There's no good way to figure out what the names are or what problem is just incomplete information in comments like this. There are other approaches--e.g., you can try dragging the directories from the file browser into your terminal if your terminal supports it, I'll add that--but if you expand your question then it should be possible to know what will likely work. Aug 24, 2017 at 0:05
  • @AliOuld Even if you cannot make the text appear correctly after pasting it into your question, you can still save the edit and let me know and I can view the source and fix it myself (assuming the site lets you submit the edit that way). Aug 24, 2017 at 0:05
  • i edited my original post, you can see the text.
    – AliOuld
    Aug 24, 2017 at 0:10
2

Graphical method

I would use nautilus the file manager built into Ubuntu. Simply highlight the directories, right-click and select "send to trash". If directories have large files you might want to empty trash right away.

If the directories are owned by root Nautilus won't let you delete them. In this case open a terminal and use:

gksu nautilus

Can't move to trash but can delete directly

According to this Linux Mint question some Windows files can't be moved to trash but can be deleted directly.

Another answer in this thread points out how to find out the file system type using:

df -T /media/<path_to_project_folder>

Then changing the /etc/fstab entry worked for mounting using different parameters and successfully deleting the files.


Terminal Method

As per this Super User Q&A you can delete files with special characters (weird names) by changing to the directory containing them and using:

rm -i -- *

This will prompt you to delete each file. You can and should change '*' to a narrower match if there are a lot of files. The -- stops processing options, so a file named -d will be removed by rm successfully.

Another answer in the same thread proposes deleting by inode number using. It says you can use ls -li to show all files by their inode. Then run this command to remove the file:

find . -inum ${INODE_NUM} -delete

You can add -maxdepth 1 to my find just to be safe:

find . -maxdepth 1 -inum ${INODE_NUM} -delete
7
  • see the picture in my edit, nothing worked and it really is becoming annoying. thanks anyway for your input.
    – AliOuld
    Aug 24, 2017 at 17:36
  • I wonder if it is permissions or mount problem. Can you click the down arrow to show more details and post a new screen shot please? Aug 24, 2017 at 19:37
  • By itself lack of permissions or ownership should not cause a "No such file or directory" error, especially locally, but I agree that this may be useful in further narrowing down the problem. ...This makes me wonder if maybe these directories actually don't exist and are only being shown due to a kernel or driver bug. That is, perhaps instead of the filenames being wrong due to odd characters (as I had suspected) they are wrong because there really is no such file with that name anymore. @AliOuld Have you tried rebooting to see if they are still there? Also can you add the output of mount? Aug 24, 2017 at 20:43
  • those directories were created on July 25th, so it is now a full month since then, you can imagine how many times I shut down or rebooted my computer, I read somewhere that is bug caused by bleachbit 1.10 or other version I don't really remember, maybe I'll unmount the partition and see, is that your suggestion?
    – AliOuld
    Aug 24, 2017 at 22:33
  • All of these seem worthwhile things to try but I think you should click the down arrow to get a detailed error message as the screen is offering. Aug 24, 2017 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.