# Serious Problem



## andy8 (Mar 14, 2011)

Hi,

This may be a really novice question but I'm a new FreeBSD user. I need some help. I've entered the command *chsh* as a root user on the system. I entered an editor environment and I couldn't exit.

What is the command to exit the environment? I've also entered some commands on the editor which I couldn't erase, any methods to clear them and  exit the system?

Kind Regards,


----------



## SirDice (Mar 14, 2011)

You are most likely inside vi(1). You can quit vi (without saving) with <ESC>:q! (that's escape key, colon, q, exclamation mark and hitting enter).


----------



## andy8 (Mar 14, 2011)

Thanks for  the  prompt  reply.

But  when  I  click  esc  key  it  doesn't  appear  on  the  interface  and  when  I  click  the  letter  q,
it  says  'q isn't a vi command'

I  couldn't  execute  the <ESC>:q!


----------



## andy8 (Mar 14, 2011)

BTW I'm using Macbook - In  case  the  OS  has  anything  to  do  with  this  issue


----------



## SirDice (Mar 14, 2011)

You forgot the colon (:).

You won't see the escape, just hear a beep. When you start typing :q! this will appear on the bottom left-hand side.


----------



## andy8 (Mar 14, 2011)

Bravo !

It  worked.  Thank  you  very  much  indeed. I  really  appreciated  it.


----------



## anomie (Mar 14, 2011)

@andy8: it would be a very, very good idea for you to learn (n)vi if you're going to be working on unix / unix-like systems. Search the 'net for some tutorials. 

-------

In the meantime, FreeBSD includes an "easy editor". To try it out, use one of the following (based on the shell your account is using).

For c shell-based: 

```
setenv EDITOR /usr/bin/ee
```

For Bourne shell-based: 

```
export EDITOR=/usr/bin/ee
```

From that point on, most commands that invoke an editor (including chpass(1), crontab(1), and others) will use ee(1) instead of vi(1). If you decide you like it, you simply put the same statement in your account's shell startup file.


----------



## wblock@ (Mar 14, 2011)

It should also be added, quickly, that *you should not change root's shell*.  It can leave you stranded at bad times.
If you really want something other than csh for root, add a bit to the end of your .cshrc:

```
if (-f /usr/local/bin/bash) then
  exec /usr/local/bin/bash
endif
```


----------



## SirDice (Mar 14, 2011)

Yes, vi. It's a really good editor but it has a massive learning curve. The 'best' part of it is that you can usually find it on _every_ unix or unix-like system. So, at least learn the basics of it. Like editing and exit with/without saving for instance 

Don't worry, I actually ended up rebooting my machine when I first encountered vi and couldn't figure out how to quit the damn thing.


----------



## Alt (Mar 14, 2011)

Can't understand the vi fans (no offence) =) Usually on fresh install I set up the net with [cmd=]ee /etc/rc.conf[/cmd] and then just [cmd=]pkg_add -r mc[/cmd]  
And yes, I'm using noobish *mcedit* to solve my tasks and don't think about editor things ever. ï¿½e


----------



## aragon (Mar 14, 2011)

SirDice said:
			
		

> Yes, vi. It's a really good editor but it has a massive learning curve


Mmm, I disagree.  Compared to everything else one needs to learn to administer a Unix system, vi is a drop in the ocean... and a well worth drop!


----------



## da1 (Mar 15, 2011)

SirDice said:
			
		

> I actually ended up rebooting my machine when I first encountered vi and couldn't figure out how to quit the damn thing.



Hahahaha, good old times; happened to me to )


----------



## fluca1978 (Mar 29, 2011)

I love Emacs and hate vi, but I think both are quite hard to learn and to master the first times...


----------

