When you execute a program from the command line, you need to provide either an absolute pathname or a relative pathname to the executable file, unless the executable is located in a directory which is specified in your shell's $PATH
environment variable.
Absolute pathnames start relative to the root directory:
/home/cs50/pset6/server
or this shorter version:
~cs50/pset6/server
The second one works because ~cs50
is equivalent to /home/cs50
.
Using an absolute pathname like this should fix your problem. You will not even need to cd
to the CS50 Staff's home directory.
Relative pathnames start relative to the current working directory:
cd /home/cs50/pset6
./server
or like this:
cd /home/cs50
./pset6/server
or even like this:
cd /home/ubuntu
../cs50/pset6/server
When you type server
by itself on a line, instead of ./server
(assuming that your working directory is /home/cs50/pset6
) the shell looks for the server
command in all the directories on your $PATH
.
In the IDE, the $PATH
is long and maybe a bit overwhelming:
~/workspace/ $ echo $PATH
/home/ubuntu/.nvm/versions/node/v4.2.1/bin:/home/ubuntu/bin:/usr/local/rvm/gems/ruby-2.2.1/bin:/usr/local/rvm/gems/ruby-2.2.1@global/bin:/usr/local/rvm/rubies/ruby-2.2.1/bin:/home/ubuntu/bin:/opt/cs50/bin:/mnt/shared/bin:/home/ubuntu/workspace/node_modules/.bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mnt/shared/sbin:/opt/gitl:/opt/go/bin:/mnt/shared/c9/app.nw/bin:/usr/local/rvm/bin
In the Appliance, the $PATH
is shorter and easier to read:
jharvard@appliance (~): echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Since there is no executable binary or script file named server
in any of those locations, the bash
shell responds with the helpful error message:
bash: server: command not found
The error message tells you three things. Most obviously, it tells you "command not found" -- something you typed was not found on the $PATH
.
Less obviously, it also tells you where the error is coming from ("bash:" -- the "Bourne Again SHell" command interpreter) and also what invalid command you tried to execute.
~/workspace/ $ waleed
bash: waleed: command not found
Hope this helps.