Debian : Setting environment variables for all users

An environment variable like JAVA_HOME can be set in different ways in  linux systems.

#1 . If we set environment variables in .bashrc file found in each users home directory, it will be accessible only for that user.

~/.bashrc   ——> specific to a particular user.

Setting environment variable for all users.
If the environment variable to be available for all users,

#2.   it can be set in /etc/environment

For instance let see how JAVA_HOME can be set,
Open this file in  vim or any editor of your choice, and add following line in it.
This sets JAVA_HOME for default open JDK. Please note that location is specified in quotes,

Then save the file and run the command, to have these these changes in effect immediately.
source /etc/environment
But this is not a recommended method.

#3. Setting via /etc/profile

vim /etc/profile (open the this file in vim )
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
Then save the file and run following command.
source /etc/profile

#4. Setting via /etc/profile.d
This can be viewed as an extension to the above step. Having all application specific environment file in /etc/profile makes the maintenance a hassle. As a solution to this, variables will be specified as a separate module inside the directory /etc/profile.d/. These modules are shell scripts and should end with .sh extension, otherwise system is not going to recognize it. You can read further on this from here.

I think this would be clear, with the following example.
In order to set JAVA_HOME bythis approach, first create a file inside /etc/profile.d (The file should end with .sh extension ).

Then open this file using vim or any editor
vim /etc/profile.d/
Then add following lines ( This JAVA_HOME location could be different for others)

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${JAVA_HOME}/bin:${PATH}

Then save the file and run the following command.
source /etc/profile

You can also consider reading this


VirtualBox – Copy Paste Not working (Debian)

Even though you have set bidirectional for the option Shared Clipboard in settings ( under General –>Advanced ) some times it will not work. The following steps fixed this issue for me.

In the guest OS do the following :

  1. update source.list file
  • enable the contrib repositories; e.g. for Debian 8, make sure your /etc/apt/sources.list contains something like
    deb jessie main contrib

2.  Install guest addition software.

apt-get update
apt-get install virtualbox-guest-dkms

Error processing package nginx

During the installation of nginx using apt repository ie when we use the following command :
apt-get install nginx we may come across some error messages like this,

Job for nginx.service failed. See ‘systemctl status nginx.service’ and ‘journalctl -xn’ for details.
invoke-rc.d: initscript nginx, action “start” failed.
dpkg: error processing package nginx-full (–configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-full (>= 1.6.2-5+deb8u4) | nginx-light (>= 1.6.2-5+deb8u4) | nginx-extras (>= 1.6.2-5+deb8u4); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-full (<< 1.6.2-5+deb8u4.1~) | nginx-light (<< 1.6.2-5+deb8u4.1~) | nginx-extras (<< 1.6.2-5+deb8u4.1~); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.

dpkg: error processing package nginx (–configure):
dependency problems – leaving unconfigured
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)


Stopping the apache service (or current webserver) before we try to install nginx, would solve this issue. Once we get nginx installed, we can start apache service again.

Hence the following steps are supposed to solve this issue.

1. sudo systemctl stop apache2.service
2. sudo apt-get install nginx
3. sudo systemctl start apache2.service

Install errors with node v4 and v5 #776

While building  a nodejs application (npm install) I came across some weird issues which are in a nutshell as follows.
v8.h:336:1: error: expected unqualified-id before ‘using’,  node-gyp

The nodejs version I was using was v5.10.1 and the reason for this issue was incompatible gcc. and upadating gcc to correct version solved the problems. Following steps are what I did to fix the issue.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 80 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --config gcc (choose gcc-5 from the list)

Check that the correct versions of gcc and g++ are being used by default by running gcc -v; g++ -v

Oozie – Connection Refused Error on creating sharelib directory on hdfs

Please refer

After preparing oozie  war file, we need to create sharelib directory on HDFS file system using the command  (we need to be in oozie home directory)

./bin/ sharelib create -fs hdfs://localhost:9000

The above command will internally issue a HDFS create directory command to the Name node running at hdfs://localhost:9000 and then copy the shared library to that directory.

Though we expect everything to be normal, sometimes errors may popup. The error I got was added below.


From the connection error shown on  screen, it is clear that name node at localhost:9000 is not  working. This can be confirmed by typing in terminal :

telnet localhost 9000 

Now I need to confirm the if that was the specified port for name node. This can be done using the command

# first get HDFS info
hdfs getconf -confKey fs.defaultFS

the above command gives the the output hdfs://localhost:9000.                                                              So we  are using correct path and port number

Now into the details of the issue.

The problem is name-node has not been started. So we need to ensure that all hadoop services are running.  Then we need to run the following command from hadoop user home (/home/hadoop for me) jps

This command is expected to give the following result if everything is normal,

2583 DataNode
2970 ResourceManager
3461 Jps
3177 NodeManager
2361 NameNode
2840 SecondaryNameNode
But when I executed the command, NameNode was missing from the result. That is the reason why we are not able to create sharelib on hdfs, Our real problem. So fixing this is the key to our problem.
This can be done as follows:
1. Move to hadoop user home (for me  /home/hadoop)
stop all hadoop services using
2. Then reformat name node using
   hdfs namenode -format
3. then restart hadoop all services using by specifically runningthe commands and
4.Then issue the command jps
5. If everything is normal will be getting earlier mentioned expected result. If that the case, we can resume with oozie installation. and run the command,
 ./bin/ sharelib create -fs hdfs://localhost:9000
But unfortunately, for me data node was missing in jps output. Fixing this issue is a bit tricky.
Before that stop all hadoop services using
1. First we need to get the hdfs data node path. This will be specified in hdfs-site.xml of hadoop. (for me it was in /usr/local/hadoop/etc/hadoop)
2. for me data-node was in /home/hadoop/mydata/hdfs/datanode
3. cd to above path and remove all its contents by issuing rm command
   hadoop@space-Vostro-3800:/home/hadoop/mydata/hdfs/datanode$ rm -r *
4. Then go to hadoop user home folder and reformat name node .
   hadoop@space-Vostro-3800:/home/hadoop$ hdfs namenode -format
Then start all hadoop services using or by running the commands separately.
5. The run the command jps. Then I got the expected result
So here name node service is running and this can be verified by
                      telnet  localhost 9000
So everything is under control now . Now we can resume with oozie installation.  We can move to oozi folder in hadioop user home and run
hadoop@space-Vostro-3800:/home/hadoop/oozie$./bin/ sharelib create -fs hdfs://localhost:9000
Now we can create database using
hadoop@space-Vostro-3800:/home/hadoop/oozie$ ./bin/ create -sqlfile oozie.sql -run
ok. with this database is created.
Now start oozie service using
hadoop@space-Vostro-3800:/home/hadoop/oozie$ ./bin/ start
The same can be verified from web interface. Please type the following url in your browser.
# Web UI
Now we are done with so called oozie installation.