1

Unsuccessfully creating a .desktop file. In usr/share/applications user has r+w permissions. Do I need to change to rwx to create viable .desktop?

sudo chmod u+x for my user is not working (lacking operand after 'u+x').

Tried Freedesktop but it doesn't seem to cover this aspect...

Permissions are not my strong suit and I am new... very frustrated.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Foo
Comment=FooApp
Exec=/usr/share/applications/simi1.py
Icon=/usr/share/icons/hicolor/48x48/apps/pic.png
Terminal=true
StartupNotify=false

Idu how this is possible...my file is clearly in the dir

screenshot of error and file ls info

meyeti
  • 59

2 Answers2

0

By default root should be the owner of the /usr/share/applications directory.

Are you able to use sudo to create and edit the file?

Either at a console :

sudo nano /usr/share/applications/myApp.desktop

Or maybe :

sudo gedit

then write the file and save it to the directory.

It is best practice to use sudo to make/edit files in directories with root permissions rather than change these permissions.

Alternatively, you could write the file in your home directory then use sudo to copy it to /usr/share/applications

sudo cp myApp.desktop /usr/share/applications/

Finally, if you want to use this myApp.desktop file as a shortcut on your desktop simply :

cp /usr/share/applications/myApp.desktop ~/Desktop/
0

First, you need to have root privileges to do this. Second you don't need executable permissions on the files in /usr/share/applications. A simple ls -l on the directory on my own machine shows this:

$ ls -l
total 2864
-rw-r--r-- 1 root root  5511 Dec 19 08:14 alacarte.desktop
-rw-r--r-- 1 root root  3417 Dec 17 15:21 assistant-qt5.desktop
-rw-r--r-- 1 root root 14329 Jan 23 13:37 bamf-2.index
-rw-r--r-- 1 root root   296 Nov  2  2015 bastet.desktop
-rw-r--r-- 1 root root  6305 Jan 16  2017 bleachbit.desktop
-rw-r--r-- 1 root root  6333 Aug 30 13:38 bleachbit-root.desktop
...

Note that none of the above files are executable; in other words, files which are present in application directories like /usr/share/applications or ~/.local/share/applications are not executable because no one is going to execute them. Files in your Desktop folder are executable so you can execute them but no one goes in /usr/share/applications to run an application.

Let's solve the first problem:

You can become root by running sudo -i and then entering your user password. Once you are root, you can create the desktop file with either

# gedit /usr/share/applications/[file].desktop

Or

# nano /usr/share/applications/[file].desktop

Now you can enter the contents of the file as you desire.

hexman
  • 891