How to add FTP users to Pure-FTPd

Detailed instructions here…
http://download.pureftpd.org/pub/pure-ftpd/doc/README.Virtual-Users

Here are my basic instructions

ADD THE USER

  • pure-pw useradd USERNAME -f /etc/pure-ftpd/pureftpd.passwd -u 48 -g 48 -d /PATH/TO/YOUR/DOMAIN

VIEW FILE MAKE TO SURE USER ADDED

  • vi /etc/pure-ftpd/pureftpd.passwd

RUN THIS COMMAND

  • pure-pw mkdb /etc/pure-ftpd/pureftpd.pdb -f /etc/pure-ftpd/pureftpd.passwd

Now when you view the pureftpd file (example: /etc/pure-ftpd/pureftpd.passwd) it will look something like this

howtohacksisawesome:kUyD6KHYvkUyD6KHYvHDkRSSicOlvHDkRSSicOlv/:48:48::/PATH/TO/YOUR/DOMAINs/./::::::::::::
anotheruser:1$ng1e9GP9pAs3ILv7y6K2C:48:48::/PATH/TO/YOUR/DOMAIN/./::::::::::::
~
~
~

How to add to and edit iptables

If you’re using a firewall on your server, you’ll want to edit your IPtables. Here’s how you can add new IPs or edit existing ones. Remember port 22 is for ssh and port 21 for FTP.

  • vi /etc/sysconfig/iptables

Edit the IPs in /etc/sysconfig/iptables. Then save changes and run this command to commit changes

  • service iptables restart

Successful service iptables restart should result in this:

Flushing firewall rules: [  OK  ]
Setting chains to policy ACCEPT: filter [  OK  ]
Unloading iptables modules: [  OK  ]
Applying iptables firewall rules: [  OK  ]

Example of what iptables should look like

http://www.brandonhutchinson.com/iptables_fw.html

http://oceanpark.com/notes/firewall_example.html

http://www.iitk.ac.in/LDP/LDP/nag2/x-087-2-firewall.example.html

http://www.liniac.upenn.edu/sysadmin/security/iptables.html

Or search google for “example iptables config file”

How to clear the Qmail Queue (clean & delete it quickly)

Awe shiznit!! Is your qmail queue on your server out of control? Look no further! Here’s a quick and easy way to clear, clean, or empty your qmail queue.

Clear & Clean Qmail Queue Completely, Safely & Fast!

This script should not remove anything it should not remove, and it should clear all e-mail from your qmail queue safely so you can start sending mail normally again. (This is for qmail only and not a solution for any other mail programs.) You’re going to need ssh access and an ssh program like putty or putty portable.

Let’s get busy with the Qmail Clear script:

  1. Log into your server through ssh
  2. type this:
    su –
  3. type this:
    wget http://www.howtohacks.com/scripts/qmailclear.sh
  4. type this:
    sh qmailclear.sh or sh ./qmailclear.sh
  5. done.

I took the downloadable script down so you’ll need to write it yourself, but just as a quick summary so you know what it’s doing, the Qmail Clear script looks like this:

echo Cleaning Queue
mv /var/qmail/queue/lock /root/
cd /var/qmail/queue; find . -type f -exec rm -f ‘{}’ \;
mv /root/lock /var/qmail/queue/
echo Queue is now Clean

If this didn’t do the trick and you’re receiving oversized file truncating errors (or “Argument list too long”) then you should use this more intense script. It will take longer but it will get the job done.

Let’s get busy with the Qmail Clean script :

  1. Log into your server through ssh
  2. type this:
    su –
  3. type this:
    wget http://www.howtohacks.com/scripts/qmailclean.sh
  4. type this:
    sh qmailclean.sh or sh ./qmailclean.sh
  5. done.

DO NOT restart any process. DO NOT reboot the server. DO NOT do anything until the script says it is done. If you restart a process, etc, it will break qmail and that’s no fun. Just run the script until it’s complete.

You can download the script and view all of the code yourself, but here’s a quick summary of the main lines of code so you know what’s taking place when running the Qmail Clean script:

echo “Stopping Qmail”
/etc/init.d/qmail stop
echo “Clearing the Mail Queue”
cd /var/qmail/queue/info
rm -rf blah blah blah
echo “Info folder clean, clearing mess folder”
cd /var/qmail/queue/mess
rm -rf blah blah blah
echo “Mess folder clean, clearing remote folder”
cd /var/qmail/queue/remote
rm -rf blah blah blah
echo “Remote folder clean, clearing intd folder”
cd /var/qmail/queue/intd
rm -rf blah blah blah
echo “Intd folder clean, clearing local folder”
cd /var/qmail/queue/local
rm -rf blah blah blah
echo “Local folder clean, clearing todo folder”
cd /var/qmail/queue/todo
rm -rf blah blah blah
echo “Mail queue cleaned”
echo “Restarting Qmail Now”
/etc/init.d/qmail start
echo “Qmail Started!”
echo “Done!”

If you’re interested in reading more about Qmail I recommend this book Qmail book and also these links:
A reference for qmail users – qmail.org
A qmail tutorial site – Life With Qmail

How to add a new IP to your server

Need to add a new IP to your server? Here’s how you can do it easily.

Add new IP to server by adding it to your httpd.conf file using the following. First launch the conf file in a text editor like this

vi/etc/httpd/conf/httpd.conf

Save that conf file. Then restart the service using this command

service httpd restart

And… BOOYA! Finished.

How to use basic VI commands

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 empty the qmail queue

To clear all messages from the queue the first step is you must shut down qmail. Here are the SSH commands for that.

  • Using qmail-rocks scripts:
    /etc/rc.d/qmail stop
  • Or you can try the following
    qmailctl stop
  • Or you can try this
    init.d/qmail stop

To clear the qmail queue, use the following SSH commands to change to the queue directory and clear the queue.

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

After it’s clear you can start qmail back up using a similar command that stopped the service, but say start.

  • Using qmail-rocks scripts:
    /etc/rc.d/qmail start
  • Or you can try the following
    qmailctl start
  • Or you can try this
    init.d/qmail start

Now the queue should be empty!

For learning the ins and outs of Qmail I recommend this Qmail book

How to TAR a file or folder, GZIP, and UNTAR (create TAR files archive)

If you’re running a Linux based server, here a step by step guide on how to tar a file and then how to gzip (compress) that file using a simple SSH command.

When you are logged into your server through SSH, you can use this command line to tar and then gzip your folder into a tarball file. This will compress your file into the current directory

  • tar -czf whatever.tar foldername
    (another method would be…)
  • 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 foldername

Now that you have a tar file, here’s how to untar / ungzip (or unzip, uncompress) a file in SSH. Using this command you’ll 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.

  • tar -xf whatever.tar
    (another method would be…)
  • gunzip -dc whatever.tar.gz | tar xvf –

Here are a list of tar options, and their significance.

-c = create
-f = read to/from the named file (instead of the device /tape)
-t = list contents of .tar file
-r = append to a .tar file
-v = verbose (tells you everything its doing)
-x = extract contents of .tar file
-z = compress files

Want to learn more SSH commands? I recommend the book Linux in a Nutshell

If you’re a server admin, another thing you might be interested in is how to clear the qmail queue.