Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-19-2005, 01:34 AM
|
#1
|
Member
Registered: Aug 2004
Location: Sri Lanka
Distribution: Debian Etch
Posts: 36
Rep:
|
running programs in console?
Hy guys!
I've got a silly question,
Some programs(normally which I created using g++) must run as
'./myprogram'
but other programs like java run by just typing
'java'
can I make 'myprogram' also runnable without that ugly dot and slash??
Thanks
|
|
|
02-19-2005, 01:42 AM
|
#2
|
Member
Registered: Jun 2003
Location: Glendale AZ
Distribution: Slackware 10
Posts: 153
Rep:
|
well
Well, the issue here is "/usr/local/bin" and "/usr/sbin"
These directories hold binary programs such as "ls" or the forementioned "java" and since they are in this directory they are accessible by simply typing them without that nasty "./"
"./" simply means ... run from this directory. i.e. ./randomprogram = please run the binary file randomprogram from this directory.
So, if you want to NOT have to type "./program" you will have to copy the binary file into the /usr/local/bin/ directory.
Have fun.
|
|
|
02-19-2005, 08:10 AM
|
#3
|
Member
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99
Rep:
|
ok, take a look at a variable that is set automatically for linux:
PATH
to show its content, type "echo $PATH"..
you'll see a list of directories separated by a ":"
every executable that is in one of those directories will be executed if you just type their names..
for example /sbin/lilo is an executable, and /sbin is in the PATH..
you just have to type lilo and it's executed
If you want to add your own directory to the PATH, do this:
PATH="$PATH:/mydirectory/"
but that applies only for your current session, if you want it to apply for all the others,
you have to edit the file /etc/profile..
search for the lines containing the PATH content and add your dir to this group of dirs..
DON'T forget that the directories must be separated by ":"
Last edited by JoannesX; 02-19-2005 at 08:12 AM.
|
|
|
02-19-2005, 08:18 AM
|
#4
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
uhhhh, no. I'm gonna warn you though this could be considered a security risk by some. Anyway, what you want to do is add the current directory in your PATH ( but it will always be the current directory, not a static directory like "/home/programs/bin" or something like that). Some distro's do this and some do not. here is what you need to add to /etc/profile:
# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
PATH="$PATH:."
fi
I would copy it verbatim for security reasons.
|
|
|
02-22-2005, 05:41 PM
|
#5
|
Member
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99
Rep:
|
What do you really mean with "not a static directory"?
'cause I have added /ext3/scripts/shell to my PATH just to have a separated dir for my scripts..
and it's totally static so far..
I just had to create a .bash_profile for each user and add this to the PATH there, in order to let them run my scripts too...
Sorry if I misunderstood..
|
|
|
02-22-2005, 08:34 PM
|
#6
|
Member
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472
Rep:
|
Suggestion:
If you use these programs often, you can add it into the
menu or create a desktop icon.
Menu:
-> K (window equivalent of start)
-> Appl...
-> System
-> Menu Editor
[could be be diffenrence based on distribution)
Icon:
wiggle to executable on a file manager
Left-click and hold and drag to desktop.
choose to link.
Sheng-Chieh
|
|
|
02-22-2005, 10:30 PM
|
#7
|
Member
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99
Rep:
|
yes that works if you're running X..
But the questions here is how to run programs in console...
|
|
|
All times are GMT -5. The time now is 11:09 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|