Sunday 28 August 2016

Unknown

Lock an application in Linux


All of us need some privacy. For security purpose or some personal reason, we just don't want few application to be accessed by everyone. Especially when we are not around! One way of doing so is by not giving our PC to others, but it doesn't work all the times. The other option is more convenient. LOCK THE APPLICATION. Let's say you don't want someone to access nautilus (Default file manager in fedora) or Firefox(web browser), just lock the application so that it asks for root authentication when prompt to open.
* I am using Fedora 24 here, but it can be done in any Red Hat or Debian based OS.

We are going to change '.desktop' file of the particular application in order to lock it. Every application has its own '.desktop'f ile.

In GNOME, an application gets registered into the desktop's menu through a desktop entry, which is a text file with .desktop extension. This desktop file contains a listing of the configurations for your application.

.Desktop file is located in directory:  /usr/share/applications

We will change the permission using the same file.


How to do that?

1. Open the terminal and go to the directory mentioned above.


   $ cd /usr/share/applications
 

List of my .desktop files









2. Select the application that you want to lock. For example, I will lock Firefox.


Open firefox.desktop file using any text editor. As I am in love with vim, I will use the same.


$ sudo firefox.desktop

Text file 'firefox.desktop'
3. We are going to change Exec=firefox %u to Exec=gksudo -k -u root firefox %u

Here we are changing the file permission when executed.

So search Exec=firefox in the text file.

To search in vim, press ':' followed my a '/' and the characters that you want to search.


searching :/Exec=firefox %u
Result
4. Now change it using Insert mode (i), to Exec=gksudo -k -u root firefox %u.

Cheers, we are done!

If you have any doubt, let me know in the comment or message me through contact form.

Unknown

About Unknown -

FOSS enthusiast, Linux evangelist and a programmer heart and soul. In love with Python and C. I contribute to fedora project and seek opportunities to learn more.

Subscribe to this Blog via Email :

2 comments

Write comments
Unknown
AUTHOR
27 July 2018 at 10:21 delete

its not working
after that i m able to launch firefox from apps without password
and terminal doesn't allow me to launch the firefox
the terminal says:-
Running Firefox as root in a regular user's session is not supported.
help now

Reply
avatar
7 August 2021 at 04:40 delete

Hi there. I'm trying to lock a flatpak application in the way that you described. The App I'm trying to lock is notes-up, an excellent application written for ElementaryOS... The exec= line has a few more parameters.

original: Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=com.github.philip-scott.notes-up com.github.philip_scott.notes-up

Edited: Exec=gksudo -k -u /usr/bin/flatpak %u run --branch=stable --arch=x86_64 --command=com.github.philip-scott.notes-up com.github.philip_scott.notes-up

Flatpak .desktop file located in /var/lib/flatpak/exports/share/applications

However it still just lets me in without password prompting.
I'm on Linux Mint Cinnamon btw if that makes any difference.

Thanks in advance.

Reply
avatar