import sys form binascii import unhexlify s = unhexlify(sys.argv[1]) + unhexlify(sys.argv[2]) \ + unhexlify(sys.argv[3]) + unhexlify(sys.argv[4]) import struct result = struct.unpack_from('f', s) print result[0]
個人在學習Linux過程當中的個人筆記,提供個人及有需要的人查閱,若有錯誤歡迎提供指正,謝謝。 This Blog recorded notes about my learning Linux and provides myself and others reference. If there are any incorrect information, welcome to leave a message to correct me, Thanks.
2012年12月22日 星期六
Ascii hex (IEEE754) 轉成 flaot in python
2012年12月6日 星期四
Route setting under multi interfaces
The GATEWAY setting in ifcfg-eth0 will add a default gateway while interface starts, but may be overwrited by next started interface. To avoid this, remove the GATEWAY setting in ifcfg-eth0 and use route-eth0 file
Note. NetworkManager should be stopped
for Example, If there are two interface eth0 and eth1
ifcfg-eth0
for Example, If there are two interface eth0 and eth1
ifcfg-eth0
DEVICE=eth0 IPADDR=10.3.23.221 NETMASK=255.0.0.0 #GATEWAY=10.3.23.254ifcfg-eth1
DEVICE=eth0 IPADDR=172.18.101.2 NETMASK=255.255.0.0 #GATEWAY=172.18.254.254route-eth0
default 10.3.23.254 dev eth0route-eth1
172.16.0.0/12 via 172.18.254.254 dev eth1
2012年10月3日 星期三
Create a Package repo
1. create /var/pxe/centos6 directory
http://practical-tech.blogspot.tw/2011/10/how-to-configure-pxe-server-in-rhel-6.html
http://httpd.apache.org/docs/current/sections.html
mkdir -p /var/pxe/centos62. mount iso and copy all files into /var/pxe/centos6 and create repo
cp -ivr /media/CentOS_6.3_Final/* /var/pxe/centos6 cd /var/pxe/centos6 createrepo .3. create conf file /etc/httpd/conf.d/pxeboot.conf
Alias /centos6 /var/pxe/centos6 <Directory /var/pxe/centos6> Options Indexes FollowSymLinks AllowOverride None </Directory>4. Allow selinux httpd_sys_content_t
cd /var/pxe chcon -R -t httpd_sys_content_t './centos6'5. Restart httpd
service httpd restart6. Open browser to check "http://127.0.0.1/centos6" is available Reference:
http://practical-tech.blogspot.tw/2011/10/how-to-configure-pxe-server-in-rhel-6.html
http://httpd.apache.org/docs/current/sections.html
2012年9月27日 星期四
Install RockMongo on Ubuntu
1. Install mongodb
follow the link below to install mongodb
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
2. Install php5, php-pear
>apt-get install php5 php-pear
3. Install php-mongo
http://www.php.net/manual/en/mongo.installation.php
4. download rockmongo and the unzip and put in /var/www
http://rockmongo.com/downloads
5. restart apache2 mongodb
>service apache2 restart
>service mongodb restart
(If mongodb is locked, please check below link)
http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/
6. Login with admin/admin on http://localhost/rockmongo
(Modify config.php to change login username/password)
follow the link below to install mongodb
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
2. Install php5, php-pear
>apt-get install php5 php-pear
3. Install php-mongo
http://www.php.net/manual/en/mongo.installation.php
4. download rockmongo and the unzip and put in /var/www
http://rockmongo.com/downloads
5. restart apache2 mongodb
>service apache2 restart
>service mongodb restart
(If mongodb is locked, please check below link)
http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/
6. Login with admin/admin on http://localhost/rockmongo
(Modify config.php to change login username/password)
2012年8月30日 星期四
Disable ping response in Linux
sysctl -w net.ipv4.icmp_echo_ignore_all=1http://www.linuxarticles.org/2010/10/disable-ping-response-in-linux/
2012年8月29日 星期三
Install mongodb on Ubuntu
1. import public key
Reference: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB102. create /etc/apt/sources.list.d/10gen.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen3.
sudo apt-get update4.
sudo apt-get install mongodb-10gen
Reference: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/
tsocks
1. install epel first
http://fedoraproject.org/wiki/EPEL
1. insatll tsocks
http://fedoraproject.org/wiki/EPEL
1. insatll tsocks
yum install tsocks2. add file /etc/tsocks.conf
server = 127.0.0.1 server_type = 5 server_port = 12343. establish ssh tunnel
ssh -D 1234 user@xxx.remote.host4. wget with socks proxy
tsocks wget http://get.something5. you might want to unset the http_proxy variable
unset http_proxy
2012年7月23日 星期一
Install MediaWiki
1. Install mysql, mysql-server, httpd
#yum install mysql mysql-server httpd
2. start mysql server
#service mysqld start
3. change mysql root password
#mysqladmin ping -u root password 'newpassword'
Enter password: (just press Enter)
mysqld is alive
(The mysql root password was changed to newpassword)
4. Download MediaWiki
http://www.mediawiki.org/wiki/Download
5. Extract to /var/www/html/wiki
#cd /var/www/html
#mkdir wiki
#copy all files intol wiki foler
6. using browser open http://127.0.0.1/wiki
follow the instruction step by step to install MediaWiki
(Note. If install on CentOS 5, must install php53-common and php53-mysql)
7. Backup, using the script
http://www.mediawiki.org/wiki/User:Megam0rf/WikiBackup
schedule the script on crontab weekly
http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki
http://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup
#yum install mysql mysql-server httpd
2. start mysql server
#service mysqld start
3. change mysql root password
#mysqladmin ping -u root password 'newpassword'
Enter password: (just press Enter)
mysqld is alive
(The mysql root password was changed to newpassword)
4. Download MediaWiki
http://www.mediawiki.org/wiki/Download
5. Extract to /var/www/html/wiki
#cd /var/www/html
#mkdir wiki
#copy all files intol wiki foler
6. using browser open http://127.0.0.1/wiki
follow the instruction step by step to install MediaWiki
(Note. If install on CentOS 5, must install php53-common and php53-mysql)
7. Backup, using the script
http://www.mediawiki.org/wiki/User:Megam0rf/WikiBackup
schedule the script on crontab weekly
http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki
http://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup
2012年7月16日 星期一
install python setuptools (easy_install)
1. Download .egg from http://pypi.python.org/pypi/setuptools/ (according your python version)
2. using sh to execute .egg file
2. using sh to execute .egg file
2012年7月12日 星期四
replace new line (\n) using sed
sed ':a;N;$!ba;s/\n/ /g' filereference:
http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n
2012年6月6日 星期三
install OpenLDAP on CentOS6
1. 使用yum安裝openldap-servers(slapd)和openldap-client(ldap)
yum install openldap-servers openldap-clients
2. 編輯or產生/etc/openldap/ldap.conf
vi /etc/openldap/ldap.conf
3. 複製slapd.conf和DB_CONFIG
yum install openldap-servers openldap-clients
2. 編輯or產生/etc/openldap/ldap.conf
vi /etc/openldap/ldap.conf
URI ldap://127.0.0.1 BASE dc=my-domain,dc=com
3. 複製slapd.conf和DB_CONFIG
cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
4. slappasswd
打上欲設定的ldap server密碼,將最後一行{SSHA}xxxxxxxxx複製起來
5.編輯/etc/openldap/slapd.conf
把裡面的dc=my-domain,dc=com改成自己要的
在rootpw的地方把剛剛複製的{SSHA}xxxxx貼上去
6.建立一root.ldif檔,內容
#root |
dn: dc=my-domain,dc=com |
dc: my-domain |
objectClass: dcObject |
objectClass: organizationalUnit |
ou: my-domain.com |
7. 先把slapd.d裡的資料移除
rm -rf /etc/openldap/slapd.d/*
8. 使用slaptest將slpad.conf轉成slapd.d/
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
9. 改變檔案權限及擁有者
chown -R ldap:ldap /var/lib/ldap
chown -R ldap:ldap /etc/openldap/slapd.d
10.將slapd設為system boot up自動啟動
chkconfig slapd on
11.啟動slapd
service slapd start
12. 登入Webmin的LDAP Users and Groups (config要設好)
LDAP server uses encryption? -> Yes SSL
Bind to LDAP server as -> cn=Manager,dc=my-domain,dc=com
Credential for bind name above -> Set to "ldap server password"
13. Open port 389 TCP in firewall
Reference:
http://jamyy.dyndns.org/blog/2012/01/3506.html
13. Open port 389 TCP in firewall
Reference:
http://jamyy.dyndns.org/blog/2012/01/3506.html
2012年6月4日 星期一
nsupdate出現SERVFAIL
查看/var/log/message,因為權限的問題,所以
chown -R named:named /var/named
or
chown -R named:named /var/named/chroot/var/named
還有SELINUX預設也會擋,要關掉bind的部分 named_write_master_zones
http://en.wikipedia.org/wiki/Nsupdate
http://fedoraproject.org/wiki/SELinux/named
chown -R named:named /var/named
or
chown -R named:named /var/named/chroot/var/named
還有SELINUX預設也會擋,要關掉bind的部分 named_write_master_zones
setsebool -P named_write_master_zones 1
http://en.wikipedia.org/wiki/Nsupdate
http://fedoraproject.org/wiki/SELinux/named
2012年4月11日 星期三
yum repo setting
若出現cannot find a valid baseurl for repo的訊息
請編輯/etc/yum.repo.d/裡面的.repo檔案
把baseurl前面的#去掉
請編輯/etc/yum.repo.d/裡面的.repo檔案
把baseurl前面的#去掉
2012年4月10日 星期二
ntlmaps
1. Download ntlmaps
http://ntlmaps.sourceforge.net/
2. extract
tar xvfz ntlmaps-0.9.9.0.1.tar.gz -C /usr/local/bin
3. create soft symbolic link
ln -s /usr/local/bin/ntlmaps-0.9.9.0.1 /usr/local/bin/ntlmaps
4. Edit server.cfg
vi /usr/local/bin/ntlmaps/server.cfg
5. Run!
/usr/local/bin/ntlmaps/main.py -c /usr/local/bin/ntlmaps/server.cfg
6. Optional: Add run command into /etc/rc.local
Reference:
[1]
http://ntlmaps.sourceforge.net/
2. extract
tar xvfz ntlmaps-0.9.9.0.1.tar.gz -C /usr/local/bin
3. create soft symbolic link
ln -s /usr/local/bin/ntlmaps-0.9.9.0.1 /usr/local/bin/ntlmaps
4. Edit server.cfg
vi /usr/local/bin/ntlmaps/server.cfg
5. Run!
/usr/local/bin/ntlmaps/main.py -c /usr/local/bin/ntlmaps/server.cfg
6. Optional: Add run command into /etc/rc.local
Reference:
[1]
2012年4月5日 星期四
2012年3月14日 星期三
Eclipse設定SVN以及Mercurial
1. install EclipseMercurial
Update Site: http://cbes.javaforge.com/update
2. install SVN Connector:
Update Site: http://download.eclipse.org/technology/subversive/0.7/update-site/
(the site address might be duplicated)
(under Ubuntu)
1. install mercurial
>sudo apt-get install mercurial
2. install subversion
>sudo apt-get install subversion
Update Site: http://cbes.javaforge.com/update
2. install SVN Connector:
Update Site: http://download.eclipse.org/technology/subversive/0.7/update-site/
(the site address might be duplicated)
(under Ubuntu)
1. install mercurial
>sudo apt-get install mercurial
2. install subversion
>sudo apt-get install subversion
2012年3月8日 星期四
Mercurial: push source code on bitbucket.org
1. Register an account on bitbucket.org and create a repository named sample-repo
2. yum install mercurial
3. configure https certificate authorities. create file /etc/mercurial/hgrc contain
4. enter the path of source code, initial hg repository
> cd /path/of/source
>hg init
5. create a file .hg/hgrc contain
6. add file into repository
>hg add
7. commit repository
>hg commit
edit the file to remove some HG: prefix
8. push the repository
>hg push https://your-account@bitbucket.org/your-account/sample-repo
9. Congratulation! You can browse your code on bitbucket.org now.
Reference:
http://mercurial.selenic.com/wiki/Mercurial
http://mercurial.selenic.com/wiki/CACertificates
http://mercurial.selenic.com/wiki/QuickStart
2. yum install mercurial
3. configure https certificate authorities. create file /etc/mercurial/hgrc contain
[web] cacerts = /etc/pki/tls/certs/ca-bundle.crt
4. enter the path of source code, initial hg repository
> cd /path/of/source
>hg init
5. create a file .hg/hgrc contain
[ui] username = FirstName LastName
6. add file into repository
>hg add
7. commit repository
>hg commit
edit the file to remove some HG: prefix
8. push the repository
>hg push https://your-account@bitbucket.org/your-account/sample-repo
9. Congratulation! You can browse your code on bitbucket.org now.
Reference:
http://mercurial.selenic.com/wiki/Mercurial
http://mercurial.selenic.com/wiki/CACertificates
http://mercurial.selenic.com/wiki/QuickStart
2012年2月28日 星期二
windows安裝 python setuptools easy_install
1. Download setuptools, (setuptools-0.6c11.win32-py2.7.exe)
http://pypi.python.org/pypi/setuptools
2. Add C:\Python27\Scripts in PATH variable
3. Install compiler
http://www.microsoft.com/express/Downloads/#2008-Visual-CPP
3. try using easy_install to install some stuff
http://pypi.python.org/pypi/setuptools
2. Add C:\Python27\Scripts in PATH variable
3. Install compiler
http://www.microsoft.com/express/Downloads/#2008-Visual-CPP
3. try using easy_install to install some stuff
2012年2月9日 星期四
讓Linux可以解析到WINS下的機器
1. 在/etc/samba/smb.conf新增
[global]
wins server = ip
2. 更改/etc/nsswitch.conf 的hosts解析方式增加wins
hosts: wins dns files
參考資料:
https://bbs.et8.net/bbs/showthread.php?t=885180
[global]
wins server = ip
2. 更改/etc/nsswitch.conf 的hosts解析方式增加wins
hosts: wins dns files
參考資料:
https://bbs.et8.net/bbs/showthread.php?t=885180
2012年2月7日 星期二
Install freeradius2 on CentOS
1. using yum install freeradius2 and freeradius2-utils (CentOS 5.X)
#yum install freeradius2 freeradius2-utils
CentOS 6.X:
package name is freeradius and freeradius-utils
2. start radiusd with debug mode
#radiusd -X
or, start radiusd service
#service radiusd start
3. add a user. add following line at the top of /etc/raddb/users
4. add a accept client rule in /etc/raddb/client.conf:
client 192.168.0.0/24 {
secret = testing123
shortname = private-network
}
5. restart the radiusd
#service radiusd restart
6. try the user testing is acceptable
(If show Access-Accept, It success.
If show "radclient:: Failed to find IP address for XXX", That mean radclient can't resolve XXX, add a line to /etc/hosts likes "127.0.0.1 XXX" or setup DNS correctly)
7. try the user testing from remote client
reference:
http://freeradius.org/doc/
http://tec1021.pixnet.net/blog/post/28639573-%E8%BC%95%E9%AC%86%E6%9E%B6%E5%A5%BDradius%E4%BC%BA%E6%9C%8D%E5%99%A8~
#yum install freeradius2 freeradius2-utils
CentOS 6.X:
package name is freeradius and freeradius-utils
2. start radiusd with debug mode
#radiusd -X
or, start radiusd service
#service radiusd start
3. add a user. add following line at the top of /etc/raddb/users
testing Cleartext-Password := "password"
4. add a accept client rule in /etc/raddb/client.conf:
client 192.168.0.0/24 {
secret = testing123
shortname = private-network
}
5. restart the radiusd
#service radiusd restart
6. try the user testing is acceptable
$ radtest testing password 127.0.0.1 0 testing123
(If show Access-Accept, It success.
If show "radclient:: Failed to find IP address for XXX", That mean radclient can't resolve XXX, add a line to /etc/hosts likes "127.0.0.1 XXX" or setup DNS correctly)
7. try the user testing from remote client
$ radtest testing password 192.168.1.1 0 testing123
reference:
http://freeradius.org/doc/
http://tec1021.pixnet.net/blog/post/28639573-%E8%BC%95%E9%AC%86%E6%9E%B6%E5%A5%BDradius%E4%BC%BA%E6%9C%8D%E5%99%A8~
2012年1月6日 星期五
Install Celery on CentOS6
1. insall epel (ref-link)
2. install erlang
#yum install erlang
3. install rabbitmq
a. download rabbitmq rpm (link)
b. install:
#rpm -Uvh rabbitmq-xxxx.rpm
c. let rabbitmq daemon auto-start on boot up:
#chkconfig rabbitmq-server on
d. start rabbitmq server:
#service rabbitmq-server start
4. install Celery
#easy_install Celery
5. install django-celery
#easy_install django-celery
6. setting up django-celery on project (link)
2. install erlang
#yum install erlang
3. install rabbitmq
a. download rabbitmq rpm (link)
b. install:
#rpm -Uvh rabbitmq-xxxx.rpm
c. let rabbitmq daemon auto-start on boot up:
#chkconfig rabbitmq-server on
d. start rabbitmq server:
#service rabbitmq-server start
4. install Celery
#easy_install Celery
5. install django-celery
#easy_install django-celery
6. setting up django-celery on project (link)
訂閱:
文章 (Atom)