LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2004, 02:03 AM   #1
mjkramer
Member
 
Registered: Sep 2003
Location: Orem, Ut
Distribution: Mandrake-9
Posts: 48

Rep: Reputation: 15
setting a path


how do i change the path to include a command for a program i want to run? i want the path to include this command every time i log into linux.
 
Old 11-18-2004, 02:05 AM   #2
PenguinPwrdBox
Member
 
Registered: Oct 2003
Posts: 568

Rep: Reputation: 31
Add the directory into your path, or symlink the program into an existing folder in your path.
You can add the directory to your path by editing /etc/profile.
Once you have saved, at the command line:
Code:
user@machine$ source profile
 
Old 11-18-2004, 02:07 AM   #3
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
There is quite a few ways to do this. When you type a command, bash searches your PATH variable.

# echo $PATH

You can either put your program in one of those folders, or change your PATH to include it's current directory. Your best bet is to just cp your executable to /bin
 
Old 11-18-2004, 02:12 AM   #4
mjkramer
Member
 
Registered: Sep 2003
Location: Orem, Ut
Distribution: Mandrake-9
Posts: 48

Original Poster
Rep: Reputation: 15
ok, i have no idea what im looking at, other than general programming knowledge. here is my profile file:

Code:
# /etc/profile -*- Mode: shell-script -*-  # (c) MandrakeSoft, Chmouel Boudjnah

 <chmouel@mandrakesoft.com>  loginsh=1  # Users generally won't see annoyng 

core files [ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1  if ! echo ${PATH} 

|grep -q /usr/X11R6/bin ; then     PATH="$PATH:/usr/X11R6/bin" fi  if [ "$UID" -ge 500 ] 

&& ! echo ${PATH} |grep -q /usr/games ; then     export PATH=$PATH:/usr/games fi  

umask 022  USER=`id -un` LOGNAME=$USER MAIL="/var/spool/mail/$USER" 

HISTCONTROL=ignoredups HOSTNAME=`/bin/hostname` HISTSIZE=1000  if [ -z 

"$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then     INPUTRC=/etc/inputrc fi  # some old 

programs still use it (eg: "man"), and it is also # required for level1 compliance for 

LI18NUX2000 NLSPATH=/usr/share/locale/%l/%N  export PATH PS1 USER 

LOGNAME MAIL HOSTNAME INPUTRC NLSPATH export HISTCONTROL HISTSIZE   

for i in /etc/profile.d/*.sh ; do  if [ -x $i ]; then   . $i  fi done  unset i
exactly where, how, and what should be placed into this script?

Last edited by mjkramer; 11-18-2004 at 02:14 AM.
 
Old 11-18-2004, 02:15 AM   #5
mjkramer
Member
 
Registered: Sep 2003
Location: Orem, Ut
Distribution: Mandrake-9
Posts: 48

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by scottman
There is quite a few ways to do this. When you type a command, bash searches your PATH variable.

# echo $PATH

You can either put your program in one of those folders, or change your PATH to include it's current directory. Your best bet is to just cp your executable to /bin
ahh, cause bin is already included in path? geeze, that is quite a task. see, this is my first day using linux. i took a linux class in college about 5 years ago, but it was all book and no hands on. im assuming i can't just copy the file to run the program into bin but would have to actually move all the related files into bin as well. geeze. you say in order to copy i use the command 'cp'?

yea, see, it said, "cannot find runtime directory.." something or other. i put the executable file into bin but it cant locate the other components it needs i assume.

Last edited by mjkramer; 11-18-2004 at 02:27 AM.
 
Old 11-18-2004, 02:52 AM   #6
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
You should simply create a symbolic link to the executable in /usr/bin (/bin is for programs like ls, mv, etc):
Code:
ln -s /path/to/executable /usr/bin
This way, you are not adding extra files to a directory which is set aside for binary's. You will need to be root to do this, since you are making system wide changes.

To add a directory to your path, add the following lines to the bottom of ~/.bash_profile (For just your user)
Code:
PATH=/path/to/new/directory:$PATH
export PATH
Then run the command "source .bash_profile" and the new directory will be added to your path, and will be available each time you log in.

If you have only one executable in a directory (eg Firefox or something similar), use the symbolic link, while if you have a directory with lots of executables (eg Java Bin directory) then add it to your path.

I hope this helps
--Ian
 
Old 11-18-2004, 05:26 AM   #7
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
IBall's link solution is actually better than my cp solution. This is because if the executable looks for dependant files relative to it's location it would fail (in my solution). The link would cause the executable to be executed from it's original location, preserving any directory path's. Sorry if my solution caused any problems.
 
Old 11-18-2004, 03:54 PM   #8
mjkramer
Member
 
Registered: Sep 2003
Location: Orem, Ut
Distribution: Mandrake-9
Posts: 48

Original Poster
Rep: Reputation: 15
got it all figured out. thanks

Last edited by mjkramer; 11-18-2004 at 07:34 PM.
 
Old 11-18-2004, 07:35 PM   #9
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
~/ means to look in the current users home directory.

The dot in froto of .bash_profile means that it is a hidden file - means that it is not displayed unless you want it to be. do a "ls -a" to see all the hidden files in a directory. Bash has 3 config files, .bash_profile, .profile and .bashrc. You can use any one of them.

To add multiple directories to your path:
Code:
PATH=$PATH:/directory/one:/directory/two
export PATH
ie: each directory is separated by a colon.

I hope this helps
--Ian
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the path.... joel112 Slackware 5 08-28-2003 01:27 PM
Setting the path Milkman00 Linux - General 2 07-26-2002 08:44 AM
setting PATH tda Linux - Newbie 1 04-29-2002 12:54 PM
Setting up PATH Sonny Linux - Newbie 4 01-28-2002 01:02 PM
PATH SETTING webboss Linux - Newbie 2 03-17-2001 05:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration