Vi Text Editor (console mode)

Don´t be shy, Linux is fun! =)
Post Reply
User avatar
Stavros
ΜΟΛΩΝ ΛΑΒΕ
ΜΟΛΩΝ ΛΑΒΕ
Posts: 1098
Joined: 02 Jan 2006, 17:00
18
Location: Mississippi, U.S.A.

Vi Text Editor (console mode)

Post by Stavros »

I have never come across a more infuriating piece of software. I know it's because I'm new to it, but damn...after messing with it for over an hour I'm still stuck on square one. Ok, so enough of the bitching, now the questions:

-I used the "R" command and was able to replace text. My problem was saving the text file. I had it set like I wanted, but it gave me the error that Vi was in Read-Only mode. Any help?

Oh yea, the command I used to view sshd_config was:

Code: Select all

vi sshd_config
after I had cd to /etc/ssh.

So, help really needed.

User avatar
computathug
Administrator
Administrator
Posts: 2693
Joined: 29 Mar 2007, 16:00
17
Location: UK
Contact:

Post by computathug »

Save Text And Exit VI

ZZ or :wq or
:x Save file and exit vi
:w file Save file but do not exit. Omitting file saves current file
:w! file Save file overriding normal checking
:n,mw file Write lines n through m to file
:n,mw>>file Append lines n through m to end of file
:q Leave vi, saving changes before last write
(you may be prompted to save first)
:q! Leave vi without saving any changes since last write
Q Escape vi into ex editor with same file; :vi returns
:e! File-edit current file, disregarding changes since last write.

if you are using vim you might like to try the tutorial before hand.

type

vimtutorial (in vim)
Last edited by computathug on 26 Jan 2008, 03:56, edited 1 time in total.

User avatar
Lyecdevf
cyber Idi Amin
cyber Idi Amin
Posts: 1222
Joined: 16 Mar 2006, 17:00
18
Location: In between life and death.
Contact:

Post by Lyecdevf »

I guess it is frustrating for a beginner but vi is considered by some people I know as the best unix editor. Any way you have to first press the escape button and than :wq.
We will either find a way, or make one.
- Hannibal

User avatar
Stavros
ΜΟΛΩΝ ΛΑΒΕ
ΜΟΛΩΝ ΛΑΒΕ
Posts: 1098
Joined: 02 Jan 2006, 17:00
18
Location: Mississippi, U.S.A.

Post by Stavros »

Ha! Finally got it. Yea, Guess I forgot to press Esc before trying to save. Now I'm just having trouble figuring out how to start sshd.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

i use nano =) really good editor

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

ohhh.....just as a little remark:
on newer distros you might ran into trouble using vi, you will notice it when it diplays ^A and similar stuff when you're trying to move the cursor, in this case use vim instead of vi.

to start/stop/restart a service always take a look into /etc/init.d/ , the services you find there can be controlled by:

Code: Select all

cd /
etc/init.d/servicename start|stop|restart
if the service can't be found in there it is most likely in /usr/bin/, but before searching the directories manually simply query the database:

Code: Select all

locate servicename
if you haven't done it yet build the database first:

Code: Select all

updatedb
might take some time.

applications/services are always in bin directories (if they have been installed the default way), like /usr/bin/, /usr/local/bin/.

in your case it should be

Code: Select all

etc/init.d/ssh restart
changes apply on the next login, if you are logged in already via SSH the connection will be kept using the old parameters. keep this in mind when you're working on a remote system, this can keep you away from locking yourself out....as long as the old connection is still open you still have a chance to take back changes.

:wink:

G-Brain
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 467
Joined: 08 Nov 2007, 17:00
16
Location: NL

Post by G-Brain »

If VIM is installed, there should be a "vimtutor" command available. Helped me out :D

I now use VIM every day.

Post Reply