[Techtalk] Executing user-made commands on the command line

Malcolm Tredinnick malcolm at commsecure.com.au
Sun May 11 22:10:21 EST 2003

On Sun, May 11, 2003 at 04:55:08AM -0700, Berenice wrote:
> May as well post some more questions while I'm here :)
> 1.  Where I can see the source code of commands such as ls or rm? 
> I'm interested in seeing how they do things like flow control and
> options.

Those two particular commands come from a GNU package called fileutils.
You can download it from any of the GNU FTP sites, for example.

On an RPM-based system, you can work out which package a binary belongs
to by running 

	rpm -qf <path-to-binary>
(so 'rpm -qf /bin/ls' for example). That will tell you which source rpm
to go hunting for (at somewhere like www.rpmfind.net). Not sure what the
analogous procedure is on Debian systems, but I am sure somebody here
can point the way.

> 2. If I create my own commands, how can I make them run like standard
> linux commands (ie: just by tying in the command name at the prompt)?

Yes. Have a look at the contents of your PATH environment variable (echo
$PATH). That shows the diretories that will be searched for any command
you type at the prompt. You may have ~/bin in there, or else you can add
that as part of your .bash_login script. Then, dropping any executable
shell script into ~/bin will enable it to be run from the command

Success always occurs in private and failure in full view.

More information about the Techtalk mailing list