Find the answer to your Linux question:
Results 1 to 6 of 6
I did a search on editing PATH and found a note about editing it after the export command, but not sure how to do that. Right now, I believe my ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2002
    Posts
    14

    Editing PATH via export


    I did a search on editing PATH and found a note about editing it after the export command, but not sure how to do that.

    Right now, I believe my path is this (if I copied the right line here)

    declare -x PATH="/usr/kerberos/bin: .... "

    I would like to add /usr/local/bin or the /lib directory, also the /sbin directory so I don't have to type /sbin/ before every command.

    Also, another question. I'm trying to install Nessus on my box so it has those instructions, as well as editing the ld.so.conf file. What is that file (how is it different from the PATH environment?) I just wanted to know so I can learn.

    I think I edit the PATH after running the export command, but not sure how I save the changes.

    Thanks guys!!

    Tellurye

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    To modify your PATH variable at runtime, you can run something like this:
    Code:
    PATH=$PATH:/extra/path
    The reason this works is because of the shell's command line expansions. Before the shell actually executes any command, it does a number of expansions, including variable expansion. In this case, it sees the dollar sign, takes the word immediately after it (PATH), and replaces it with the contents of the variable whose name is that word. So essentially, it replaces $PATH with the current contents of the PATH variable.
    Thus, if your PATH currently contains /bin:/usr/bin, for example, this command line will, after expansion, read PATH=/bin:/usr/bin:/extra/path. Then the command is executed and "/bin:/usr/bin:/extra/path" is put into the PATH variable. Thus, /extra/path is now part of the PATH variable.
    Of course, this isn't saved - the variables are only kept in memory and are therefore lost when the shell exits. To make the change persistent, you need to put that command into your ~/.bashrc file. The ~/.bashrc file is always executed by the shell when it starts, so if you have such a command there, it will always put /extra/path into the PATH variable for every new shell that starts.

    The ld.so.conf file serves a completely different purpose. It defines where the dynamic link loader should look for shared objects when ELF programs are started. If a program that you start defines that it wants to link against libc, for example, the dynamic linker looks in all directories specified by /etc/ld.so.conf for a libc. To see what libraries a program wants to link against, run the ldd command on that program. For example, if you run "ldd /bin/ls", you'll see that ls wants to link again libtermcap, libc and ld-linux (ld-linux is the dynamic linker itself). Of course, this differ from system to system. On my workstation, for example, ls wants a lot of libraries (librt, libacl, libc, libpthread, ld-linux and libattr).

    I don't think that you want to add the /lib directory to your PATH, though. The lib directories (/lib, /usr/lib and /usr/local/lib) only contain various subroutine libraries - you probably don't want to try running those.

  3. #3
    Just Joined!
    Join Date
    May 2002
    Posts
    14
    Thanks, Dolda!

    Appreciate the explanation. Hey, how do I edit the ~/.bashrc file. When I did a "which" on it, it listed the /usr/bin location, opened that up in root, enabled show system files, and still didn't see it.

    I tried using the edit command. LOL, u can tell that I'm in my DOS days.

    AM I right that I can edit it in a text file or something like that?

    And I hear you about not adding the lib, I was just guessing, I think it tells you to add bin to it or something, I don't have it right in front of me.

    Thanks again for the help

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer
    Join Date
    Dec 2002
    Location
    New Zealand
    Posts
    766
    to edit your personal bashrc file. open a text editor and (u will have to type this coz its ahiden file) /home/username/.bashrc

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Oh, sorry, for letting that part out of the explanation. The tilde (~) is shorthand for your home directory. Many programs, especially the shell, will recognize it. Thus, run, for example, "emacs ~/.bashrc" from the shell to edit it with emacs. If you don't like emacs (you should learn to anyway, it is the best program ever written), try another editor, like pico, nano, gedit, vi, kwrite, etc...

    If you didn't already know, files beginning with a dot (so called dot-files), like .bashrc, are hidden by most programs. With ls, for example, you have to run it with the -a switch (ls -a) to make it the dot-files as well.

    Edit: Fixed a broken BBCode tag

  7. #6
    Just Joined!
    Join Date
    May 2002
    Posts
    14
    Thanks so much guys!!

    That was what I needed!!

    Tellurye

Posting Permissions

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