Tag Archive for 'server'

Some Basic VI Commands

TEST

I’m bored right now so I’m messing around on my server. Sometimes people forget VI Commands so I thought I’d share some basic VI commands. Hopefully this quick reference can help somebody out. For those that don’t know, VI is an editor used in the Linux/Unix environment to edit files that contain text. http://en.wikipedia.org/wiki/Vi

To edit a file in SSH you’ll run this command
# vi /path/to/file/whatever.sh

First… you must learn there are 2 different modes.

Insert mode and Command mode

hit escape to enter command mode.
from command mode… these are the keys to go into insert mode
i => will make you start inputing at the cursor
a => will make you start inputing after the cursor
o => will open up a new line below the current line your cursor is
on,and move the cursor there.

when in insert mode, hit the escape key to enter command mode again
basic command mode commands
:w => save the file
:wq => save the file and quit
:q! => quit w/o saving

/textstring => searches for the textstring in the file ( hit n to find
next instance and N to find previous )

simple copy and paste
yy => yanks single line ( aka copy line into buffer)
p => will paste buffer onto the line below where the cursor is.

to get fancy, you can prepend yy with the number of lines you want to
copy ex .

5yy  => will yank 5 lines from where the cursor is and below in the buffer
p => will paste those 5 lines

dd => cuts single line ( aka cuts line into buffer )
p => will paste cut buffer onto the line below where the cursor is.

And that’s about it. For more in depth instructions you can check out these two sites:
http://osr600doc.sco.com/en/FD_create/vi_summary.html
http://www.cs.colostate.edu/helpdocs/vi.html

How to: tar a file, gzip a file, untar a file quickly

TEST

I thought I’d share in case anybody else runs into the problem and needs to tar or gzip a file on their server.

Here’s how to tar and then how to gzip (compress) a file in SSH
When you are logged into SSH this command line should tar and then gzip your folder into a .tar.gz file. This will gzip your file into the current directory:
tar -czf whatever.tar.gz foldername
If you’d like to tar your file and have it put in another location use this:
tar -czf /directory/directory/whatever.tar.gz foldername

Here’s how to untar and how to ungzip (or unzip, uncompress) a file in SSH:
This will untar and uncompress your file, then it will place that folder in the directory you are currently in restoring your old folder and file structure:
gunzip -dc whatever.tar.gz | tar xvf -

Thank you, and good night.

How to empty the qmail queue

TEST

To clear *all* messages from the queue, shut down qmail, then:

cd /var/qmail/queue
find intd todo local remote mess info bounce -type f -print |xargs rm

Start qmail back up, and the queue should be empty.