It's because the file name contains spaces. Therefore the rm
command interprets it as multiple arguments, which is not intended and obviously fails.
You need to put the file name in quotation marks to be passed as single argument:
sudo rm "/usr/share/applications/Eclipse Mars C/C++.desktop"
But as especially @JacobVlijm has pointed out, Eclipse Mars C/C++.desktop
is no valid file name, because of about the only character that may not be included in file names, because it separates directories: the /
(slash).
If the command as described above really worked, that means you have the file C++.desktop
inside the directory /usr/share/applications/Eclipse Mars C
, which is very unlikely, as this is not the recommended structure for the .../applications
directories.
But if we assume that this file really exists as described in the previous paragraph, there is another possible way to enter the file name correctly. You can escape all spaces with a \
(backslash) instead of quoting the entire name:
sudo rm /usr/share/applications/Eclipse\ Mars\ C/C++.desktop
But note that rm
only removes files, not directories. As we assume (because everything else is theoretically impossible) that Eclipse Mars C/C++.desktop
is not a file, but a file in a subdirectory, we don't have achieved what we want yet, as there would still be the (probably empty) directory /usr/share/applications/Eclipse Mars C
remaining. To also remove this subdirectory and all contained files (so you may omit the commands above to delete the file only), we have to use one of the command variants below:
sudo rm -r "/usr/share/applications/Eclipse Mars C"
sudo rm -r /usr/share/applications/Eclipse\ Mars\ C
Note that we now don't refer to the file name, but the directory name only. And we use the -r
parameter for rm
, which stands for "delete recursively".
.desktop
file would never ever include spaces. See my answer.Eclipse Mars C/C++.desktop
is not a valid filename; nonetheless anEclipse Mars C
folder containing aC++.desktop
file is perfectly plausible, but seems unlikely since/usr/share/applications
should contain only.desktop
files.rm
which would not have removed a directory :)