Editing web files without FTP

4661409838_919824b9fa_b

by Aaron Reimann

March 31, 2010

Are you a web designer that sometimes needs to SSH into a web site and make some changes but don’t know a Unix text editor? Here are some basic commands that you might need while navigating into the correct directory and editing a file using Vi, one of the best text editors around (if you can handle command-line).

Navigating in and out of directories:

To change directories:

pwd (shows you what directory you are in)

ls (lists all files)

cd www (gets you into the directory called www)

cd .. (gets you down one directory)

Editing files: I normally will use TextMate as a text editor, but for some quick fixes or if I am on someone’s computer, I will SSH in and edit file and use Vi. It is confusing if you don’t know it. I am by no means a Vi expert like some of my friends, but I can do a lot. Here are the basics:

Use the arrow keys to navigate. You can use letters to move around, but if you don’t want to learn Vi, don’t waste your time.

vi filename.php (opens a file called filename.php)

i (gets you in the insert mode)

the escape key gets you out of the insert mode

x (deletes the character your cursor is on)

dd (deletes the whole line you are on)

:w (writes the file)

:q (quits Vi)

:wq (writes the file and exists)

:%s:bob:john:g (Replaces bob with john in the whole file. I recently used that to replace text on a 42 meg text file; it came in handy. It took seconds to do.)

Enjoy!

photo credit: dir /s via photopin (license)

related posts

Celebrating 20 Years of WordPress by Speaking at WordCamp Europe 2023

Now that I’ve settled down from my trip to Israel and Greece, I wanted to…

Speaking at WordCamp Netherlands 2022

In the WordPress world, we have WordCamps. It is an event that will have 150…