This is somewhat a Grandma question, but nevertheless, I can't really figure it out.

It's the following: I log in to a remote machine via ssh. There (for example!) I try to set LD_LIBRARY_PATH appropriately. This is often done with export but on the console I get from ssh, export leads to "Command not found". I type then bash and now I can use export.

On the other hand, I don't need to enter the bash terminal to execute sh-scripts and makefiles which contain for example the export command but can do it right from the console I get when entering via ssh.

I would be glad if someone could explain me this in a few words! Or how can I find out more?

  • As kidmose says, this has nothing to do with ssh. If you could login directly to the server (i.e., by going to its physical console), you would get the same interface you are seeing now. You can run scripts and Makefiles because they, internally, invoke bash (or at least /bin/sh, which is a predecessor of bash and is very similar to it). If you look at the scripts that you are using, you'll probably notice that they begin with #!/bin/sh or (rarely) #!/bin/bash. The make program is probably hard-coded to use /bin/sh, although it may be possible to override this in a Makefile. – G-Man Sep 4 '14 at 15:44

Bash is a shell, replacing sh, which was common before.

SSH is a protocol for secure connections.

From bash(a shell on you machine) you can run the program ssh to securely communicate with a shell on another machine. That shell might not be bash, but if bash is available you can enter a bash shell (within the other shell) by typing "bash" and then you can use export (which I think is a part of bash)

  • 1
    tcsh is an alternative to bash. They serve the same purpose, but in somewhat different ways. The admin of your remote server presumably figured that tcsh would server you better, but as you've found you can just open up bash instead. – kidmose Sep 4 '14 at 15:25
  • 1
    @Michael: If you’re more comfortable with bash, and it’s available, you may as well use it. (If you type exec bash, you won’t need to exit twice when you’re done.) But, in case you want to learn more about tcsh, you can look at its man page, or look for documentation on csh, a.k.a. “the C shell” (tcsh is an evolved version of csh). In particular (for example), to set an environment variable, use setenv (variable) (value) (note: no =) rather than export (variable)=(value). – G-Man Sep 4 '14 at 15:35
  • 1
    @kidmose, this might be nitpicky, but you don't have to start in a bash shell. You can open a SSH connection from Putty in Windows without an initial bash shell. – Adam Sep 4 '14 at 15:41
  • 1
    @Michael, if no shell is specified, make uses /bin/sh, see this page. – Adam Sep 5 '14 at 15:32
  • 1
    @Michael, the bash shell (as an example) communicates directly with the kernel in the form of system calls and signals, there's no middleman at that point, just lots of C code. If you have any additional questions, rather than posting a comment, start a new question. – Adam Sep 5 '14 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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