Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Help with Linux paths.....?

In Linux.....How do you add a directory to your path to run a program's commands directly so that the full path doesn't have to be given.

2 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    I will assume that you haven't changed shells, so you're using the bash shell by default. (Bash is the Linux default, so if you haven't changed anything since the initial installation, you're okay).

    In your root directory, you'll find a (hidden) file called .bash_profile. If it's not there (it should be) just created it with an editor. Make sure you add the dot in front of the file name, as it needs to be hidden.

    Add the following lines to .bash_profile

    # User specific environment and startup programs

    PATH=$PATH:/your/new/directory

    export PATH

    "/your/new/directory" is the location of the file you want to run.

    If the file you want to run is in a directory inside your home directory, do this:

    PATH=$PATH:$HOME/your/new/directory

    export PATH

    Then logout and log back on, and the directory should be in your path.

  • Paul
    Lv 7
    1 decade ago

    It depends on what shell you are using. For bash you would use e.g.:

    export PATH=/opt/local/bin:$PATH

    This inserts /opt/local/bin at the start of PATH.

Still have questions? Get your answers by asking now.