Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I had to install git from source on RHEL. After installation the git command is shown to be in /usr/local/bin/git when trying the whereis command.This path is available in $PATH also.

When I type git it still says "Command not found." How to resolve this?

EDIT : output of various commands

$type git
type: Command not found.

$which git
git: Command not found.

$ls -l /usr/local/bin/git
-rwxr-xr-x 112 root users 5851488 Mar 15 20:07 /usr/local/bin/git

$whereis git
git: /usr/local/bin/git

$echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

EDIT: It works now but do not know why

I disconnected the telnet connection and logged in again few minutes back and find that the git command works. I am not sure what caused it to start working. This is confusing.

share|improve this question
    
Please add the type git, which git, ls -l /usr/local/bin/git outputs. –  manatwork Mar 15 '13 at 15:10
    
@manatwork please see the edit. –  Manoj Mar 15 '13 at 15:17
    
@Marco added the output of echo $PATH. –  Manoj Mar 15 '13 at 15:18
1  
I guess @manatwork meant file and not type ;-) so he wants (and I too) to see the output of file /usr/local/bin/git –  Huygens Mar 15 '13 at 15:58
1  
@Huygens, type is a shell builtin in dash, bash and zsh. In case you use ksh, you may have a good excuse for not knowing it. (In my ksh there is just an alias to whence with the name type. Not sure how widespread is such setting.) pastebin.com/VzScxzRg –  manatwork Mar 15 '13 at 16:23
show 3 more comments

3 Answers

up vote 3 down vote accepted

From the error messages you're using (t)csh. It would help to mention it in your question, especially as you're showing $ as your prompt, and that's traditionally a Bourne prompt, not a csh prompt.

type is a builtin in Bourne-style shell. It doesn't exist in csh. When you run type git, it tells you that the type command is not found.

Many shells keep information about the location of commands in the search path in a cache. I don't know if any version of csh caches negative lookups, but it seems that yours does. Run the command rehash to refresh the cache. When you start a new shell instance, it has a fresh cache and so doesn't remember that git was not present earlier.

share|improve this answer
    
Hi Gilles, I should have mentioned the shell. Sorry for that. But I get $ in the prompt for both bash and tcsh. in tsch it is [username@systemname]$ format and in bash it is bash-3.2$ format. –  Manoj Mar 18 '13 at 7:25
    
I think this is the closest possible explanation to what happened. I will try to recreate this and verify and get back. Thanks... –  Manoj Mar 18 '13 at 7:26
add comment

Make sure that, as in this thread, your shell hasn't changed from the one you are supposed to get:

I have just found that my shell got changed to csh and it was creating the problem.

[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/csh

I changed it to bash and the problem was resolved!

[root@localhost ~]# type export
export is a shell builtin

That would explain why you get a 'type: Command not found.' error message.

I experimented with these commands:

[root@localhost ~]# csh
[root@localhost ~]# type export
type: Command not found.
[root@localhost ~]# bash
[root@localhost ~]# type export
export is a shell builtin
[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/bash
share|improve this answer
    
Changing the shell to bash causes the 'type' command to work. The git command works now even without going into bash. Do not know why! Please see the edit. –  Manoj Mar 15 '13 at 17:14
add comment

The most probable reason is that you have the correct PATH but not the correct LD_LIBRARY_PATH.

The latest git executable is a binary file which is dynamically linked. When you followed the installation instructions, it probably placed libraries (.so files) in /usr/local/lib, you need to add this path to your LD_LIBRARY_PATH. Try it and then run git:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
git

If that does not work, could you provide the output of ldd /usr/local/bin/git. Thanks.

PS: if the solution worked, you need to add the LD_LIBRARY_PATH line to your .bash_profile

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.