[K12OSN] Re: Run script from any directory (Krsnendu dasa)

Krsnendu dasa krsnendu at orcon.net.nz
Mon Feb 28 19:31:23 UTC 2005


Thank you very much. Will be very useful in future.

Cheers,
Krsnendu dasa

-----Original Message-----
From: k12osn-bounces at redhat.com [mailto:k12osn-bounces at redhat.com] On Behalf
Of Matt Oquist
Sent: Tuesday, 1 March 2005 8:24 a.m.
To: k12osn at redhat.com
Subject: [K12OSN] Re: Run script from any directory (Krsnendu dasa)

> From: "Krsnendu dasa" <krsnendu at orcon.net.nz>
> Subject: [K12OSN] Run script from any directory
> Very basic linux script question
> 
> I am trying to install smbldap
> 
> When I try to run ldap-useradd -m username 
> I get command not found message.
> 
> It only works when I change to the directory where these scripts live and
> type   #./ldap-useradd -m username
> 
> How can I change it so I can run it from any directory?

This is a basic question that applies the same way to any command line
shell - Unix, Linux, DOS.

Your "path" environment variable determines which directories are
searched for commands you type on the command line.

smbldap-tools version 0.8.6.* puts all its executables in
/opt/IDEALX/sbin/, so you need to add that to your user's PATH setting
if you don't want to do either of these every time you run one of
those scripts:

$ cd /opt/IDEALX/sbin/
$ ./smbldap-useradd blahblahblah
OR
$ /opt/IDEALX/sbin/smbldap-useradd blahblahblah

To view your current PATH setting:
$ echo $PATH

To TEMPORARILY change your path setting to include the smbldap-tools
directory:
$ export PATH="$PATH:/opt/IDEALX/sbin"

To "permanently" change your path setting to include the smbldap-tools
directory, you'll need to edit your shell configuration files.  First
check your .bash_profile, and then take a look at .bashrc.  (It's
a very good idea to know what's in these in any case.  'man bash' for
more details.)

Then add this line to your config:
export PATH="$PATH:/opt/IDEALX/sbin"

That should do it.

'man bash' documents the PATH setting.

--matt




More information about the K12OSN mailing list