Find the answer to your Linux question:
Results 1 to 3 of 3
I'm trying to write general code for finding/modifying a bash script, but the only thing is that it could be in many different places, and I don't want to modify ...
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Posts
    32

    How to find absolute path of a command

    I'm trying to write general code for finding/modifying a bash script, but the only thing is that it could be in many different places, and I don't want to modify the wrong one.

    Say, for example, that I call the command "java", and an exe is sitting in /sbin/ and one is sitting in /usr/sbin/

    Is there a command which identifies which the machine is pointing to without looking at a .profile?

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Code:
    which <command>
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    The commands are executed in the order of the $PATH variable
    Code:
    tom@btrprime:~> echo $PATH
    /home/tom/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
    tom@btrprime:~>
    So if I created a script in /home/tom/bin called 'firefox' which launched firefox with some custom switches, it would override the one in /usr/bin .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...