Tuesday, August 27, 2013

system call fork() and exec()

25 Jan 2013: system call fork() and exec()

http://www.youtube.com/watch?v=B4XsjJcClLc

RDAVIDWebService

Dear All We have launched a new library for programatically acces to DAVID (http://david.abcc.ncifcrf.gov/) which allows Set Enrichment analysis. This tool allows you to perform set enrichment analysis in a programatically way. It has been made available through Bioconductor. Please feel free to use it and any commento and suggestions will be very wellcome. You can access it from (in development R version) please visit www.bioconductor.org source("http://bioconductor.org/biocLite.R") biocLite("RDAVIDWebService")

Wednesday, August 14, 2013

some examples of simple bash scripts

#!/bin/sh

result=$( grep 'packet loss' dummy |
awk '{  first=match($0,"[0-9]+%")
    last=match($0," packet loss")
    s=substr($0,first,last-first)
    print s, last}' )

echo $result


----------------------
#there is a file named: dummy
#with the content: "There is 100% packet loss at node 1".
#possibly other lines

#note by wzy: first=11; last=15
Answer: 100%

Wednesday, August 7, 2013

How to install DHCP server in ubuntu 12.04 (Precise) Server

A DHCP Server assigns IP addresses to client computers. This is very often used in enterprise networks to reduce configuration efforts. All IP addresses of all computers are stored in a database that resides on a server machine.
A DHCP server can provide configuration settings using two methods
Address Pool
This method entails defining a pool (sometimes also called a range or scope) of IP addresses from which DHCP clients are supplied their configuration properties dynamically and on a fist come first serve basis. When a DHCP client is no longer on the network for a specified period, the configuration is expired and released back to the address pool for use by other DHCP Clients.
MAC Address
This method entails using DHCP to identify the unique hardware address of each network card connected to the network and then continually supplying a constant configuration each time the DHCP client makes a request to the DHCP server using that network device.

Install DHCP server in ubuntu 12.04
In ubuntu 12.04 ISC DHCP server is a transitional package for dhcp3-server so you have to install the following package
sudo apt-get install isc-dhcp-server
There are two main files /etc/default/isc-dhcp-server and /etc/dhcp/dhcpd.conf which we will need to configure so lets take the first.
Configuration of DHCP server
First you need to configure /etc/default/isc-dhcp-server file so you need to edit the file using the following command
sudo vi /etc/default/isc-dhcp-server
You should see similar to the following

#Defaults for dhcp initscript
#sourced by /etc/init.d/dhcp
#installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
#This is a POSIX shell fragment
#
#On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#Separate multiple interfaces with spaces, e.g. “eth0 eth1?.
INTERFACES=”eth0?

Replace eth0 above with the name of your network interface that you want the server to lease addresses on. Save and exit the file
Now you need to configure /etc/dhcp/dhcpd.conf file for this edit this file using the following command
sudo vi /etc/dhcp/dhcpd.conf
Once it opens you should see similar to the following

#
#Sample configuration file for ISC dhcpd for Debian
#
#Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
#configuration file instead of this file.
#
#
#The ddns-updates-style parameter controls whether or not the server will
#attempt to do a DNS update when a lease is confirmed. We default to the
#behavior of the version 2 packages (‘none’, since DHCP v2 didn’t
#have support for DDNS.)
ddns-update-style none;
#option definitions common to all supported networks…
option domain-name-servers ns1.example.org, ns2.example.org;
option domain-name “yourdomainname.com”;
default-lease-time 600;
max-lease-time 7200;

#If this DHCP server is the official DHCP server for the local
#network, the authoritative directive should be uncommented.
#authoritative;
#Use this to send dhcp log messages to a different log file (you also
#have to hack syslog.conf to complete the redirection).
log-facility local7;
#No service will be given on this subnet, but declaring it helps the
#DHCP server to understand the network topology.
#subnet10.152.187.0 netmask 255.255.255.0 {
#}
#This is a very basic subnet declaration.
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.150 10.0.0.253;
option routers 10.0.0.2;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.254;
option domain-name-servers 10.0.0.1, 10.0.0.2;
option ntp-servers 10.0.0.1;
option netbios-name-servers 10.0.0.1;
option netbios-node-type 8;
}

#option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
#This declaration allows BOOTP clients to get dynamic addresses,
#which we don’t really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
#range dynamic-bootp 10.254.239.40 10.254.239.60;
#option broadcast-address 10.254.239.31;
#option routers rtr-239-32-1.example.org;
#}
#A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
#range 10.5.5.26 10.5.5.30;
#option domain-name-servers ns1.internal.example.org;
#option domain-name “internal.example.org”;
#option routers 10.5.5.1;
#option broadcast-address 10.5.5.31;
#default-lease-time 600;
#max-lease-time 7200;
#}
#Hosts which require special configuration options can be listed in
#host statements. If no address is specified, the address will be
#allocated dynamically (if possible), but the host-specific information
#will still come from the host declaration.
#host passacaglia {
#hardware ethernet 0:0:c0:5d:bd:95;
#filename “vmunix.passacaglia”;
#server-name “toccata.fugue.com”;
#}
#Fixed IP addresses can also be specified for hosts. These addresses
#should not also be listed as being available for dynamic assignment.
#Hosts for which fixed IP addresses have been specified can boot using
#BOOTP or DHCP. Hosts for which no fixed address is specified can only
#be booted with DHCP, unless there is an address range on the subnet
#to which a BOOTP client is connected which has the dynamic-bootp flag
#set.
#hostfantasia {
#hardware ethernet 08:00:07:26:c0:a5;
#fixed-address fantasia.fugue.com;
#}
#You can declare a class of clients and then do address allocation
#based on that. The example below shows a case where all clients
#in a certain class get addresses on the 10.17.224/24 subnet, and all
#other clients get addresses on the 10.0.29/24 subnet.
#class“foo” {
#match if substring (option vendor-class-identifier, 0, 4) = “SUNW”;
#}
#shared-network 224-29 {
#subnet 10.17.224.0 netmask 255.255.255.0 {
#option routers rtr-224.example.org;
#}
#subnet 10.0.29.0 netmask 255.255.255.0 {
#option routers rtr-29.example.org;
#}
#pool {
#allow members of “foo”;
#range 10.17.224.10 10.17.224.250;
#}
#pool {
#deny members of “foo”;
#range 10.0.29.10 10.0.29.230;
#}
#}

From the above file you need to configure bold options and change domain name where it says yourdomainname.com Finally you have to restart the dhcp service by using the following command
sudo service isc-dhcp-server restart
DHCP server testing
You can check if your dhcp server is working properly bt running the following command
sudo netstat -uap



Next:
Install tftp server
You have two options: install the tftpd-hpa package or the atftp package.

For example:
#apt-get install tftpd-hpa

You may look through the configure file at:
#less /etc/default/tftpd-hpa

Modify the xinetd.conf file:
#vim /etc/xinetd.conf

Add a line to the end of the file:
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

restart the service:
#service tftpd-hpa restart
#service xinetd restart



Saturday, August 3, 2013

Install Apache2.4.6 on Ubuntu LTS 12

Install Apache2 on ubuntu LTS 12

(1)Download the source codes from www.apache.org:
httpd-2.4.6-deps.tar.gz
httpd-2.4.6.tar.gz

(2)Extract the source packages and install them (APR; APR-util; Apache2).

(3)Install the PCRE (Perl Compatible Regular Expression) library.
By default, this library will be installed in the directory /usr/local/lib, but somehow Apache2 will not be able to know this. So you need to do the following:

---------------------
Ubuntu
Create a new file in /etc/ld.so.conf.d/ called .conf

Edit the file and add a line per directory of shared libraries (*.so files), it will look something like:
/usr/local/lib
Reload the list of system-wide library paths:
sudo ldconfig
---------------------
 
(3)Now you are ready to start Apache2:
#/usr/local/apache2/bin/apachectl start

You can verify that Apache2 is running:
#pgrep httpd

Or point your web browser to 127.0.0.1
It works!


Friday, August 2, 2013

install NVIDIA driver in ubuntu

  • There is a bug with nvidia and the stock 3.8.0-19 kernel in ubuntu 13.04 use the mainline kernel
    • Not doing this can result in not being able to boot
  • Install the driver by running sudo apt-get install -y nvidia-313-updates nvidia-settings-313-updates
    • If you want the beta driver use the xorg edgers ppa, then install nvidia-319 nvidia-settings-319
      sudo apt-add-repository ppa:xorg-edgers/ppa -y; sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get install nvidia-319 nvidia-settings-319 -y

Thursday, August 1, 2013

使用Msmtp mutt shell发邮件


下载msmtp
wget http://downloads.sourceforge.net/msmtp/msmtp-1.4.16.tar.bz2?modtime=1217206451&big_mirror=0
1、编译一下软件
tar jxvf msmtp-1.4.13.tar.bz2
./configure --prefix=/opt/msmtp
make
make install
2、查看配置文件在那儿
[root@server bin]# ./msmtp --version
msmtp version 1.4.13
TLS/SSL library: none
Authentication library: built-in
Supported authentication methods:
plain cram-md5 external login
IDN support: disabled
NLS: enabled, LOCALEDIR is /opt/msmtop/share/locale
System configuration file name: /opt/msmtp/etc/msmtprc -----呵呵,这是我自己建的
User configuration file name: /root/.msmtprc
Copyright (C) 2007 Martin Lambers and others.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License .
There is NO WARRANTY, to the extent permitted by law.
3、配置一下msmtp的配置文件
[root@server etc]# more msmtprc
# Set default values for all following accounts.
defaults
logfile /opt/msmtp/log/msmtp.log -------该文件要存在,不然没有日志
# The SMTP server of the provider.
account sohu
host smtp.sohu.com
from your_account@sohu.com
auth login -------这个要为login,似乎on不行
user your_account
password your_password
# Set a default account
account default : sohu
到这儿时,最好先测试一下
/opt/msmtp/bin/msmtp yehaozi@gmail.com
hello,test
ctrl d
tail -f /opt/msmtp/log/msmtp.log 看看有没有成功。
然后再进入到上面的邮件中,看看信收到没有
4、配置mutt
我原来在网上一直看到mutt msmtp发送邮件,我不想装mutt。(汗啊,后面才发现系统已经装了)。一直在找怎么使用msmtp自己来发邮件,邮件可以发,不过功能实在是太少了。那就用已经安装好了的mutt.
[root@server bin]# tail -5 /etc/Muttrc
set sendmail="/opt/msmtp/bin/msmtp"
set realname="actor"
set use_from=yes
set editor="vi"
5、现在都已经搞定了,开始测试看看
[root@server bin]# echo "测试一下" | mutt -s "治理信息" test@gmail.com