Solved

Adding / Removing Path Entries

Posted on 2004-08-11
17
2,003 Views
Last Modified: 2013-12-06
Hello.

I need to make the following path adjustments:

   add    /home/mytools/vips/bin    to my PATH
   add    /home/mytools/vips/lib    to my LD_LIBRARY_PATH
   add    /home/mytools/vips/man    to my MANPATH
   add    /home/mytools/vips/lib/pkgconfig    to my PKG_CONFIG_PATH.

Also, if and when I decide to delete the package, how do I remove the path entries?

I am running Red Hat 9.

Thanks!
0
Comment
Question by:hankknight
  • 8
  • 8
17 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 11772429
You can do this interactively with:

export PATH=/home/mytools/vips/bin:$PATH
export LD_LIBRARY_PATH=/home/mytools/vips/lib:$LD_LIBRARY_PATH
export MANPATH=/home/mytools/vips/man:$MANPATH
export PKG_CONFIG_PATH=/home/mytools/vips/lib/pkgconfig:$PKG_CONFIG_PATH

Those path additions are only for the current shell and its descendants and will disappear at the next login. To have that set for all shells and to persist across logins you'll need to add those commands to the end of ~/.bashrc.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11772475
or you can put thoses settings into a seperate file (e.g ~/.vips.rc) and source that file in your bash
with . ~/.vips.rc

If all users should get those settings you can put them into /etc/profile.d/vips.sh

so every gets thoses settings. If you delte the software just remove the file form /etc/profile.d/ and those settings will no longer be available
0
 
LVL 16

Author Comment

by:hankknight
ID: 11772792
Thank you.

All users should get these settings.  I am still a bit unclear on how to do this:

Should I create a file called vips.sh placed in the /etc/profile.d/ directory that contains only the following lines?

   export PATH=/home/mytools/vips/bin:$PATH
   export LD_LIBRARY_PATH=/home/mytools/vips/lib:$LD_LIBRARY_PATH
   export MANPATH=/home/mytools/vips/man:$MANPATH
   export PKG_CONFIG_PATH=/home/mytools/vips/lib/pkgconfig:$PKG_CONFIG_PATH
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 48

Expert Comment

by:hernst42
ID: 11773013
yes that should work. The directory /etc/profile.d/ should already exist and contain some *.sh -files
(I haven't tried it on a RedHat box (only SuSE))

Maybe you should also change the lines so the settings for that app are appended, to prepended

/etc/profile.d/vips.sh:
   export PATH=$PATH:/home/mytools/vips/bin
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mytools/vips/lib
   export MANPATH=$MANPATH:/home/mytools/vips/man
   export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/mytools/vips/lib/pkgconfig
 
0
 
LVL 16

Author Comment

by:hankknight
ID: 11774262
OK, I put

   export PATH=$PATH:/home/mytools/vips/bin
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mytools/vips/lib
   export MANPATH=$MANPATH:/home/mytools/vips/man
   export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/mytools/vips/lib/pkgconfig

in /etc/profile.d/vips.sh

It still doesn't work.  

Do I have to reboot the system by typing in "reboot" in my ssh terminal?
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11774423
no, you need to relogin and then the changes should be applied. Did the directory /etc/profile.d/ exist before and are there any other files in it. THe /etc/profile and /etc/profile.d are only read for an loginshell
0
 
LVL 16

Author Comment

by:hankknight
ID: 11774516
Yes, the directory /etc/profile.d/ exsists and has the following files:
 
   colorls.csh
   colorls.sh
   lang.csh
   lang.sh  
   less.csh  
   less.sh  
   vim.csh  
   vim.sh  
   which-2.csh  
   which-2.sh

And I need ALL users to be ablt to exicute the commands.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11774936
the changed environment should be available after a new login. Do a
echo $PATH
to see if the path includes the home/mytools/vips/bin or not
0
 
LVL 16

Author Comment

by:hankknight
ID: 11775966
I type in

    echo $path

and nothing is displayed.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11776043
try
echo $PATH

$PATH is case-senisitive and must be written in UPPERCASE, so $path should print nothing indeed.
0
 
LVL 16

Author Comment

by:hankknight
ID: 11776395
Thanks.

Only the following is showing up in my path:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11776613
what is the output of
  ls -l /etc/profile.d/vips.sh
and
  echo $SHELL
0
 
LVL 16

Author Comment

by:hankknight
ID: 11778516

>> what is the output of ls -l /etc/profile.d/vips.sh

-rw-r--r--    1 root     root          276 Aug 11 13:07 /etc/profile.d/vips.sh

>> and echo $SHELL

/bin/bash


Here is the whole thing:

Last login: Wed Aug 11 12:01:22 2004 from 243.325.63.4

[root@suncrest /root]#  ls -l /etc/profile.d/vips.sh
-rw-r--r--    1 root     root          276 Aug 11 13:07 /etc/profile.d/vips.sh
[root@suncrest /root]#
[root@suncrest /root]# ls -l /etc/profile.d/
total 12
-rwxr-xr-x    1 root     root          379 Jan 17  2003 colorls.csh
-rwxr-xr-x    1 root     root          474 Jan 17  2003 colorls.sh
-rwxr-xr-x    1 root     root          926 Sep 21  2001 lang.csh
-rwxr-xr-x    1 root     root         1388 Sep 21  2001 lang.sh
-rwxr-xr-x    1 root     root          237 Feb  5  2001 less.csh
-rwxr-xr-x    1 root     root          192 Feb  5  2001 less.sh
-rwxr-xr-x    1 root     root           13 Sep 17  2003 vim.csh
-rwxr-xr-x    1 root     root          181 Sep 17  2003 vim.sh
-rw-r--r--    1 root     root          276 Aug 11 13:07 vips.sh
-rwxr-xr-x    1 root     root          126 Sep 10  2000 which-2.csh
-rwxr-xr-x    1 root     root          125 Sep 10  2000 which-2.sh
[root@suncrest /root]# echo $SHELL
/bin/bash
[root@suncrest /root]# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
[root@suncrest /root]#

Thanks.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11778653
everything looks good for me. Try to make /etc/profile.d/vips.sh exectable
chmod +x /etc/profile.d/vips.sh

If that doesnt work maybe you can make a tar and put it anywhere to download, so I can have a closer look at the files.
tar -czf profile.tgz /etc/profile /etc/profile.d

0
 
LVL 16

Author Comment

by:hankknight
ID: 11779120
I changed the permissions.

Now there is good news and bad news.

The good news is that it is now showing up in the path:

[root@suncrest /root]# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbi:/root/bin:/usr/X11R6/bin:/home/mytools/vips/bin
[root@suncrest /root]#

The bad news is it still isn't working.

Now when I log in, I get two "Command not found" errors, but it doesn't tell me what the errors are:

Last login: Wed Aug 11 16:28:59 2004 from 243.325.63.4

: command not found
: command not found
[root@suncrest /root]#
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 11779192
ok it seems that redhat needs the execution bit :-)

now change the content of the vips.sh to the following:

export PATH=${PATH:+$PATH:}/home/mytools/vips/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/home/mytools/vips/lib
export MANPATH=${MANPATH:+$MANPATH:}/home/mytools/vips/man
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}:/home/mytools/vips/lib/pkgconfig

So if one of those variables is not set, the : as seperator is not added to that environment variables
0
 
LVL 16

Author Comment

by:hankknight
ID: 11779215
It works now, thanks!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to have a cron job run until a condition is met 12 66
Coding C# in Linux 8 69
linux(debian) mouse poor performance 4 41
Linux script delete files 3 34
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question