LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-12-2011, 12:14 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Rep: Reputation: 51
Command path is in PATH but bash does not find the command.


kernel 2.6.21.5, slackware 12.0
GNU bash 3.1.17

Hi:
Code:
semoi@darkstar:~$ whoami
semoi
semoi@darkstar:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/java/jre/bin:/usr/lib/qt/bin:/usr/share/texmf/bin:.
semoi@darkstar:~$ ls /usr/local/bin/nasm
/usr/local/bin/nasm*
semoi@darkstar:~$ nasm
-bash: /usr/bin/nasm: No such file or directory
semoi@darkstar:~$
As you can see, /usr/local/bin is in the path. However, bash does not look for nasm in /usr/local/bin.

If I am root, things go well:
Code:
root@darkstar:~# whoami
root
root@darkstar:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
root@darkstar:~# nasm
nasm: error: no input file specified
type `nasm -h' for help
root@darkstar:~#
I cannot explain this at my present stage of knowledge. Can you?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-12-2011, 12:33 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,267

Rep: Reputation: 298Reputation: 298Reputation: 298
Permissions?

try

chmod 755 /usr/local/bin/nasm
chown root:root /usr/local/bin/nasm

(as root)

Edit:
I think druuna is right, it's probably an alias.

Last edited by Guttorm; 07-12-2011 at 12:39 PM.
 
Old 07-12-2011, 12:35 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

This part looks suspicious:
Code:
semoi@darkstar:~$ nasm
-bash: /usr/bin/nasm: No such file or directory
Bash seems to be looking for nasm in /usr/bin, if a command cannot be found in the PATH setting you would expect this:
Code:
bash: nasm: command not found
Could it be that nasm is aliased to expand to /usr/bin/nasm? (alias | grep nasm to check).

Hope this helps.
 
Old 07-12-2011, 02:25 PM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
No. alias | grep nasm gets no output. Besides
Code:
root@darkstar:~# ls -l /usr/local/bin/nasm
-rwxr-xr-x 1 root root 1272632 2011-07-12 13:25 /usr/local/bin/nasm
root@darkstar:~#
it has the same permissions, owner and group (root:root) as, e.g. mplayer, which gets executed for common users.
 
Old 07-12-2011, 02:30 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Maybe a function? Try
Code:
set | grep nasm
 
Old 07-12-2011, 02:33 PM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
set|grep nasm: no output, either.
 
Old 07-12-2011, 02:38 PM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

Are you executing the commands we asked for as root or as user semoi (it should be done as user semoi)?
 
Old 07-12-2011, 02:39 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,184

Rep: Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584
as the semoi user, try:
Code:
export PATH=/usr/local/bin:/usr/bin:/bin
whereis nasm
if that doesn't work, post the contents of semoi user:

Quote:
set
alias
 
Old 07-12-2011, 03:18 PM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
Hi:

And thanks for your posts, guys.
Code:
$ whoami
semoi
$ alias|grep nasm
$ set|grep nasm
$ OLDPWD=/home/semoi/assemblers/nasm-2.09.09 [nothing of interest]
$
I didn't do the export because 'whereis nasm' gives:
Code:
$ whoami
semoi
$ whereis nasm
nasm: /usr/local/bin/nasm
$
I attach the alias and set outputs.
Attached Files
File Type: txt set.txt (3.2 KB, 6 views)
File Type: txt alias.txt (235 Bytes, 8 views)

Last edited by stf92; 07-12-2011 at 03:24 PM.
 
Old 07-12-2011, 03:32 PM   #10
sandwormusmc
Member
 
Registered: Nov 2006
Distribution: Fedora 15 x86_64
Posts: 76

Rep: Reputation: 24
Quote:
Originally Posted by stf92 View Post
Hi:...
Is there a broken link perhaps in /usr/bin? What is the output of "ls -la /usr/bin/nasm*"?

If the output shows a broken link, try:

Code:
 # ln -s /usr/local/bin/nasm /usr/bin/nasm
 
Old 07-12-2011, 03:33 PM   #11
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 333

Rep: Reputation: 141Reputation: 141
If the nasm file has been moved to /usr/local/bin/ from /usr/bin/ it might still be hashed at its old location.
When the shell finds a command along the search path it remembers the location in an internal hash table. The next time the command is executed the shell uses the value in its hash table instead of searching the path again. Each shell has its own hash table, which could explain why the root shell can find the file.
Code:
# To see the hash table:-
hash

# To delete nasm from the hash table:-
hash -d nasm
 
6 members found this post helpful.
Old 07-12-2011, 03:37 PM   #12
sandwormusmc
Member
 
Registered: Nov 2006
Distribution: Fedora 15 x86_64
Posts: 76

Rep: Reputation: 24
Quote:
Originally Posted by Kenhelm View Post
If the nasm file has been moved to /usr/local/bin/ from /usr/bin/ it might still be hashed at its old location.
When the shell finds a command along the search path it remembers the location in an internal hash table. The next time the command is executed the shell uses the value in its hash table instead of searching the path again. Each shell has its own hash table, which could explain why the root shell can find the file.
Code:
# To see the hash table:-
hash

# To delete nasm from the hash table:-
hash -d nasm
Nice, wasn't aware of that ... very useful info.
 
Old 07-12-2011, 03:59 PM   #13
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by Kenhelm View Post
If the nasm file has been moved to /usr/local/bin/ from /usr/bin/ it might still be hashed at its old location.
When the shell finds a command along the search path it remembers the location in an internal hash table. The next time the command is executed the shell uses the value in its hash table instead of searching the path again. Each shell has its own hash table, which could explain why the root shell can find the file.
Code:
# To see the hash table:-
hash

# To delete nasm from the hash table:-
hash -d nasm
Doing hash it output
/usr/bin/nasm
hash -d nasm put and end to this issue. Thanks. From an old instalation nasm was in /usr/bin. Then I did 'removepkg nasm-xx.xx'. But the hash table (quite a new concept for me) was left intact, it seems. Regards.
 
Old 07-12-2011, 04:04 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I actually wanted to suggest that the hash table was the problem, but I wouldn't imagine that it would not automatically remove the hash entry and search again if a command is not found.
 
Old 07-12-2011, 08:03 PM   #15
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
Could you do a test in your system?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find command to search wildcard in path? markdjones82 Linux - General 12 12-11-2009 01:02 AM
PATH set incorrectly and lost bash: vi command... how can I change .bashrc? Lindz Linux - Newbie 10 09-23-2009 05:01 AM
How to exclude certain path from find command. UltraSoul Linux - Software 8 05-16-2009 06:26 PM
how to get the absolute path information of a command from ps command output ratul_11 Linux - General 1 08-06-2008 02:10 AM
how do i get the proper path to a file through find command napster Linux - General 4 11-07-2005 04:35 AM


All times are GMT -5. The time now is 03:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration