How to configure USER permanent PATH link in Linux (Ubuntu 12.04)

  When we do our scripting or any other job in Linux, we always have problem in running the script or command directly from our shell terminal. As shown in my previous video, we always need to go  from one folder to one folder to execute file. The reason why we need to do this because our shell doesn't recognize our working folder as a valid location to check the command as determine by our kernel. A command might consist of several line of bash configuration and it can go up to hundred line in which we call it a script .We use script to make our machine do what we want to do with our machine. 
 
   In Linux, this function is control under the 'Environment Variables'.Environment variables consist of names that have values assigned to them.Environment variables provide a way to influence the behavior how our script/command/software function in our machine.

   Our machine stored the 'Environment Variables' under variable called "PATH".Our system will scan and check the "PATH" variable  folder for the command that we type in the terminal.It will then execute it as a valid command or not.For example if we run "ls -a" in our terminal, our system will scan the system folder to find which file to execute .Thus if we want to make our life easier, we need to include the folder that we want the system to scan to .By default,we can see what folder is included in our machine environment by typing "echo $PATH" as below example.

shark_attack@Positive-Space:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

In Bash, we can manipulate  the variable using "export"command , we can use below format for this purpose .

 export VARIABLE=value
or more specifically

export PATH=$PATH:/home/shark_attach/Programming/bash  #/home/shark_attack... is my folder


Need to be highlighted here the "export" command will only run as a temporary  on our machine.when we restart our machine, the link will be deleted. To make it permanent, we need to write it on our system variable. There are two ways in doing so which is on :

1. User level
2. System level 

Differences between both level for Ubuntu are simplified in below table


FILE CAN BE CHANGE ENV SETTINGS DETAILS LEVEL TYPE
~/.pam_environment(Recomended)
~/.profile
~/.bash_profile
~/.bash_login
~/.bashrc
Only effect a particular user USER
/etc/environment (Recomended)
/etc/profile
/etc/bash.bashrc
It effect whole user that use the system SYSTEM
                                    Environment Variable in Ubuntu

Each of this file have their own specific function on our machine. For more detail information,please visit Ubuntu Variable Guide

Once you've decided which file you should be manipulating, use the echo and single quote (') as below. Single quote means that we  echo the file  literally as how we want it to be written.
echo 'export PATH=$PATH:/home/shark_attack/Programming/bash' >>~/.bashrc

restart the Terminal and try run the file/script. This should work. Please see my videos for more detail.



Read Previous : How to configure Sudoer