LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2010, 11:46 AM   #16
rajesh1978
LQ Newbie
 
Registered: Jun 2010
Posts: 26

Original Poster
Rep: Reputation: 0

In fact I know to set the path environmental variable . But I was diverted by the comments that I get as answer.

It in deed wanted to know as Linux is an open source if I want to add one command like ls,cd etc then where to put the executable or lib.

how the executable ls or cd is working the same way I want to put my own command.
 
Old 07-11-2010, 11:50 AM   #17
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
so what you should do is add the path /usr/Hoge/Test to the bash environment variable $PATH. use the following command to modify the $PATH variable

Code:
PATH=/usr/Hoge/Test:$PATH
Now you should be able to execute the binary by typing
Code:
executablefile
 
Old 07-11-2010, 12:04 PM   #18
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by rajesh1978 View Post
In fact I know to set the path environmental variable . But I was diverted by the comments that I get as answer.

It in deed wanted to know as Linux is an open source if I want to add one command like ls,cd etc then where to put the executable or lib.

how the executable ls or cd is working the same way I want to put my own command.
'ls' is works the way it works just because its directory can be found in $PATH.

The library part is different; it's a non-issue if you statically link; for DLLs read 'man ldconfig' and perform WEB search on LD_LIBRARY_PATH, LD_RUN_PATH environment variables. Also, you might think about a shell wrapper for your executable, this is, for example, how 'firefox' is typically called/implemented.
 
Old 07-11-2010, 12:12 PM   #19
pr_deltoid
Member
 
Registered: Jun 2010
Distribution: Fedora
Posts: 289

Rep: Reputation: 41
Going by what I've read you don't have to do anything but put your program in a directory that is in PATH. Just make sure the name of your program doesn't conflict with any others. Don't overwrite an important program with the same name.
Code:
echo $PATH
The directories are separated by colons.

Last edited by pr_deltoid; 07-11-2010 at 12:14 PM.
 
Old 07-11-2010, 12:19 PM   #20
rajesh1978
LQ Newbie
 
Registered: Jun 2010
Posts: 26

Original Poster
Rep: Reputation: 0
Thanks to all of you, for your guidance. I will work on your suggestions
 
Old 07-11-2010, 07:24 PM   #21
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Or just see Steve's post that mentions where typical programs for all users live. I would add that when using a test item that another common practice can be to place it in the /usr/local/bin until you wish to go main stream, then I typically go with /usr/bin (I try to leave /bin to system application installs)
 
Old 07-11-2010, 07:57 PM   #22
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
$HOME/bin is a good place for user-created commands. Just make sure it's in $PATH (in most distros it's already there).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing Karmic changes ben44b Linux - Hardware 0 01-18-2010 05:22 PM
Implementing cd command ko589 Programming 4 03-02-2009 10:17 PM
Implementing IPv6 ??? ajeetraina Linux - Server 0 07-09-2007 10:40 PM
implementing ping? pcdude Programming 4 11-03-2004 03:57 AM
"Doubt in Implementing top command " manikantha Programming 1 09-24-2004 07:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration