2011-03-01

KDE on Ubuntu Server 11.04

Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu

Packages

    Desktop

  • kde-plasma-desktop (xserver-xorg and kdm included)
  • chromium-browser
  • flashplugin-installer
  • language-support-??
  • kchmviewer
  • network-manager-kde
  • jockey-kde

    Development

  • g++
  • make
  • gdb
  • openjdk-6-jre
  • qt4-dev-tools

    Media

  • amarok

Configuration

    NetworkManager

  • edit /etc/NetworkManager/NetworkManager.conf
  • make the line read managed=true
  • sudo service network-manager restart

2011-02-22

Python Notes

os.wait() will return the oldest finished jobs

2011-02-15

Vim Recording

Ref: http://www.thegeekstuff.com/2009/01/vi-and-vim-macro-tutorial-how-to-record-and-play/

Start recording by pressing q, followed by a lower case character to name the macro
Perform any typical editing, actions inside Vim editor, which will be recorded
Stop recording by pressing q
Play the recorded macro by pressing @ followed by the macro name
To repeat macros multiple times, press : NN @ macro name. NN is a number

2011-02-11

32-bit and 64-bit packages in CentOS 5 x86_64

yum -y remove *.i386 *.i486 *.i586 *.i686

*Not recommended but you can prevent yum from installing 32-bit software by adding this line to section [main] in /etc/yum.conf:
exclude=*.i386 *.i586 *.i686

2011-02-09

MySQL (RHEL5)

chkconfig mysqld on
/etc/init.d/mysqld start
Login mysql
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passpass'; (passpass is the password you use to login)
DROP USER 'user2'@'localhost'
GRANT ALL ON *.* TO 'user1'@'localhost'; (wildcard % is allowed for * match)
USE mysql
UPDATE user SET password=PASSWORD("passpass") WHERE User='user1';
FLUSH PRIVILEGES;

Modify MySQL configuration file (/etc/my.cnf for Fedora-based linux; /etc/mysql/my.cnf for Debian-based linux), so it looks like this:
[client]
max_allowed_packet=1024M
[odbc]
max_allowed_packet=1024M
[mysqld]
max_allowed_packet=1024M
slave_transaction_retries=128
default-storage-engine=INNODB
datadir=/mnt/MD_1000/mysql
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306


Open port 3306 for remote administration:
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
Or if the only allowed client (e.g. your web server) is 10.5.1.3, then:
/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

Save iptables rules:
service iptables save

Backup/dumping with limited rows (e.g. to build a sample database from a large one)
mysqldump -u [username] -p [databaseName] --where="true limit 100" > dump.sql

2011-02-01

Linux List The Open Ports And The Process That Owns Them

Ref: http://www.cyberciti.biz/tips/linux-display-open-ports-owner.html

How do you list the network open ports on your server and the process that owns them? The answer is simple use the following command (must run as root):
sudo lsof -i
sudo netstat -lptu

CentOS 5 FTP Setup (vsftpd)

Ref 1: http://www.linuxquestions.org/questions/fedora-35/vsftpd-error-553-could-not-create-file-390569
Ref 2: http://www.cyberciti.biz/tips/rhel-fedora-centos-vsftpd-installation.html

Disable SELinux on FTP, so that uploading works:
setsebool -P ftp_home_dir 1

Install the vsftpd package via yum command:
# yum install vsftpd

vsftpd Defaults


Default port: TCP / UDP - 21 and 20
The main configuration file: /etc/vsftpd/vsftpd.conf
Users that are not allowed to login via ftp: /etc/vsftpd/ftpusers

Configure Vsftpd Server


# vi /etc/vsftpd/vsftpd.conf

Turn off standard ftpd xferlog log format:
xferlog_std_format=NO
Turn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
log_ftp_protocol=YES
Above to directives will enable logging of all FTP transactions. Lock down users to their home directories:
chroot_local_user=YES
Create warning banners for all FTP users:
banner_file=/etc/vsftpd/issue
Turn on vsftpd on boot:
# chkconfig vsftpd on
Start the service:
# service vsftpd start
# netstat -tulpn | grep :21


Configure Iptables To Protect The FTP Server


# vi /etc/sysconfig/iptables
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the RH-Firewall-1-INPUT:
-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT
Open file /etc/sysconfig/iptables-config, enter:
# vi /etc/sysconfig/iptables-config
Ensure that the space-separated list of modules contains the FTP connection tracking module:
IPTABLES_MODULES="OTHER_MODULES ip_conntrack_ftp"
Save and close the file. Restart firewall:
# service iptables restart

Tip: View FTP Log File
Type the following command:
# tail -f /var/log/vsftpd.log

Tip: Restrict Access to Anonymous User Only
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
local_enable=NO

Tip: Disable FTP Uploads
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
write_enable=NO

For upload to work except for anonymous, you might need to:
  • create a group, say ftpw
  • change the ownership of /var/ftp and its subdirectories to group ftpw
  • add ftpw group onto users with write privilege

2010-12-23

Notes on Compiling SeqHound

  1. Compile NCBI
    1. make sure link the actual makefile in platform/ to the root level
    2. make sure the paths in the linked makefile are modified to your environment
  2. Compile SLRI
    1. make sure $NCBI is set
    2. link lib/*.mk to root level
    3. cd lib && make lib
  3. Compile bzip2
  4. Compile libiodbc (as ODBC dependency)
  5. Set environment var $NCBI, $SLRI, $ODBC, and $BZDIR
  6. Comment out ValNodeUnique in seqhound/include/intrez_misc.h and seqhound/src/intrez_misc.c
  7. cd seqhound && ./makeallsh odbc all

2010-12-17

Secure GRUB

Version 1 (aka 0.98)
Reference cyberciti.biz
  1. #grub-md5-crypt
    Password:
    Retype password:
    $1$NYoR71$Sgv6pxQ6LG4GXpfihIJyL0
  2. # vi /boot/grub/menu.lst (Red Hat /boot/grub/grub.conf)
    Edit file and add a password line as follows:
    password --md5 $1$NYoR71$Sgv6pxQ6LG4GXpfihIJyL0

Sample config file:
default 0
timeout 5
password --md5 $1$NYoR71$Sgv6pxQ6LG4GXpfihIJyL0
title Debian GNU/Linux, kernel 2.6.13.4-cust-en-smp
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda3 ro
savedefault
boot


Version 2 (aka 1.98)
Reference ubuntuforums.org

Linux notes

skill -STOP -u username Pause somebody.
skill -KILL -u username Kick out somebody.
skill -KILL -v /dev/pts/* Kick all out.

last show successful logins
lastb show bad logins
lastlog show latest logins of all/any users.
/var/log/btmp bad logins
/var/log/wtmp successful logins
/var/run/utmp current logins

Set date and time
# date -s "2 OCT 2006 18:00:00"
# date --set="2 OCT 2006 18:00:00"
# date +%Y%m%d -s "20081128"
# date +%T -s "10:13:13"

Get hardware info
/sbin/lspci
/sbin/lsusb
lshw

route -n
shows the routing table, the gateway will be flagged with a 'G'

If DNS is not properly configured, go to /etc/resolv.conf, check or add line nameserver x.x.x.x

To pipe wget download content:
wget -q url -O - | cat > abc.txt

For ubuntu 10.10
Edit /etc/default/grub & run update-grub to set the booting preferences