Why "command not found"?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
tomliotta
Level 2
Level 2
Posts: 59
Joined: Mon Aug 04, 2014 6:59 pm
Location: Gig Harbor, WA, USA

Why "command not found"?

Post by tomliotta » Wed Jun 10, 2015 8:53 pm

LM 17.1 64-bit, Lenovo T500

Given this excerpt from a terminal session:

Code: Select all

toml@T500-64 /opt/SQLDev $ sqldeveloper.sh
sqldeveloper.sh: command not found
toml@T500-64 /opt/SQLDev $ java -jar sqldeveloper.jar
SQL Developer 2.3.0

Java version 1.7.0_79
Java vendor Oracle Corporation
OS name Linux

toml@T500-64 /opt/SQLDev $ 
And given this content of /opt/SQLDev/sqldeveloper.sh:

Code: Select all

#!/bin/sh
java -jar sqldeveloper.jar
Was sqldeveloper.sh the "command not found"? I assume that it was, but then it's not clear how it couldn't be found. I wondered if something in the script wasn't found, so I ran the java command by itself, and that worked fine.

The basic questions come down to (1) is the error explicitly indicating the problem command rather than something in the script, and (2) what's a basic troubleshooting sequence? (I.e., how do I determine why it's not found?)

The sqldeveloper.sh script is definitely in /opt/SQLDev since ls lists it in that terminal session. I appear to have the directory set correctly in the terminal. I'm the owner and it's set as executable (AFAICT).
Tom

For LM12: Old IBM T22 laptop, 512MB, 40GB HDD (w/LMDE12 dual boot), CD-RW/DVD, USB 1.1 and on-board Ethernet
For LM16: IBM ThinkCenter M52, 4GB, 500GB HDD (w/WinXP dual)
Lenovo W510 ThinkPad,Core i7, 12GB, 320GB HDD (LM17.3 64-bit)
and 2 others.

Mute Ant
Level 13
Level 13
Posts: 4926
Joined: Tue Sep 03, 2013 7:45 pm
Location: Norfolk UK

Re: Why "command not found"?

Post by Mute Ant » Wed Jun 10, 2015 9:04 pm

Yes, the bare "sqldeveloper.sh" is the command-not-found because Linux shells don't automatically include the current directory as a source of commands. You can run it by explicitly giving it a path;

Code: Select all

./sqldeveloper.sh
Other command-not-found trouble-shooters...

Code: Select all

### Which youtube-dl command would you run?
    which youtube-dl

Code: Select all

### Where is the command sudo?
    whereis sudo

Code: Select all

### First thing in the morning?
    whoami

tomliotta
Level 2
Level 2
Posts: 59
Joined: Mon Aug 04, 2014 6:59 pm
Location: Gig Harbor, WA, USA

[Solved] Re: Why "command not found"?

Post by tomliotta » Fri Jun 12, 2015 7:16 am

Mute Ant wrote:Yes, the bare "sqldeveloper.sh" is the command-not-found because Linux shells don't automatically include the current directory as a source of commands.
Sheesh! Now that's a fundamental detail that'll never be forgotten. The platforms I've done some limited scripting work on have been more "UNIX" than "Linux". Current directory was usually sufficient, but always using "./" can work either way.

Thanks much! (And for the other bits also.)
Tom

For LM12: Old IBM T22 laptop, 512MB, 40GB HDD (w/LMDE12 dual boot), CD-RW/DVD, USB 1.1 and on-board Ethernet
For LM16: IBM ThinkCenter M52, 4GB, 500GB HDD (w/WinXP dual)
Lenovo W510 ThinkPad,Core i7, 12GB, 320GB HDD (LM17.3 64-bit)
and 2 others.

User avatar
Flemur
Level 16
Level 16
Posts: 6184
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Why "command not found"?

Post by Flemur » Fri Jun 12, 2015 12:01 pm

The platforms I've done some limited scripting work on have been more "UNIX" than "Linux".
Yeah, IIRC, in Unix "." was usually in your PATH by default; if you like that setup you can add "." to the PATH in your ~/.bashrc_profile
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Mint 18.3 Xfce/fluxbox/pulse-less
Xubuntu 17.10/fluxbox/pulse-less

deleted

Re: Why "command not found"?

Post by deleted » Fri Jun 12, 2015 12:31 pm

FWIW, as I recall, not having the current directory in your path was yet another security feature. (albeit a small one)
In otherwords, "." in your path is a security risk.
-Z

Post Reply

Return to “Newbie Questions”