Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    changing PATH variable


    Hi there,
    I just migrated from Fedora to Debian. In Fedora i could change the PATH env variable by editing the .bash_profile file. How do you do the same thing in Debian.

    Thanks in advance.

  2. #2
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274
    There might be a better way of doing this, but this is how I do it.

    Edit /etc/profile, and add these lines at the bottom - obviously change the variable names and the paths to suit your machine.

    Code:
    BENS_HOME=/home/ben
    QMAIL_STUFF=/var/qmail/scripts
    
    PATH=$PATH:$BENS_HOME:$QMAIL_STUFF
    
    EXPORT PATH BENS_HOME QMAIL_STUFF
    Then logout and log back in.
    Registered Linux user #389109
    My Semi-Linux Blog

  3. #3
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    In Debian, the equivalent of .bash_profile is .bashrc, so you should be able to edit that file the way you're used to.
    Stand up and be counted as a Linux user!

  4. $spacer_open
    $spacer_close
  5. #4
    I just want to include the current directory in the list of directories specified by PATH variable. So i added the following line in .bashrc file

    PATH=$PATH:.

    but it doesnt work. I mean if i execute any program in the current directory, and the current directory is not in the PATH variable. I get a command not found message.

  6. #5
    Just Joined! praka123's Avatar
    Join Date
    Jan 2006
    Location
    Kerala,India
    Posts
    35

    Post

    According to my copy of debian bible.for adding the paths /usr/local/sbin,/usr/sbin/,/sbin to env.
    open up your ~/.bashrc in your favourite editor,and near the top of the file(Just after the first block of comments),add the following line:
    Code:
    PATH="/usr/local/sbin: /sbin: /usr/sbin: $PATH
    save the file and then log out and log back in.run
    Code:
    echo "$PATH"
    to verify.

  7. #6
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    Quote Originally Posted by tnlg102
    I just want to include the current directory in the list of directories specified by PATH variable.
    May I ask why not just prepend the command or executable with a ./ or sh?
    Stand up and be counted as a Linux user!

  8. #7
    I agree with Zelmo. Also, it is recommended that the working directory should never be put first in your PATH. One could accidentally execute a command in the working directory that masks an common command. For example, if an executable named ls exists in the working directory then it would be executed instead of the ls command in the /bin directory. This could have disasterous effects, especially if you are superuser and the ls command was placed there malicously.

  9. #8
    Quote Originally Posted by CanyonMan
    I agree with Zelmo. Also, it is recommended that the working directory should never be put first in your PATH. One could accidentally execute a command in the working directory that masks an common command. For example, if an executable named ls exists in the working directory then it would be executed instead of the ls command in the /bin directory. This could have disasterous effects, especially if you are superuser and the ls command was placed there malicously.
    I run linux on my home pc, so security is not a big consideration. I think that it is a pain to prepend the name of the executable with ./ everytime i want to execute it.

  10. #9
    I finally got to include the current directory in the PATH variable. I just added the following line to the .bashrc file

    PATH = ".":$PATH

    thank you guys for your replies.

  11. #10

    bump for similar question

    New to Debian, and Linux in general...

    Editing ~/.bashrc certainly does the trick for $PATH in the shell. Unfortunately this doesn't do what I thought it did, which would be to change the search path in general; e.g., I write a shell script to java -jar foo.jar but the script won't work when clicked from e.g. the file manager or the desktop, even if I choose "Run in Terminal." (Surely, I thought, the latter would work.)

    From my initial research I thought editing /etc/profile would work but none of my changes show up in $PATH after logout. I've tried editing the line where PATH is defined and I've tried stokes's method. For the meantime I've just put a new PATH=$PATH:/<javapath> statement in the shell; it works, but it seems wrong to me.

    Thanks for any help.

Posting Permissions

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