Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to add to the search path - bin? Post 302901789 by bakunin on Thursday 15th of May 2014 03:42:16 PM
Old 05-15-2014
You haven't said which OS you are on, but i suppose it is some kind of Linux.

Notice, that there are two files: /etc/profile and/or /etc/bash.bashrc. These are systemwide settings and changing these will alter your system, so stay away from them as long as you are not sure what you do and how you do it.

Then there is "/your/home/.profile" and "/your/home/.bashrc". These files are only executed by you and you can - more or less - do whatever you want with them. The worst you might do is make login or execution of the shell for yourself impossible - log on as root, remove the offending files or replace them with some backup copy and you are again ready to go. You might want to create a separate "test user" for that purpose and experiment with the startup files for this account. Once you are satisfied you copy the files from there to your own home and use them.

Now to your initial question: "$PATH" is a list of directories, separated by colons (":") which are searched for executable files if no complete path is entered. A common PATH variable might look similar to this:

Code:
# echo $PATH
/bin:/usr/bin:/usr/sbin:/usr/local/bin

If you now enter "command" at the command line these directories are searched in the order they appear in this variable for a file which is executable and named "command": first "/bin/command", then "/usr/bin/command", etc..

Once such a file is found, it is executed. By changing the order within "$PATH" you can influence which executable (if there are several named identically) is executed. If you put "/your/home/bin" in front of your PATH by executing

Code:
PATH=/your/home/bin:$PATH

an executable named i.e. "/your/home/bin/cp" would "override" (take precedence over) the system command "cp", usually located in "/usr/bin/cp".

This is sometimes a wanted effect, sometimes not. You decide what you want here. You just need to know that writing "$PATH" is like typing the complete current value of the PATH variable, therefore, taking the above mentioned value as example:

Code:
# echo $PATH
/bin:/usr/bin:/usr/sbin:/usr/local/bin
# PATH=$PATH:/some/new/dir
# echo $PATH
/bin:/usr/bin:/usr/sbin:/usr/local/bin:/some/new/dir
# PATH=/other/dir:$PATH
# echo $PATH
/other/dir:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/some/new/dir

etc..

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

home directory in search path

Is it unsafe to put your own home directory (a regular user) in your search path? I am writing useful shell scripts, but don't have the permissions to put them in /usr/bin. (Korn shell) thanks (2 Replies)
Discussion started by: jpprial
2 Replies

2. UNIX for Advanced & Expert Users

set path so all new users can execute the command in /bin/mycommands

I want to add a default path /bin/mycommands along with others to be loaded as default path for all new accounts created on my system . With out the new accounts not having to change thie manually to /bin/mycommands.Do I change the /etc/profile ? is there any better way? Please throw some... (2 Replies)
Discussion started by: sravusa
2 Replies

3. Shell Programming and Scripting

add bin to variable PATH and save changes

i wrote a script and is running. I add the path bin to variable PATH, i.e. PATH=$PATH/bin. i add this to PATH in order to run the script in any path working directory. Thats ok. The problem is as son as i close the session and start a new session, changes are lost. How can i tell the shell or... (1 Reply)
Discussion started by: alexcol
1 Replies

4. Windows & DOS: Issues & Discussions

Path of Recycle Bin on Windows

hello everybody, I am trying to find the path of the Recycle Bin. I know that it's a temporary storage place, but it should have a path that we can refer to. I want to know it because I sometimes use cygwin to work on Windows, and when you delete something with it, it's gone. I just checked... (4 Replies)
Discussion started by: milhan
4 Replies

5. UNIX for Dummies Questions & Answers

extract a part of a path like (input: /etc/exp/home/bin ====> output: exp)

Hi, I need to make some extraction . with the following input to get the right output. input: /etc/exp/home/bin ====> output: exp and input: aex1234 ===> output: ex Thanks for your help, (4 Replies)
Discussion started by: yeclota
4 Replies

6. Shell Programming and Scripting

PATH dircetory search order

Hello I using CygWin and am working on project that requires whereby after I make some code changes and rebuild I have to manually copy the updated files into the install directory to test them. There is a build output directory where these files placed, but the program will not run from there.... (4 Replies)
Discussion started by: bobban
4 Replies

7. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

8. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

9. Programming

Gcc linker search path order

I have a build where I wish to link against and load a specific version of a library and a different version of the same library is installed on the system. I'm using a -L option to point to the version that I wish to link against but gcc still seems to choose the installed version. Is there a way... (4 Replies)
Discussion started by: Richard Johnson
4 Replies

10. Shell Programming and Scripting

Php search path

Probably simple, but I don't see it. jack@veritron /u/email $ cat p3.php <?php require_once './lib/swift_required.php'; $x=get_include_path(); echo "$x \n"; set_include_path('./lib:./lib/classes:'.$x); $x=get_include_path(); echo "$x \n"; $transport =... (1 Reply)
Discussion started by: jgt
1 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. SunOS 5.10 30 Aug 2004 getusershell(3C)
All times are GMT -4. The time now is 06:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy