Question: Is there anyway to deploy a contract permanently on my private chain?

I tried the greeter contract and closed the console. After running the console again and trying to invoke my greet function I received the following error.

Error: 'greeter' is not defined

Answer: 
**No.** A deployed contract on a blockchain does not get deleted when Geth's console is closed.

Restarting the Geth Javascript console requires variables, like `greeter`, to be re-initialized because the Javascript variables are in memory only and not persisted.

One thing that can help:

> 
> Geth has support to load custom JavaScript files into the console through the --preload argument. This can be used to load often used functions, setup web3 contract objects, or ...
> 
> 
> `geth --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js" console`
> 
> 
> 

For more information, including other ways to use Geth's console, see:
<https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console>

Tools such as Truffle make ongoing contract development easier, for example Truffle saves contract addresses and ABIs, so that as @Rob mentions, re-initializing in Truffle, when needed, would be a simple `greeter = Greeter.deployed()`.
It does not get deleted but the variable of that contract is deleted. In order to preserve the variable of the contract before you exit the geth console, you can store the variable with corresponding ABI interface and address of the contract in web3js. Example code in node.js:

```js
var http = require('http');
var Web3js = require('web3');
var web3 = new Web3js("ws://localhost:8546");

var server = http.createServer((req,res)=>{
  res.statusCode = 200;
  res.setHeader('Content-Type','application/json');

  // Contract receives ABI interface and address
  // Then contract is passed to greeter variable
  var greeter = new web3.eth.Contract([
        {
                "constant": false,
                "inputs": [],
                "name": "kill",
                "outputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "constant": true,
                "inputs": [],
                "name": "greet",
                "outputs": [
                        {
                                "name": "",
                                "type": "string"
                        }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "name": "_greeting",
                                "type": "string"
                        }
                ],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "constructor"
        }
], "0x5c6aa1573b32eb75bf516b6d1de1a5a27fadc111"); // <-- this is the address

  greeter.methods.greet().call().then((result) => {
    console.log(result);
    res.end(result);
  });
});

server.listen(8080, () => {
  console.log('alhamdulillah');
});

```