Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: How can I set Path in bash shell

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default How can I set Path in bash shell

    hi,

    I've installed JDK in Linux. As I'm a beginner to Linux, I need to how can I set path in bash shell so that all users can run java.

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,515
    Thanks
    17
    Thanked 815 Times in 511 Posts
    Rep Power
    10

    Default

    Use export command as follows at command prompt:
    Code:
    export PATH=$PATH:/usr/lib/j2sdk1.4-sun/bin
    You need to add command to /etc/profile or /home/you/.bash_profile so that PATH get set automatically after each reboot.

    You can also add variable JAVA_HOME
    Code:
    export JAVA_HOME=/usr/lib/j2sdk1.4-sun
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. #3
    Junior Member
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default PATH Changer

    I made this little script file that will change your path. it will add or remove a directory from your path. it is pathchanger. Here is a link
    icecoolcorey.net

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Hi. I'm a very very new linux user.

    I am having the same problem of not being able to permanently adding a path to my bash profile.

    I have already added the path to my .bashrc file, but don't seem to be able to restore the path after logging off from terminal.

    This is how my .bashrc file looks like:

    source ~/.bash_profile

    export PATH=$PATH:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

    export PATH=/Documents/Camino/camino/bin:$PATH

    export MANPATH=//Documents/Camino/camino/man:$MANPATH

    Where the program i want to run is stored in folder called Camino.

    Please help! =)

    Thanks

  5. #5
    Junior Member Landis's Avatar
    Join Date
    Mar 2012
    Location
    Детроит, США
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default $PATH now has 2 entries for added directory path.

    Hello,
    first, this is my first post at nixCraft, but long time 'viewer'. Thanks.

    OK, I edited my .bashrc file adding
    Code:
    PATH=/home/landis/programs/Java/:$PATH
    export PATH
    to the end of the file. Everything else seems to be rem'd in the file.

    Now, when I logout of KDE, logout of shell, login at prompt and type echo $PATH my 'new' path addition is echoed twice at the beginning of $PATH.. .
    Why?
    I did not add it anywhere else, nor was even One instance in path before I added it, that's why I added it.. : )

    Спасибо,
    Landis.
    p.s., I also tried it without the line 'export'... same thing...

  6. #6
    Senior Member Rahul.Patil's Avatar
    Join Date
    Feb 2012
    Location
    Mumbai india
    Posts
    486
    Thanks
    10
    Thanked 50 Times in 47 Posts
    Rep Power
    8

    Default

    Hi,
    can you once check PATH of Java in /etc/bashrc and .bashrc
    you can use following command to check the same

    PHP Code:
    awk '/PATH/&&/Java/' /etc/bashrc .bashrc 

  7. #7
    Member
    Join Date
    Feb 2012
    Posts
    33
    Thanks
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default

    What OS are you using? Will all the users be using BASH? There are small differences between different distros.

  8. #8
    Junior Member Landis's Avatar
    Join Date
    Mar 2012
    Location
    Детроит, США
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by Rahul.Patil View Post
    Hi,
    can you once check ....
    PHP Code:
    awk '/PATH/&&/Java/' /etc/bashrc .bashrc 
    ok, first try output:
    Code:
    landis@linux-amd:~> awk '/PATH/&&/Java/' /etc/bashrc .bashrc
    awk: cmd. line:1: fatal: cannot open file `/etc/bashrc' for reading (No such file or directory)
    landis@linux-amd:~>
    hmm, same error as root (su).. Question.. do i need the ' (apostrophe) before and after /PATH/&&/Java/?
    I used them. should I Not?

    thanks,
    Landis.

  9. #9
    Junior Member Landis's Avatar
    Join Date
    Mar 2012
    Location
    Детроит, США
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by bitlord View Post
    What OS are you using? Will all the users be using BASH? There are small differences between different distros.
    I am using, on all systems a version of openSuSE from 11.2 to 12.1 and a bash shell.

    Landis.
    p.s., the system I'm on right now is openSuSE 11.2, but I think I was on a openSuSE 12.1 when I first asked the question.. but, again all my systems are openSuSE, bash. Thanks.
    Last edited by Landis; 29th March 2012 at 10:53 PM.

  10. #10
    Junior Member Landis's Avatar
    Join Date
    Mar 2012
    Location
    Детроит, США
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    additionally, in bash, is it required to declare Every directory? I mean, is 'path' Not recursive?
    if I have /etc/bin that does Not cover directories Below it (sub directories)?

    Спасибо,
    Landis

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Similar Threads

  1. -bash: /bin/ps: Cannot allocate memory
    By kasimani in forum Linux software
    Replies: 2
    Last Post: 4th May 2011, 04:05 AM
  2. split files by specifying a string (bash shell)
    By vikas027 in forum Shell scripting
    Replies: 7
    Last Post: 21st June 2010, 01:35 PM
  3. Bash not working!
    By Mwalimugini in forum Getting started tutorials
    Replies: 4
    Last Post: 24th March 2008, 10:52 PM
  4. SCP with a bash shell password linux and unix servers
    By jerry in forum Networking, Firewalls and Security
    Replies: 1
    Last Post: 9th June 2007, 06:53 PM
  5. linux setting system-wide path
    By in forum Linux software
    Replies: 1
    Last Post: 28th January 2006, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •