Linux command to show where bin files are located


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Linux command to show where bin files are located
# 1  
Old 08-21-2015
Linux command to show where bin files are located

I was having trouble remembering the linux command to show where bin files are located. I eventually figured it out from googling that it was "which".

How to find command location in Linux?

Since I saw a few other interesting commands like whereis and type it got me curious. Are there any other useful and similar commands?

Linux / UNIX: Determine where a binary command is stored / located on file system
# 2  
Old 08-21-2015
Code:
whatis
apropos

whatis gives a one liner from the man page
apropos search all of the man pages, like man -k, so apropos ls
shows any manual entry with ls in the name/title
# 3  
Old 08-22-2015
Hi.

For bash and ksh, see also command:
Code:
command: command [-pVv] command [arg ...]
    Runs COMMAND with ARGS ignoring shell functions.  If you have a shell
    function called `ls', and you wish to call the command `ls', you can
    say "command ls".  If the -p option is given, a default value is used
    for PATH that is guaranteed to find all of the standard utilities.  If
    the -V or -v option is given, a string is printed describing COMMAND.
    The -V option produces a more verbose description.

As in (using bash):
Code:
$ command -v mkdir
/bin/mkdir

and
Code:
$ command -V mkdir
mkdir is hashed (/bin/mkdir)

and (for me):
Code:
$ command -V ls
ls is aliased to `ls -CF --color=never'

For a local command (script):
Code:
$ command -V mag
mag is hashed (/home/drl/bin/mag)

In this environment:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation) 
bash GNU bash 3.2.39
ksh 93s+

For ksh, similar to:
Code:
$ whence -v whence
whence is a shell builtin

See man bash and man ksh for details.

Best wishes ... cheers, drl

Last edited by drl; 08-22-2015 at 10:49 AM..
# 4  
Old 08-22-2015
Not to forget whereis, which i think is a GNU-speciality.

I hope this helps.

bakunin
# 5  
Old 08-22-2015
Coming back to one of the command that you mentioned, type would usually be the best command to use, rather than which, since it also shows if a command is a shell builtin or keyword, whereas which would not.
Code:
$ type test time
test is a shell builtin
time is a shell keyword

Code:
$ which test time
/bin/test
/usr/bin/time

There is a nice option to type that shows all:
Code:
$ type -a test time
test is a shell builtin
test is /bin/test
time is a shell keyword
time is /usr/bin/time

# 6  
Old 08-23-2015
which is the C-shell builtin (and shows C-shell aliases).
/usr/bin/which is an emulation.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with running a script on files located in subdirectories

Hello everyone, I'm am a newbie to coding so I am reaching out in hopes that I can get some help from this forum. I am trying to run the script below from a single directory, however the directory has many subfolders. In each of those subfolders is a file, uniquely named to that specific... (3 Replies)
Discussion started by: azurite
3 Replies

2. Shell Programming and Scripting

Find out directory where command is located

so i have a script that i do not want copies of that script to be roaming around. i want that script to be in only one location on the filesystem, and whoever wants to use it should just link to it. any idea on how to exit from a script if it is detected that the running version is a copy and... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Linux

The DNS files, where are located?

Hello, please where are located DNS files on various linux distributions? Mainly im interested in CentOS (RedHat) and Ubuntu (Debian). I mean i will be changing IPs and i have registered nameservers on my domain registar and it points to OLD IP, so i need to know in which files to edit on... (3 Replies)
Discussion started by: postcd
3 Replies

4. Shell Programming and Scripting

Comparing file ownership/permission and content of files located on two different servers

Hi All, can some one suggest me a tool to compare file ownership/permission and contents of files located at two different unix servers? Thanks, Pranav (1 Reply)
Discussion started by: Pranav Bhasker
1 Replies

5. Shell Programming and Scripting

Command to show unique strings in two files

how to display the unique strings in two files using shell script or commands. I tried diff and cmp but it shows the entire line, i need only the mismatched strings. File1: sat,sun,mon,tue rose,lilly,lotus white,red,blue,green,pink File2: sat,sun,mon,tue rose,sunflower,lotus... (4 Replies)
Discussion started by: Arun_Linux
4 Replies

6. Solaris

Show complete command on command line when we use 'ps'

Hi, When I query using ps -ef, the complete command is not displayed and is truncated. Can you please tell me a method to resolve this ? I have tried the below. ps -ef | cat ps -ef | grep imp >/tmp/t1.txt /usr/ucb/ps -auxw pargs <pid> /usr/ucb/ps -aefyl | grep imp Thanks (11 Replies)
Discussion started by: mk1216
11 Replies

7. Shell Programming and Scripting

HOW: Shell script accessing files located in individual logged in user.

Hi I have below scenario, I hope this could be possible, but as of now no idea how to implement this. Mount point in this location /abc/mp, and there will different users who will be executing one the file shell1.sh file located in /abs/mp, but every user will execute this shell1.sh file from... (1 Reply)
Discussion started by: shekharjchandra
1 Replies

8. Solaris

Where are the source files located in solaris (b 116)

Hi all, I would like to know the dir location where all the source files for various file systems are located(not the compiled ones)? I tried in /usr/src/uts , but thats as far as I can go. After this i have the i86pc but there are no .c files anywhere.... (Impossible) # find / -name *.c... (1 Reply)
Discussion started by: wrapster
1 Replies

9. Shell Programming and Scripting

Bash scripting to compare N number of files located in two directories

I want to compare "N" (around 2000+) number of huge files located in a directory A against "N" files located in a different directory using Bash scripting. Please help me with any scripts available. Thanks. (2 Replies)
Discussion started by: Sangtha
2 Replies

10. UNIX and Linux Applications

Where are the Areca and IPMI config files located

Hi, I'm trying to locate the config files that are installed on a Unix/Linux system that belong to programs called Areca and IPMI. Two different programs. The most information I can get from IPMI is that it may be version 1.11 from Supermicro and it's installed by a CD. I checked the CD and... (1 Reply)
Discussion started by: edomingox
1 Replies
Login or Register to Ask a Question