How to: add directory to path


Recommended Posts

I've got no idea...  One difference I can think of is the search PATH used for commands might be different. (Causing the shell to traverse different directories when looking for the commands to run)

 

 

My cache_dirs lives in /boot/custom/bin.  I invoke it like this in my "go" script.  my drives spin down just fine.  I add /boot/custom/bin to the execution path in the "go" script.

(This is my whole "go" script.)

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

PATH=$PATH:/boot/custom/bin

cache_dirs -w -e Pictures -e data -d 3

fromdos < /boot/custom/bin/powerdown > /sbin/powerdown

chmod u+x /sbin/powerdown

fromdos < /boot/custom/etc/rc.d/S30-inittab-powerdown | sh

fromdos < /boot/custom/etc/rc.d/rc.local_startup | sh

echo "/boot/unmenu/uu" | at now + 1 minute

 

I'm tring to figure out how to add a directory to the path but am having no luck.  I found this example from Joe L. which is the exact directory I want added to my path but when I copy this line into my go script it does not seem to work.  After rebooting /boot/custom/bin is not in my path.  What do I needto do in order to get this working?

Link to comment

I've got no idea...   One difference I can think of is the search PATH used for commands might be different. (Causing the shell to traverse different directories when looking for the commands to run)

 

 

My cache_dirs lives in /boot/custom/bin.  I invoke it like this in my "go" script.   my drives spin down just fine.   I add /boot/custom/bin to the execution path in the "go" script.

(This is my whole "go" script.)

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

PATH=$PATH:/boot/custom/bin

cache_dirs -w -e Pictures -e data -d 3

fromdos < /boot/custom/bin/powerdown > /sbin/powerdown

chmod u+x /sbin/powerdown

fromdos < /boot/custom/etc/rc.d/S30-inittab-powerdown | sh

fromdos < /boot/custom/etc/rc.d/rc.local_startup | sh

echo "/boot/unmenu/uu" | at now + 1 minute

 

I'm tring to figure out how to add a directory to the path but am having no luck.  I found this example from Joe L. which is the exact directory I want added to my path but when I copy this line into my go script it does not seem to work.  After rebooting /boot/custom/bin is not in my path.  What do I needto do in order to get this working?

The reason it does not work for you is that you do not run the "go" script when you log in.

 

A login shell gets its path from two places in linux.  a system wide file

/etc/profile

and a user-specific file located in the user's home directory

.profile

 

The system wide file is evaluated first, then the user-specific one.

 

The user-specific one does not currently exist in unRAID. If it did, it would exist as /root/.profile  ( .profile in the home directory of the user logging in)

 

To create the ".profile" file, we can add a line in the "go" script.  Then, when we next log in, ".profile" will be evaluated and your PATH set.

 

The line you need to add to the "go" file is:

echo "PATH=$PATH:/boot/custom/bin" >/root/.profile

 

Joe L.

Link to comment

Thank you, I would have NEVER figured that out on my own.

 

If I also wanted to use the next line, cache_dirs, shown in the go script would I need something like this then?

 

/usr/local/sbin/emhttp &

PATH=$PATH:/boot/custom/bin

echo $PATH >/root/.profile

cache_dirs -w -i Videos

 

Link to comment

Thank you, I would have NEVER figured that out on my own.

 

If I also wanted to use the next line, cache_dirs, shown in the go script would I need something like this then?

 

/usr/local/sbin/emhttp &

PATH=$PATH:/boot/custom/bin

echo $PATH >/root/.profile

cache_dirs -w -i Videos

 

No... close, but not quite

The second line needs to be

echo "PATH=$PATH" >/root/.profile

 

Otherwise, what ends up in .profile is a line looking like this

/usr/local/sbin:/usr/sbin:/sbin:./:/usr/local/bin:/usr/bin:/bin

instead of this

PATH=/usr/local/sbin:/usr/sbin:/sbin:./:/usr/local/bin:/usr/bin:/bin

 

Link to comment

Thank you, I would have NEVER figured that out on my own.

 

If I also wanted to use the next line, cache_dirs, shown in the go script would I need something like this then?

 

/usr/local/sbin/emhttp &

PATH=$PATH:/boot/custom/bin

echo $PATH >/root/.profile

cache_dirs -w -i Videos

 

No... close, but not quite

The second line needs to be

echo "PATH=$PATH" >/root/.profile

 

Otherwise, what ends up in .profile is a line looking like this

/usr/local/sbin:/usr/sbin:/sbin:./:/usr/local/bin:/usr/bin:/bin

instead of this

PATH=/usr/local/sbin:/usr/sbin:/sbin:./:/usr/local/bin:/usr/bin:/bin

 

 

lightbulbtransparent2.gif AH!

 

Once again - THANK YOU

Link to comment
  • 6 years later...

Hey sorry to dig this up from the graveyard, but I'm having trouble getting this to work. I have this in my go script:

PATH=$PATH:/usr/lib64/jre1.8.0_45/bin

echo "PATH=$PATH" > /root/.profile

 

And when I login, my .profile shows the correct path, but if I actually check $PATH, it doesn't contain the directory I added.

 

Am I missing some simple step?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.