LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   How to add /sbin to the system path (https://www.linuxquestions.org/questions/red-hat-31/how-to-add-sbin-to-the-system-path-4175415019/)

AlexFr 07-05-2012 05:08 AM

How to add /sbin to the system path
 
I want to run any file from /sbin, /usr/sbin, /usr/local/sbin without specifying full path. Currently executables from these directories are not included. How can I do this?

pixellany 07-05-2012 05:18 AM

I would have thought that at least /sbin would be included by default..??? What does "echo $PATH" show?

regardless, to add a directory to PATH:
Code:

export PATH="$PATH:<item1>:<item2>..etc"
eg, to add /bin:
export PATH="$PATH:/sbin"


AlexFr 07-05-2012 05:25 AM

Code:

[alex@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/alex/bin

So, required shell commands should be:
Code:

export PATH="$PATH:/sbin:/usr/sbin:usr/local/sbin"
Is this correct?
How to make this change persistent? In Ubuntu, I can add script file to /etc/profile.d directory, and it is executed every time OS starts. Can I do this in RHEL?

AlexFr 07-05-2012 05:38 AM

OK, works exactly as I expected. Thanks.

knudfl 07-05-2012 06:41 AM

RHEL : When you do : su
.. then /sbin/ and /usr/sbin/ will not be in the PATH.

Solution : su - ( su <space> <hyphen> )


All times are GMT -5. The time now is 09:08 PM.