Welcome to Techy Tunes !

Follow Me
As a developer you might want to work with different development environments. As an example, I had to work with Java 1.4, 1.5, 1.7 and 1.8 :D . When JDK changes all other stuff such as maven will also have to change.

One thing you can do is have everything in you bashrc or bash_profile and comment and uncomment the required environment variables. Believe me, I did that for a long time. duh...

Or else, you can have scripts to set your environment !!! (yay).  One sh file would look like this

#!/bin/sh
export JAVA_HOME=/home/isuru/installs/jdk/jdk1.8.0_101
export PATH=$JAVA_HOME/bin:$PATH

and the other would look like this

#!/bin/sh
export JAVA_HOME=/home/isuru/installs/jdk/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH

But we can't memorize where this files are to locate them always. That's where alias comes in.

Create .bash_aliases file in your home directory. Check whether this file is being sourced inside your bashrc or bash_profile.

Add aliases to the ~/.bash_aliases as follows
alias java8='. /home/isuru/stuff/scripts/java8.sh'
alias java7='. /home/isuru/stuff/scripts/java7.sh'
In my machine both the script files are located under the directory /home/isuru/stuff/scripts. Make sure the sh files have execute permissions.

Now we are done here. Open a new shell and type in java8. and then java  -version. Type in java7 and the java -version. See the magic :P

If you are following a routine everyday executing shell scripts, or some other stuff, put them in a single sh file and do register it as an alias. Will make your life easier.

If opening a new terminal really hurts, you can source the ~/.bashrc or ~/.bash_profile file. You can stay where you are in the current terminal and yet get the benefits of alias. See below to uncover a secret ;)

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

When we open a new terminal the ~/.bashrc or ~/.bash_profile automatically sources :D :D

Below are the steps to follow. I found these steps from a forum (which I cannot find the link now) and they have missed one important thing. So, this is how I got my huawei dongle working in Ubuntu 16.04


  • Create a mobile broadband connection first. You can do it by Edit Connections option.
  • In the terminal type lsusb having the dongle plugged in. Below is what I got

  • Note the line "Bus 001 Device 007: ID 12d1:1446 Huawei Technologies Co., Ltd. Broadband stick". This is my dongle
  • Note these, you need these up ahead. 12d1 is the vendor id, 1446 is the product id. These might change according to your dongle type (this was what they have missed ;))
sudo vi /lib/udev/rules.d/40-usb_modeswitch.rules
  • Add following line before "LABEL="modeswitch_rules_end"

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"


  • save the file and type the following. Make sure 12d1 replaces your vendor id and 1446 replaces your product id as per your dongle
sudo touch /etc/usb_modeswitch.d/12d1:1446.
  • Last step as follows. Same rules apply here for the vendor id and the product id. Additionaly add the prefix "0x" for the vendor id and product id
sudo usb_modeswitch -J -v 0x12d1 -p 0x1446 
.
  • I got the below screen and everything was good. 

  • I had to issue the command "sudo usb_modeswitch -J -v 0x12d1 -p 0x1446 " always when I restart the machine, but I always believe that having something is better than nothing ;)