Thursday, 27 August 2015

Lock any application in Linux

Some times we need to lock some applications for security purposes. In this article we will learn how to lock any application in Linux (It is support for both Debian and Redhat based systems)

Our Objective

     We are using .desktop file to lock any application in Linux. All applications has it's own .desktop file. Commonly, .desktop file is used to define various performance of application, when it run in X based system (Commonly GUI). We can modify application's performance via it's .desktop file. .desktop file is also called as configuration file for an application.

Where .desktop file is located?

  All apllications .desktop file is located in /usr/share/applications directory.

 What we need?

  1. Terminal
  2. Any text editor

How to do?

  • Open your terminal window, then go to /usr/share/applications directory.
     cd /usr/share/applications  
  •   I have following applications .desktop files. You can view it by typing ls command


  • For an example, i want to lock firefox applications. So that the application will can ask password (root passord), whenever it launced.
  •  Open firefox.desktop file via any text editor. Where now am using nano text editor
     sudo nano /usr/share/applicatios/firefox.desktop  
       Find Exec=firefox and change it in to Exec=gksudo -k -u root firefox %u. Now save and exit. 
      Now launch firefox, it will ask password to run the application. 

    Thursday, 6 August 2015

    Understanding man pages

    Man pages are stands for manual pages. In Linux, all types of tools have it's own manual page. Manual pages are commonly contains informations and instructions about a command. man pages are very useful for learning commands in Linux.
    Even if we forget the commands, that time also man pages are helpful to remember. To get detailed information about man pages in Linux, then type following commands

    To know respective commands with our needs, then type following command in terminal 
     man -k keyword  

    For an example  
     man -k time  

    where, -k stands for keyword. the above command lists many commands with numbers. This number is refer to section of man pages command. Each section of man describes different kind of commands. You can get an over view of man pages by typing following command
     man man-pages  

    It gives look like following result

    In section 1 commands are described for ordinary users.
    In section 5 documents are document configuration files.
    In section 8 describes management commands.
    When we are using man pages, grep is an very useful utility. grep is the most important command in Linux. It is a filtering utility whcih is allows to search resolves of a command in a specific time. You can also use to find a text in text files. Let we use grep in man pages 
     man -k time | grep 1  
     If a commands separates by pipe means the output of the first command is goes to the input of the second command.
    The above command is gives following result
    Now we can easily identify the command 'date' to know date of the system.
    So now let as see the man page of date command 
     man date  

    For this command we will get following result

    The synopsis is very clearly shows how to use the date command.

    Let we see some useful options
    Look at -s which is describes "set time described by STRING". So we need to set the time. Now our dought is what a STRING?
    To get the detail about STRING type /STRING in the same man page. Now you will get look like following information about the STRING 
    when we are typing date -s with time. We will get human readable format. Now we are learned how to find a command using man -k.
    There is another way to get information about an command  
     date --help  

    Hope you understand!