FTP Server

Introduction
use linux account to login
access user’s home directory (e.g. /home/alan)

Install Proftpd
aptitude install proftpd

Stop Proftpd
/etc/init.d/proftpd stop (start / reload / restart)

Configure deny list
vim /etc/ftpusers
/etc/init.d/proftpd reload

Install FTP client
aptitude intsall ftp

Display number of users
ftpcount

Display user list
ftpwho

Download files without prompt
ftp -i 192.168.1.1
mget *

Cron Job

Edit crontab
crontab -e
mm hh dd MM WK COMMAND (eg. * * 7 1 * uptime >> /var/log/uptime.log)

List all cron jobs
crontab -l

Remove crontab
crontab -r

Install crontab from file
crontab ~/mycron.txt (install)

Manage crontab of other user
crontab -u alan -e
crontab -u alan -l
crontab -u alan -r
crontab -u alan ~/mycron.txt

Control who can access crontab
vim /etc/cron.deny
vim /etc/cron.allow
(Enter username)

Compression

Compression Method
gzip  (1K corrupted will cause whole file crashed)
bzip2 (better; 1K corruped only cause 900K crashed)

bzip2 (.bz2)
Install
aptitude intsall bzip2

Compress
bzip2 /xxx
bzip2 -k /xxx (k: keep the old file)

Decompress
bzip2 -d /xxx.bz2
bzip2 -dk /xxx.bz2 (k: keep the old file)

gzip (.gz)
Install
aptitude intsall gzip

Compress
gzip /xxx

Decompress
gzip -d /xxx

tar (.tar .tar.bz2)
Compress
tar -cf /xxx.tar /xxx
tar -cjf /xxx.tar.bz2 /xxx
tar -czf /xxx.tar.gz /xxx

Decompress
tar -xf /xxx.tar
tar -xjf /xxx.tar.bz2
tar -xzf /xxx.tar.gz

Install
aptitude intsall bzip2

Apache

Install
aptitude install apache2
(home folder: /var/www/apache2-default/)

Edit port
vim /etc/apache2/ports.conf
/etc/init.d/apache2 reload

Change home directory
vim /etc/apache2/sites-enabled/000-default
# RedirectMatch ^/$ /apache2-default/
(redirect = edit the url)
/etc/init.d/apache2 reload

Add virtual directory
vim /etc/apache2/sites-enabled/000-default
Alias /virtual/ /var/www/real
<Directory “/var/www/real”>
</Directory>
/etc/init.d/apache2 reload

Add virtual host
vim /etc/apache2/sites-available/cse
NameVirtualHost *
<VirtualHost *>
ServerName cse.ust.com
DocumentRoot /cse/
</VirutalHost>
vim /etc/apache2/sites-available/cpeg
<VirtualHost *>
ServerName cpeg.ust.com
DocumentRoot /cpeg/
</VirutalHost>
a2ensite cse
a2ensite cpeg
/etc/init.d/apache2 reload

Enable userdir
a2enmod userdir
mkdir /home/alan/public_html
chmod 755 /home/alan/public_html
http://127.0.0.1/~alan

. Install
– aptitude install apache2
– (home folder: /var/www/apache2-default/)
. Edit port
– edit /etc/apache2/ports.conf
– /etc/init.d/apache2 reload
. Change home directory
– edit /etc/apache2/sites-enabled/000-default
# RedirectMatch ^/$ /apache2-default/
(redirect = edit the url)
– /etc/init.d/apache2 reload
. Add virtual directory
– edit /etc/apache2/sites-enabled/000-default
Alias /virtual/ /var/www/real
<Directory “/var/www/real”>
</Directory>
– /etc/init.d/apache2 reload
. Add virtual host
– vim /etc/apache2/sites-available/cse
NameVirtualHost *
<VirtualHost *>
ServerName cse.ust.com
DocumentRoot /cse/
</VirutalHost>
– vim /etc/apache2/sites-available/cpeg
<VirtualHost *>
ServerName cpeg.ust.com
DocumentRoot /cpeg/
</VirutalHost>
– a2ensite cse
– a2ensite cpeg
– /etc/init.d/apache2 reload
. Enable userdir
– a2enmod userdir
– mkdir /home/alan/public_html
– chmod 755 /home/alan/public_html
– http://127.0.0.1/~alan

sudo

Introduction
allows normal users to run command as root

Install sudo
apt-get install sudo

Configuration
Edit /etc/sudoers and enter these 2 lines:
uname    host=(runas) cmd
alan     pc1,pc2=(root,daemon) /bin/ls,/bin/cp,/usr/bin/whoami

Using sudo
sudo whoami
sudo -u david whoami

Get full sessions as root
sudo su –

Logging
/var/log/auth.log

User Accounts Management

Create User Account
adduser USERNAME

Delete User Account
deluser USERNAME

Additional Options:
apt-get install perl-modules
deluser –remove-all-files USERNAME
deluser –backup USERNAME
deluser –remove-all-files –backup USERNAME

Create Group
addgroup GROUPNAME

Delete Group
delgroup GROUPNAME
delgroup –only-if-empty GROUPNAME

Add user to a group
adduser USERNAME GROUPNAME

Remove user from a group
deluser USERNAME GROUPNAME

Lock User Account
passwd -l USERNAME

Unlock User Account
passwd -u USERNAME

List Age
chage -l USERNAME

Change Age
chage -E 2007/09/01 USERNAME

Print UID, GID
id USERNAME

FBML Error (line 11): illegal tag “body” under “fb:tab-position”

Errors while loading page from application
Parse errors:
FBML Error (line 11): illegal tag “body” under “fb:tab-position”

If you are using IIS, you may see the above message when you add a tab to your facebook page. It is because IIS doesn’t allow POST requests to html files by default.

Solution 1: Configure your IIS to accept POST requests to html files

Solution 2: Change your .html into .php

Remove the default post footer

“This entry was posted on Wednesday, December 2nd, 2009 at 10:00 pm and is filed under ‘category’. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.”

Steps to remove the above paragraph:

1. Login as administrator

2. Select ‘Appearance’ > ‘Editor’

3. Select the current theme

4. On the right hand side, select Single Post(single.php)

5. Search “This entry was posted” and delete the relevant code

6. Click ‘Update File’