Disable Menu Bar Toggle in Firefox

Recent Firefox has the support for toggling the menu bar using the ‘Alt‘ key. But many times its annoying the me. There is a way to disable that in Firefox.

To disable it :
1) Type “about:config” in the url bar and enter
2) Search for “ui.key.menuAccessKeyFocuses” and set the value to “false

That’s it!…

Evernote for Linux


Evernote is an awesome app for note taking but unfortunately it isn’t available for Linux yet. So, we can use the Evernote web app as a standalone application using the GNOME web app launcher. Since the Evernote web app is pretty clean, you don’t feel a difference at all.

From Gnome 3.10 onwards, you can launch any web app without the usual browser menus. Two browser currently supports this:

  • Epiphany (Gnome Web)
  • Chrome

Epiphany isn’t a shinny browser like Google Chrome and Firefox. It doesn’t render some pages correctly. And Firefox doesn’t support web app launchers yet. So, I recommend the Google Chrome for this job.

1) Go to your Evernote home page (usually https://www.evernote.com/Home.action).
2) In Chrome, Click “Settings -> More tools -> Create application shortcuts…”.
3) It’ll create the necessary Desktop entry and Application Menu entry in the user’s home directory. Just click “Create“.
4) It’ll use the web app’s favicon as the Application Icon which has low resolution and not good.
5) So, to change the application icon, download the evernote icon from the internet (https://cdn4.iconfinder.com/data/icons/free-colorful-icons/360/evernote.png).
6) Go to user’s application settings directory :
cd ~/.local/share/applications/
7) Find the .desktop file which starts with “chrome” as prefix and “evernote” in the file name like “chrome-https___www.evernote.com_Home.action_2.desktop“.
8) Replace the “Icon=” entry’s value with the newly downloaded icon’s path.
9) Just logout and login.
10) Search for Evernote in your GNOME Activities, you’ll get a fancy Evernote app in your menu.

Note : I’m using Fedora 21 with GNOME 3.14.2 on it.

Run shell script as root user (without sudo) using setuid

In the most Linux distributions, setuid doesn’t work on shell scripts because of the security issues associated with it.

But you can use the setuid on binary files and from there you can execute the shell script as root user. And the following steps will help you to do that.

1) Copy the following C program to a file named “runasroot.c” and this program simply runs a script which is passed as command-line argument.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {                                              
  if (argc != 2) {                                                              
    printf("Usage: %s /path/to/script\n", argv[0]);                             
    printf("Note: '/path/to/script' can be either relative or absolute path.\nE\
xamples:\n%s ./build.sh \n%s /tmp/test.sh\n", argv[0], argv[0]);                
  } else {                                                                      
    printf("Running the script '%s' as root user...\n", argv[1]);               
   return 0;                                                                    

2) Compile it.

gcc runasroot.c -o runasroot

3) Change the ownership of the compiled executable binary to root

sudo chown root:root runasroot

4) Change the permissions on the binary file with setuid flag

sudo chmod 4755 runasroot

5) Run the script using the executable binary file

./runasroot script.sh

Examples :

./runasroot ./build.sh 
./runasroot /tmp/test.sh

You can even copy this ‘runasroot’ executable file to your home bin directory (i.e., in ‘/home/user/bin‘) so that you can use it anywhere in your scripts. And you can use the ‘runasroot‘ command (without any password prompt) instead ofsudo‘ in your commands. If you want to pass parameters to the commands, you should use single/double quotes to surround it.

runasroot 'fdisk -l'

instead of

sudo fdisk -l

Warning: Make sure you don’t place this script in any common directory (like /usr/bin or /opt) in a multi-user environments.

Generating and Compiling Java Classes using Java Compiler API

Steps :

  • Construct JavaFileObject from any source (i.e, here, from sourceCode String) and make it to iterable object
  • Get the Java System Compiler
  • Create a compiler task using Compiler.getTask(), (if required create the task with diagnostic collection to get compilation errors)
  • Execute the Compiler Task (compile it).

Source Code :

import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Locale;

import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;

public class CompileDynamicClasses {

static String sourceCode = "class DynamicClass{" + "public static void main (String args[]){"
+ "System.out.println (\"Hello, Dynamic Class!\");" + "}" + "}";

public static void main(String[] args) {

// Construct a JavaFileObject from source code
SimpleJavaFileObject fileObject = new DynamicJavaSourceCodeObject("DynamicClass",

Continue reading "Generating and Compiling Java Classes using Java Compiler API"

“Cannot open font file True” in Fedora

When you start the fedora 16/17, it will show you an message “Cannot open font file True” in boot screen for few seconds. To fix this, we need to change the sysfont to default.
Steps :
1) Open the grub configuration
** sudo vi /etc/default/grub
2) Update the SYSFONT to latarcyrheb-sun16 and save the file.
** Look for "SYSFONT=True" and replace it with "SYSFONT=latarcyrheb-sun16"
3) Generate the grub configuration
** sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Bugzilla URL : https://bugzilla.redhat.com/show_bug.cgi?id=799401

Installing and Configuring Squid Proxy Cache Server

Squid is a proxy caching server. You can use squid in effective way, so that you can control the internet access over your network.

In Fedora, you can install the squid proxy cache server by just typing the following command, its available in the fedora main repo itself.

$ sudo yum install squid

Before starting the squid server you need to configure it with the help of this configuration file in ‘/etc/squid/squid.conf’.

In this scenario, I have a proxy server running in background which will respond to specific ip’s (LAN) and forward to a defined gateway. Using the gateway, all the hosts from my all LAN can reach internet.

What my system (proxy server) has to do is, to listen in a specified port ‘3128’ and forward the requests to the gateway.

My Gateway :
My IP Address :

Add the following things to that ‘squid.conf’ :
acl localnet src
http_access allow localnet
http_port 3128
acl RestrictedSites dstdomain “/etc/squid/restricted_sites”
http_access deny RestrictedSites

#cat /etc/squid/restricted_sites