2

I've examined some topics but I couldn't delete a file under /usr/share/applications

I downloaded Eclipse but somehow I also installed two icons and named them differently.

What I want to do is to delete an icon (not the program) that belongs to Eclipse: there are two different Eclipse icons on my /usr/share/applications which are named "Eclipse Mars" and "Eclipse Mars Java". I want to delete one of them and I have tried to delete using the following commands in the terminal:

sudo dpkg Eclipse Mars Java
sudo rm -f /usr/share/applications/Eclipse Mars Java

However, none of the above have worked...

Is there any other way to delete one of these icons?

NoWeDoR
  • 35
  • 1
  • 1
  • 7

2 Answers2

2

You see two icons because you have two desktop files: either in /usr/share/applications and/or in ~/.local/share/applications. The file name of the desktop file isn't the same in your file manager nor your Launcher. In your file manager and in your Launcher you see what's defined inside the desktop file, note the entry Name=

Example

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Eclipse C++
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=/opt/eclipse-cpp/eclipse/eclipse
StartupNotify=true
StartupWMClass=Eclipse-CPP

Eclips icon screen shot

grep -lr 'Name=Eclipse C++' ~/.local/share/applications

/home/aboettger/.local/share/applications/opt_eclipse_cpp.desktop

Therefore find the right path and file name with the commands below:

  • Eclipse Mars Java

    grep -lr 'Name=Eclipse Mars Java' /usr/share/applications
    grep -lr 'Name=Eclipse Mars Java' ~/.local/share/applications
    
  • Eclipse Mars

    grep -lr 'Name=Eclipse Mars [^J]' /usr/share/applications
    grep -lr 'Name=Eclipse Mars [^J]' ~/.local/share/applications
    

Delete the right file via (NOTE, that are the same commands as above with the additional command sudo rm or rm)

  • Eclipse Mars Java

    grep -lr 'Name=Eclipse Mars Java' /usr/share/applications | xargs sudo rm
    grep -lr 'Name=Eclipse Mars Java' ~/.local/share/applications | xargs rm
    
  • Eclipse Mars

    grep -lr 'Name=Eclipse Mars [^J]' /usr/share/applications | xargs sudo rm
    grep -lr 'Name=Eclipse Mars [^J]' ~/.local/share/applications | xargs rm
    
Fabby
  • 35,017
A.B.
  • 92,125
0

Depends on the name of the package and how you installed it.

From your question, I am guessing you used dpkg

The options for dpkg (and apt-get) are to remove or purge.

remove saves system configuration files, purge does not

-r, --remove package...|-a|--pending Remove an installed package. This removes everything except conffiles, which may avoid having to reconfigure the package if it is reinstalled later (conffiles are configuration files that are listed in the DEBIAN/conffiles control file). If -a or --pending is given instead of a package name, then all packages unpacked, but marked to be removed in file /var/lib/dpkg/status, are removed.

          Removing of a package consists of the following steps:

          1. Run prerm script

          2. Remove the installed files

          3. Run postrm script

   -P, --purge package...|-a|--pending
          Purge  an  installed  or  already  removed package. This removes
          everything, including conffiles.  If -a or  --pending  is  given
          instead  of  a  package  name,  then  all  packages  unpacked or
          removed, but marked to be purged in  file  /var/lib/dpkg/status,
          are purged.

          Note:  some configuration files might be unknown to dpkg because
          they  are   created   and   handled   separately   through   the
          configuration  scripts.  In that case, dpkg won't remove them by
          itself, but the package's postrm  script  (which  is  called  by
          dpkg),  has  to  take  care  of  their  removal during purge. Of
          course, this only applies to files in  system  directories,  not
          configuration   files   written   to   individual   users'  home
          directories.

          Purging of a package consists of the following steps:

          1. Remove the package, if not already removed. See --remove  for
          detailed information about how this is done.

          2. Run postrm script.

See http://manpages.ubuntu.com/manpages/vivid/man1/dpkg.1.html

Neither option removes files from your HOME directory, such as .desktop files. For those you have to manually find and remove them.

Files with spaces in them need quotes or escape the spaces or use tab completion

rm "file with spaces"
rm file\ with\ spaces
rm file<tab><tab>
Panther
  • 104,528