LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-30-2011, 02:45 AM   #1
anis_huq
LQ Newbie
 
Registered: Nov 2006
Posts: 29

Rep: Reputation: 0
Changing the environment variable permanently in Ubuntu 10.10


Friends, I want to make change to environment PATH system wide. Because I have program called "md5". I want to execute it from anywhere (i.e any directory).

My md5 program is located at "/home/ahuq/MappingServer/md5_program". So what I did was to put: "export PATH=$PATH:/home/ahuq/MappingServer/md5_program" in the running SHELL. This only makes temporary changes and lets me run the "md5" program from anywhere temporarily. But I want to make this change permanent. So what I did was to put the "PATH=$PATH:/home/ahuq/MappingServer/md5_program" line into the "/etc/environment" file. This screwed everything up and then for a while I couldn't execute anything from SHELL. I knew the absolute path of "nano" editor and used it to modify the file (i.e. /etc/environment) back to its original condition. This fixed the problem and now I can run programs like "ls" from the SHELL.

But still I need a way to permanently add the path of "md5" to the environment. How can I do this in Ubuntu 10.10? Which file needs to edited?

Do I just logout or do I have to restart the system to make the changes active?

Bye.
 
Old 04-30-2011, 03:02 AM   #2
Hevithan
Member
 
Registered: Apr 2011
Location: Washington State
Distribution: Zorin5-(Ubuntu 11.04) // Backtrack 5-(Ubuntu 10.04) // Dreamlinux 3.5-(Debian)
Posts: 275
Blog Entries: 5

Rep: Reputation: 39
Quote:
Originally Posted by anis_huq View Post
So what I did was to put: "export PATH=$PATH:/home/ahuq/MappingServer/md5_program" in the running SHELL. This only makes temporary changes and lets me run the "md5" program from anywhere temporarily. But I want to make this change permanent.
I'm going out on a limb here ... In other words: I only understand vaguely what you mean.


What I get is that you want all users to be able to access this program, and all I can think of is: Have you done a $ chmodcommand? ch allows whoever you add to it, permission to access files for their own use or reading ... I don't know if that applies to you, But it sounds like it may.

From washington.edu:

To change the mode of a file, use the chmod command. The general form is

Code:
    chmod X@Y file1 file2
where: X is any combination of the letters `u' (for owner), `g' (for group), `o' (for others), `a' (for all; that is, for `u,g, and o'); @ is either `+' to add permissions, `-' to remove permissions, or `=' to assign permissions absolutely; and
Y is any combination of `r', `w', `x'. Following are some examples:
Code:
     chmod u=rx file        (Give the owner rx permissions, not w)
     chmod go-rwx file      (Deny rwx permission for group, others)
     chmod g+w file         (Give write permission to the group)
     chmod a+x file1 file2  (Give execute permission to everybody)
     chmod g+rx,o+x file    (OK to combine like this with a comma)
THIS is a link to their site.



Quote:
Do I just logout or do I have to restart the system to make the changes active?
With alot of changes you don't really have to. But when I make a change or install a new program, I generally do a restart for 2 reasons.

1) If it causes the system to malfunction or run undesirably, I know what the reason is.

2) From what I understand, Linux holds onto processes as long as it is using them, So I like to restart and have it be as fresh as possible before running new things, or working with changes I have made.


Hope this info is helpful, and if not ... Well I tried
Best of luck!

Last edited by Hevithan; 04-30-2011 at 03:10 AM. Reason: Horrible spelling
 
Old 04-30-2011, 03:20 AM   #3
spankbot
Member
 
Registered: Aug 2007
Posts: 131

Rep: Reputation: 16
You need to add that PATH statement to your .bashrc file (/home/ahuq/.bashrc).

Let me know if you need more help, and don't forget to click the little "yes" button if this helped you.
 
Old 04-30-2011, 04:56 PM   #4
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Rep: Reputation: 38
Quote:
Originally Posted by spankbot View Post
You need to add that PATH statement to your .bashrc file (/home/ahuq/.bashrc).
You could always put the PATH assignment in ~/.profile since that's the last of the files read/used by bash (.bashrc will run every time a new shell is started; even after logging in).
 
Old 04-30-2011, 06:40 PM   #5
anis_huq
LQ Newbie
 
Registered: Nov 2006
Posts: 29

Original Poster
Rep: Reputation: 0
@spankbot......... I put in the line "PATH=$PATH:/home/ahuq/MappingServer/md5_program" at the end of the "/home/ahuq/.bashrc" file. Then logged out of the SHELL and went in again. It did not work:
root@ahuq-kitchen:/home/ahuq# md5 -sanis
No command 'md5' found, did you mean:
Command 'cd5' from package 'cd5' (universe)
Command 'mdu' from package 'mtools' (main)
Command 'mdb' from package 'mono-debugger' (universe)
md5: command not found

But when I did "export PATH=$PATH:/home/ahuq/MappingServer/md5_program" on the SHELL, the program "md5" became available temporarily.

root@ahuq-kitchen:/home/ahuq# md5 -sanis
MD5 ("anis") = 38a1ffb5ccad9612d3d28d99488ca94b

@thund3rstruck.... the same thing happened when I put "PATH=$PATH:/home/ahuq/MappingServer/md5_program" at the end of the .profile file. I couldn't run "md5".

Maybe I am putting the PATH statement in the wrong place of the above mentioned files. There are a lot if-else-fi structures inside those two files. Do I need to put the PATH statement inside any of those structures?
 
Old 04-30-2011, 06:58 PM   #6
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Rep: Reputation: 38
Quote:
Originally Posted by anis_huq View Post
@thund3rstruck.... the same thing happened when I put "PATH=$PATH:/home/ahuq/MappingServer/md5_program" at the end of the .profile file. I couldn't run "md5".
@Anis,

The "$PATH" variable defines the directories the shell should search to find executable files. For example see the ~/.bash_profile script below:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$HOME/Test
export PATH
I have placed a script called 'Resize Images.sh' into a folder $HOME/Test. By adding $HOME/Test to .bash_profile as demonstrated above I can open any terminal and type:

Code:
$ Re[tab]
And bash will find my script and I can run it. So change your line to:

Code:
PATH=$PATH:$HOME/MappingServer/md5_program
export PATH
FYI, I'm on a Fedora machine so if your Ubuntu doesn't have .bash_profile then look for .profile or of course you can use .bashrc as mentioned above


Regards,

Last edited by thund3rstruck; 05-01-2011 at 12:05 PM. Reason: Fixing Typo
 
Old 05-01-2011, 02:13 AM   #7
spankbot
Member
 
Registered: Aug 2007
Posts: 131

Rep: Reputation: 16
@anis. Sorry, I assumed you knew you needed to include the export command in your .bashrc or .bash_profile file. You can do it all in one step too...

export PATH=$PATH:/home/ahuq/...
 
  


Reply

Tags
environment variable, shell, ubuntu+10.10


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Permanently Set Environment Variable LANG Mistro116@yahoo.com Red Hat 1 06-12-2008 08:11 PM
changing my mac address permanently at ubuntu jamil_2342 Linux - Newbie 2 03-16-2008 01:03 PM
How to set up an system wide environment variable permanently?? piyush.kansal Fedora 5 12-07-2007 04:04 AM
changing path environment variable iNET_boss Linux - Newbie 2 07-27-2005 04:35 PM
Changing encoding- Setting an environment variable.. rixride00 Programming 1 04-20-2004 03:25 AM


All times are GMT -5. The time now is 07:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration