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-15
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 startLogin 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 mysqlUPDATE 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 = 3306Open port 3306 for remote administration:
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPTOr 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 ACCEPTSave iptables rules:
service iptables saveBackup/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):
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:
Install the vsftpd package via yum command:
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
Turn off standard ftpd xferlog log format:
Turn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
Above to directives will enable logging of all FTP transactions. Lock down users to their home directories:
Create warning banners for all FTP users:
Turn on vsftpd on boot:
Start the service:
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the RH-Firewall-1-INPUT:
Open file /etc/sysconfig/iptables-config, enter:
Ensure that the space-separated list of modules contains the FTP connection tracking module:
Save and close the file. Restart firewall:
Tip: View FTP Log File
Type the following command:
Tip: Restrict Access to Anonymous User Only
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
Tip: Disable FTP Uploads
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
For upload to work except for anonymous, you might need to:
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 1Install the vsftpd package via yum command:
# yum install vsftpdvsftpd 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.confTurn off standard ftpd xferlog log format:
xferlog_std_format=NOTurn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
log_ftp_protocol=YESAbove to directives will enable logging of all FTP transactions. Lock down users to their home directories:
chroot_local_user=YESCreate warning banners for all FTP users:
banner_file=/etc/vsftpd/issueTurn on vsftpd on boot:
# chkconfig vsftpd onStart the service:
# service vsftpd start
# netstat -tulpn | grep :21Configure Iptables To Protect The FTP Server
# vi /etc/sysconfig/iptablesAdd 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 ACCEPTOpen file /etc/sysconfig/iptables-config, enter:
# vi /etc/sysconfig/iptables-configEnsure 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 restartTip: View FTP Log File
Type the following command:
# tail -f /var/log/vsftpd.logTip: Restrict Access to Anonymous User Only
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
local_enable=NOTip: Disable FTP Uploads
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
write_enable=NOFor 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
- Compile NCBI
- make sure link the actual makefile in
platform/to the root level - make sure the paths in the linked makefile are modified to your environment
- make sure link the actual makefile in
- Compile SLRI
- make sure
$NCBIis set - link
lib/*.mkto root level cd lib && make lib
- make sure
- Compile bzip2
- Compile libiodbc (as ODBC dependency)
- Set environment var
$NCBI,$SLRI,$ODBC, and$BZDIR - Comment out
ValNodeUniqueinseqhound/include/intrez_misc.handseqhound/src/intrez_misc.c cd seqhound && ./makeallsh odbc all
2010-12-17
Secure GRUB
Version 1 (aka 0.98)
Reference cyberciti.biz
Sample config file:
Version 2 (aka 1.98)
Reference ubuntuforums.org
Reference cyberciti.biz
#grub-md5-crypt
Password:
Retype password:
$1$NYoR71$Sgv6pxQ6LG4GXpfihIJyL0# 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
bootVersion 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 loginslastb show bad loginslastlog show latest logins of all/any users./var/log/btmp bad logins/var/log/wtmp successful logins/var/run/utmp current loginsSet 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/lsusblshwroute -nshows 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.xTo pipe wget download content:
wget -q url -O - | cat > abc.txtFor ubuntu 10.10
Edit
/etc/default/grub & run update-grub to set the booting preferences
2010-12-16
Ubuntu Server 10.10 (As desktop use)
Hate OpenOffice? Dislike the integrated IM software? Feel sick about GNOME games? This solution might help to build the desktop from scratch that avoids most unnecessary components.
Installation:
Addition:Development: Remote access: Media: Printing:
Configuration:
Installation:
- Get a ubuntu server iso, and install it the debian way.
- Modify
/etc/apt/sources.listto your satisfaction. - Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu
Addition:
- Basic:
vim
- Desktop:
xserver-xorggnome-coregdmgnome-themes-selectedhumanity-icon-themegcalctool(the calculator)chromium-browsergnome-screensaverflashplugin-installerlanguage-support-??- *
network-manager - *
network-manager-openconnect(for Cisco AnyConnect VPN) *wine
- Security:
vlock
g++openjdk-6-jreqt4-dev-tools*dia*mysql-server*mysql-admin*python-mysqldb
vinagre(the client)vino(the server)
vlcmozilla-plugin-vlclibdvdcss2ubuntu-restricted-extras
system-config-printer-gnomecups*smbclient(for Windows shared printing)*hplip(HP printer drivers)
Configuration:
- Clear screen when logout:
~/.bash_logout- insert single command
clear
- Disable Ctrl-Alt-Del:
/etc/init/control-alt-delete.conf- comment out the actual command line
- Secure login/out logs:
sudo chmod 640 `sudo find /var -name ?tmp`
- Stop GDM from auto starting:
/etc/init/gdm.conf- comment out all "start on" stuff
- Configure GRUB:
/etc/default/grubupdate-grub
- MySQL
/etc/mysql/my.cnf- to reset root password:
sudo dpkg-reconfigure mysql-server-5.1
2010-11-02
Building CLucene
Note: done on Ubuntu 10.10.
Note 2: if no need for snapshot features, there is a pre-built package in the repo, called
Download CLucene source (tgz).
Install necessary dependency for building:
Make a new folder, and cd into it. Run
Then
If you get an error complaining undeclared
Note 2: if no need for snapshot features, there is a pre-built package in the repo, called
libclucene-dev.Download CLucene source (tgz).
Install necessary dependency for building:
g++zlib1g-devcmake
Make a new folder, and cd into it. Run
cmake <clucene-source-folder>.Then
ccmake <clucene-source-folder> to turn on static library build.If you get an error complaining undeclared
INT_MAX in file src/core/CLucene/search/spans/TermSpans.cpp, insert #include <limits.h> at the beginning of that file.
Subscribe to:
Posts (Atom)