Here are simple tips on controlling which executables would be executed by your linux box when issued from command line terminal.
There are several ways to specify and control which binary executable file or linux shell command would be executed by your system when issued from the terminal.
SCENARIO APPLICATION
~~~~~~~~~~~~~~~~~~~~
This blog entry assumes the possible scenarios relating to this linux blog entry:
a. you just resume to your new job with these linux boxes and you found out that some binaries were installed manually from tar ballz (tar.gz) and some were from rpm (rpm) binary package installer
b. the linux box uses both opensource binary package version and the package distributed by commercial company, like for Java binaries.
c. a previous sysad created an executable with an exact filename similar to linux built-in commands.
d. simply you want to know specify which binary executables you want to execute
Let us assume that we currently have two binary executable files named nagios, which are currently located from two different location ofcourse.
# which dir
/usr/bin/nagios
/usr/local/bin/nagios
Here are some alternative approach on how to specify which binary file location to go into when executing a linux binary or executable file.
First scenario approach
~~~~~~~~~~~~~~~~~~~~~~~~
Be in charge of your linux bash environment. This includes setting all the needed environment variables into your desired needs. Reordering of default PATH shell environment from current user account is also advisable .
# echo PATH
Considering the two binary nagios path locations
/usr/bin/nagios
/usr/local/bin/nagios
And assuming you want your system to look first for /usr/local/bin/, simply specify and change your system PATH environment variable and make sure /usr/local/bin comes first before /usr/bin before executing the duplicated binary executable like so
# export PATH=/usr/local/bin:/usr/bin
# nagios
Second scenario approach:
~~~~~~~~~~~~~~~~~~~~~~~~~
Make use of linux command name aliasing. Linux bash aliases can be instructed to remember a particular path location when executing a specific linux command. This also applicable to specify further binary arguments when calling a default binary executables.
# alias nagios='/usr/local/bin/nagios'
# nagios
To specify additional argument for a binary
# alias nagios='/usr/local/bin/nagios --whatever'
# nagios
To print all linux aliases and verify the above specifed binary path location alias
# alias
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias nagios='/usr/local/bin/nagios'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Third scenario approach
~~~~~~~~~~~~~~~~~~~~~~~~~
Alternatives man definition:
alternatives creates, removes, maintains and displays information about the symbolic links comprising the alternatives system. The alternatives system is a reimplementation of the Debian alternatives system. Alternatives was rewritten primarily to remove the dependence on perl; it is intended to be a drop in replacement for Debian’s update-dependencies script.
It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference.
The alternatives system aims to solve this multiple executables issues by using symbolic links to specify default command location using linux command alternatives.
Now, to install and add both nagios alternatives to alternatives config choices, simply
# alternatives --config nagios
# alternatives --install /usr/local/bin/nagios nagios /usr/local/bin/nagios 1
# alternatives --install /usr/bin/nagios nagios /usr/local/bin/nagios 2
To view current nagios alternatives config
# alternatives --display nagios
To view and select which binary nagios binary for linux to execute when issued from CLI
# alternatives --config nagios
Alternatives prioritizes binary command execution using alternatives command as shown above.
Final Note:
~~~~~~~~~~~
As you can see, there are lot of alternative ways to approach an issue using linux tool sets. Linux is quite powerful specially on these scenario on customizing basic tool command sets up to custom made kernels, that is why OpenSource tools are quite powerful and would continue to be so.
HTH
Appreciate your visit here, thanks for the tip!
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
September
(58)
- Dear Linux SysAd Blog Readers
- Proactive monitoring from linux terminal
- deleting new lines and return line from text file
- Google chat setup using PSI howto
- PSI messenger - a truly promising open messaging a...
- Google chat setup using GAIM Pidgin howto
- Linux command line shell variables defined
- ls - displaying directory contents in many ways
- Control of alternative linux executables
- Searching using whereis linux command
- Witchy which linux command
- NeroLinux - diehard Nero burning software
- Google Sky - Explore and Rediscover the Sky
- Celestia - 3D Earth and Sky visualization
- Earth3D - real-time 3D Earth visualization
- GcStar - managing personal collection items
- DStat - resource statistics linux tool
- Bandwidth Monitor-NG - terminal-based interface ba...
- KNemo - KDE network interface monitoring tool
- EtherApe - graphical network activity monitoring tool
- Beauty of Math using Linux
- print leading/trailing lines before/after a matchi...
- Nagios Monitoring - install and generic setup howto
- ChRT- change real-time attribute process scheduling
- squeezed out multiple commented lines
- UNIX to DOS text file format converter
- totally squeezed out multiple blank lines
- squeezed multiple blank lines into single line
- fmt - simple optimal text formatter
- Linux backup powered by RDiff-Backup
- Linux Ping command explained
- read and display text file from terminal
- URLView - URL and email extractor
- TFTP server - setup and install howto
- NMap - Linux port scanning
- removing garbage characters from screen terminal
- invert string match using grep
- RDesktop - remote desktop howto
- Graveman on Linux - burn baby burn burn
- HTOP - interactive process viewer alternative
- Caching DNS server install howto
- BitTorrent - downloading large files made easy
- PHPAlbum - web photo album install howto
- MRTG graph creation with Cisco routers
- Tree view of directories and file listings from co...
- MAC address packet filtering using IPTables
- GTK-based GNOME Linux Tools
- Linux backups powered by RSnapShot
- MRTG tutorial, install and howtos
- FindSMB - view shared folders from network
- Squid - upgrade and install howto
- prompt and press a key between script lines
- Devede - DVD/VCD video authoring and creation tool
- display file and file system status
- determine file type
- GNOME GUI task scheduler install howto
- Linux backups powered by Rsync
- KPackage - GUI package administration and manageme...
-
▼
September
(58)
Thursday, September 20, 2007
Control of alternative linux executables
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment