Tuesday, October 22, 2013

Install Python 3 on CentOS 6.4 minimal


Install Python 3 on CentOS 6.4 minimal
Environment: CentOS6.4 minimal


Require Package (C Complier)
#yum groupinstall "Development Tools"

Go to desired path for store the downloaded file. e.g.
#cd /tmp

Download Python 3.3.1
#wget http://python.org/ftp/python/3.3.1/Python-3.3.1.tar.bz2
Latest Version: https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

unzip into current directory
#tar xf Python-3.3.1.tar.bz2

Configure Script
#cd Python-3.3.1
#./configure --prefix=/usr/local


Install
#make 
or
#make altinstall

PS: 
For the version 3.4, pip is included in Python package. 
You may get the following error, which means you have not install "Development Tools" well
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS


Check if installed
#python3.3 --version


Optional:
There are python2.6 & 3.3.1 in my CentOS concurrently.
When I call "python", the version is 2.6.
I would like change it instead of typing in "python3.3" every time, so just link it up as below
PS: The path may be different.
#ln -sf /usr/local/bin/python3.3 /usr/bin/python

Don't do the strike through procedure above, it will make "yum install" crash.


延伸閱讀 Extended Reading
Why need to install C Compiler?
"Configure" Script checks the dependencies. C compiler is required in the installation procedure.

What the difference between "make install" & "make altinstall"?
"make altinstall" avoids the conflict with the current and existing package in OS

What is the parameter "xf xvf" of TAR?
x means "Extract"
v means "be verbose" (list files being processed)
f means "to file"

here is some basic options...

       Operations:
       [-]c --create
       [-]d --diff --compare
       [-]r --append
       [-]t --list
       [-]u --update
       [-]x --extract --get       

       Common Options:
       -C, --directory DIR
       -f, --file F
       -v, --verbose
       -z, --gzip


The details of the parameter & common option, please refer to the damn boring GNU manual below
http://www.gnu.org/software/tar/manual/html_chapter/Tutorial.html#SEC10




 

Sunday, July 28, 2013

Backup & Restore MySQL database


Backup & Restore MySQL Database
Environment: MySQL 5


Backup - All Databases
#mysqldump -u root -p --all-databases > /tmp/AllDatabase.sql


Backup - Single Database
#mysqldump -u root -p YourDbName > /tmp/database.sql


Backup - Single Table
#mysqldump -u root -p YourDbName YourTableName> /tmp/table.sql


Restore- Single Table
#mysql -u root -p YourDbName < /tmp/table.sql
 

Sunday, March 17, 2013

Run own script on Linux startup


Run own script on Linux startup
Environment: Ubuntu 12.04

Reference Link:
https://help.ubuntu.com/community/UbuntuBootupHowto


Make the script executable
#sudo chmod +x /etc/init.d/myscript.sh

Make the script run on startup
#sudo update-rc.d myscript.sh defaults 98 02

98 is the start sequence numbers
02 is stop sequence numbers

Both are numbers between 00 and 99
Specify how early or late a service is started or killed.

 

Sunday, March 10, 2013

Auto Login in Console Mode


Auto Login in Console Mode

Environment: Ubuntu 12.04

/* ------------------------------------------------------------Method 1

Install mingetty
#sudo apt-get install mingetty

open the tty1 conf
#sudo nano /etc/init/tty1.conf

modify the following lines:
From:
exec /sbin/getty -8 38400 tty1
To:
exec /sbin/mingetty --autologin root --noclear tty1

reboot
#sudo reboot
/* ------------------------------------------------------------End of Method 1

/* ------------------------------------------------------------Method 2

Install package
#sudo apt-get install xorg nodm

Enable Auto Login
#sudo nano /etc/default/nodm


modify the following lines:
NODM_ENABLED = true
NODM_USER = root
PS: NODM_USER is the user you want to login automatically when startup

/* ------------------------------------------------------------End of Method 2

延伸閱讀
What is getty?
wiki :  http://en.wikipedia.org/wiki/Getty_%28Unix%29
按wiki的解說,就是 "get teletype", a utility call by "init", invoke login.

而 teletype 大慨是 teletypewriter / terminal
wiki: http://en.wikipedia.org/wiki/Tty_%28Unix%29


簡單說, 就是在startup的過程裏, 會call這個getty 進行登入程序... 如果要設定成自動登入就得使用mingetty 來取代原本的getty.

那麼甚麼是 mingetty?
根據網上解釋 就是 designed to be a minimal getty for the virtual terminals on the the workstation's monitor and keyboard.

不求甚解下, 總之auto login 就用 mingetty 攪定吧.

mingetty -options as below:

--noclear
Do not clear the screen before prompting for the login name (the screen is normally cleared).
--nonewline
Do not print a newline before writing out /etc/issue.
--noissue
Do not output /etc/issue.
--nohangup
Do not call vhangup() to disable writing to this tty by other applications.
--nohostname
Do not print the hostname before the login prompt.
--long-hostname
By default the hostname is only printed until the first dot. With this option enabled, the full text from gethostname() is shown.
--loginprog /bin/login
Change the login app.
--nice 10
Change the priority by calling nice().
--delay 5
Sleep this many seconds after startup of mingetty.
--chdir /home
Change into this directory before calling the login prog.
--chroot /chroot
Call chroot() with this directory name.
--autologin username
Log the specified user automatically in without asking for a login name and password. Check the -f option from /bin/login for this.
--loginpause
Wait for any key before dropping to the login prompt. Can be combined with --autologin to save memory by lazily spawning shells.

Tuesday, January 01, 2013

轉換 EPG 由英文變中文


轉換 EPG 由英文變中文 - MCE
Environment: Windows 8 with Media Center


用英文版 windows 的話, 在使用 Media Center 接收 TV signal (DVB-TH) 取得的 EPG 會顯示英文.
但只要更改 registry, 即可以不影響介面下令 EPG 只顯示中文.



KEY:
HKLM > SOFTWARE > MICROSOFT > WINDOWS > CURRENT VERSION > MEDIA CENTER > SETTING >  MCE.GLOBALSETTINGS > systemLanguage

eng 改成 chi 即可, 如下圖