Operating System - HP-UX
1828340 Members
3023 Online
109976 Solutions
New Discussion

Re: How to run a command from anywhere in user mode?

 
SOLVED
Go to solution
Joshua Goi
Frequent Advisor

How to run a command from anywhere in user mode?

Hi all,

I have a bunch of commands from a software I just installed. I would like to run them from whichever directory I am in currently without cd-ing to that their directory to run them. And I would like to do it in user mode. Is it possible? How can it be done? Thanks!
7 REPLIES 7
Pete Randall
Outstanding Contributor

Re: How to run a command from anywhere in user mode?

I'm not sure what you mean by user mode, but the way to run the commands is either to put the paths to the commands into your $PATH or specify the full path to your command. Alternatively, if these are all in the same directory, you can just use the "./command" syntax.


Pete

Pete
Simon Hargrave
Honored Contributor
Solution

Re: How to run a command from anywhere in user mode?

Add them to your path variable. If it's for certain users, edit their $HOME/.profile. If it's for everyone, edit /etc/profile

In either case, add something like this to the end: -

# Add MyApplication to search path
PATH=$PATH:/opt/myapplication/bin
Franky_1
Respected Contributor

Re: How to run a command from anywhere in user mode?

Hi,

just add the specified path to your PATH Variable.
You can do this in /etc/profile (for all users) or in ~/.profile for selected user

Regards

Franky
Don't worry be happy
Rick Garland
Honored Contributor

Re: How to run a command from anywhere in user mode?

This is a job for the PATH environment variable. Can put into your $HOME/.profile to have in your environment, can put into /etc/profile for everybody, or you can put into /etc/PATH for system wide variable.
Rodney Hills
Honored Contributor

Re: How to run a command from anywhere in user mode?

If you are reluctant to modify the PATH variable, you could set a variable to the path and include the variable when executing.

/etc/profile
export myapp=/opt/myapp/bin

$ $myapp/foo

HTH

-- Rod Hills
There be dragons...
Victor Fridyev
Honored Contributor

Re: How to run a command from anywhere in user mode?

Hi,

You may run commands without full path if the path is included int the PATH variable. If the software is a "self made", install it in a directory which is included into PATH (/usr/local/bin, for example). Some standard and GNU installations put appropriate PATH into the file called /etc/PATH, which is read by the standard login procedure.

HTH
Entities are not to be multiplied beyond necessity - RTFM
Joshua Goi
Frequent Advisor

Re: How to run a command from anywhere in user mode?

Thanks guys!