<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3647922545077012977</id><updated>2011-12-23T12:44:53.356-08:00</updated><category term='* Blog Index *'/><category term='Python'/><category term='Unix Power Tools'/><category term='**Gauge Unix Skill Level**'/><category term='Unix Internal'/><category term='Linux Administration (Ubuntu RHEL)'/><category term='* My Blog Pages Ranked Top 10 in Google *'/><category term='DNS NIS NFS Kerberos LDAP etc'/><category term='Scripting ( Shell Perl Python)'/><category term='Desktop - vim cygwin mintty firefox etc'/><category term='TCP/IP Protocols and Security'/><category term='Solaris 10 Administration'/><category term='Web Admin - Apache Tomcat Weblogic Java'/><category term='Visitor Tracking Report'/><category term='Unix System Programming (C Python)'/><category term='AIX Administration'/><title type='text'>Shan's "Fix IT in 1 Minute!" UNIX Admin Blog</title><subtitle type='html'>Welcome to &amp;quot;Fix IT in 1 Minute!&amp;quot; - Shan Jing&amp;#39;s IT Blog. Topics include: Linux, Solaris, AIX Administrations, Python Programming, Shell Scripting, TCP/IP Protocols and Services (NFS, DNS, NIS, Kerberos, SSH, etc.).</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://shanit.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>83</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5129792333708844287</id><published>2011-05-14T21:00:00.000-07:00</published><updated>2011-05-19T13:39:29.664-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Always look on the bright side of Life!</title><content type='html'>&lt;span style="font-style: italic;"&gt;The best chapter of book 'Learning Python'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:times new roman;"&gt;"Once you finish the quiz, you’ve officially reached the end of this book. Now that you&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;know Python inside and out, your next step, should you choose to take it, is to explore&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;the libraries, techniques, and tools available in the application domains in which you&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;work. Because Python is so widely used, you’ll find ample resources for using it in&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;almost any application you can think of—from GUIs, the Web, and databases to numeric&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;programming, robotics, and system administration.&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:times new roman;font-size:130%;"  &gt;This is where Python starts to become truly fun, but this is also where this book’s story&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:times new roman;"&gt;ends, and others’ begin. For pointers on where to turn after this book, see the list of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;recommended follow-up texts in the Preface. Good luck with your journey.  And of course,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;“&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 153, 102);font-family:courier new;font-size:130%;"  &gt;Always look on the bright side of Life!&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:times new roman;"&gt;”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;-Mark Lutz, the author of "&lt;a href="http://www.amazon.com/Learning-Python-Second-Mark-Lutz/dp/0596002815"&gt;Learning Python&lt;/a&gt;"&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-5J1BkNe4MFs/TdV_3FHNbNI/AAAAAAAAC3U/clBpXrN_HGU/s1600/python_logo.jpg"&gt;&lt;img style="cursor: pointer; width: 222px; height: 302px;" src="http://1.bp.blogspot.com/-5J1BkNe4MFs/TdV_3FHNbNI/AAAAAAAAC3U/clBpXrN_HGU/s400/python_logo.jpg" alt="" id="BLOGGER_PHOTO_ID_5608529495201770706" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-5129792333708844287?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5129792333708844287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5129792333708844287'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2011/05/best-part-of-book-learning-python.html' title='Always look on the bright side of Life!'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-5J1BkNe4MFs/TdV_3FHNbNI/AAAAAAAAC3U/clBpXrN_HGU/s72-c/python_logo.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-224793415359410770</id><published>2011-03-30T14:44:00.000-07:00</published><updated>2011-03-30T20:20:39.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Configuring Python Matplotlib plot to GUI/X and Configuring TK for Python</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/-SYZLKCCfEK0/TZOkvjT_5kI/AAAAAAAAC3M/0l5CyLmhBIc/s1600/matplot1.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://3.bp.blogspot.com/-SYZLKCCfEK0/TZOkvjT_5kI/AAAAAAAAC3M/0l5CyLmhBIc/s400/matplot1.bmp" alt="" id="BLOGGER_PHOTO_ID_5589992699336844866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-gKDbbRrQg5c/TZOklT7p0lI/AAAAAAAAC3E/M8CYuJC9NMI/s1600/matplotlib..JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 263px;" src="http://4.bp.blogspot.com/-gKDbbRrQg5c/TZOklT7p0lI/AAAAAAAAC3E/M8CYuJC9NMI/s400/matplotlib..JPG" alt="" id="BLOGGER_PHOTO_ID_5589992523409510994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-HZ5U-qJ7xGU/TZOkgsclOaI/AAAAAAAAC28/ZhZCYNrujs4/s1600/matplotlib3.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 263px;" src="http://1.bp.blogspot.com/-HZ5U-qJ7xGU/TZOkgsclOaI/AAAAAAAAC28/ZhZCYNrujs4/s400/matplotlib3.JPG" alt="" id="BLOGGER_PHOTO_ID_5589992444090726818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To configure Python Matplotlib to display to GUI/X. You need to configure Matplotlib backend to be 'TKAgg' (default is Agg).&lt;br /&gt;&lt;br /&gt;Problem:&lt;br /&gt;Most Python compilers delivered with major Linux distributions don't have tcl/tk configured during the build. To test, try 'import Tkinter' in your Python.  The underlying shared object is _tkinter.so. Tkinter is required by Matplotlib to enable TKAgg backend.&lt;br /&gt;&lt;br /&gt;If your Python is not configured for Tk, you will need to rebuild Python compiler with tcl/tk and possibly rebuild matplotlib.&lt;br /&gt;&lt;br /&gt;The key of configuring tcl/tk for Python compiler is to include tcl/tk header files while building Python compiler.&lt;br /&gt;&lt;br /&gt;If you don't have root on the system, the best way is to download tcl/tk. Otherwise, you can just rpm tcl/tk devel RPMs. In either cases, you should install the correct version of header files as your system tcl/tk binary/libs.&lt;br /&gt;&lt;br /&gt;Below are the detail steps to build everything from source code, it takes about 1 hour.&lt;br /&gt;&lt;br /&gt;1. Build tcl  8.4.13&lt;br /&gt;Download at:&lt;br /&gt;http://www.linuxfromscratch.org/blfs/view/6.2.0/general/tcl.html&lt;br /&gt;use --prefix to install at a non-standard location, e.g.&lt;br /&gt;./configure --prefix=/home/sjing/tools&lt;br /&gt;&lt;br /&gt;2. Build tk&lt;br /&gt;&lt;br /&gt;Download at: http://www.linuxfromscratch.org/blfs/view/6.2.0/general/tk.html&lt;br /&gt;use ./configure --prefix to install at a non-standard location, e.g.&lt;br /&gt;./configure --prefix=/home/sjing/tools&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Build Python with tkinter and Unicode4 (check your current system python compiler's ucs setting, see Reference 1 below. This will ensure your new Python compiler is compatible with your system's)&lt;br /&gt;./configure --enable-unicode=ucs4 --prefix=/home/sjing/tools&lt;br /&gt;&lt;br /&gt;To include tcl/tk in Python, you need to compile Python with tcl/tk header files in  the -I path.&lt;br /&gt;&lt;br /&gt;If you download tcl/tk from the above sites (step 1, 2), please edit Makefile and add tcl.h/tk.h headers path in CPPFLAGS macro&lt;br /&gt;&lt;br /&gt;for example:  assume /home/sjing/tools/include has tk.h andtcl.h from step 1 and 2.&lt;br /&gt;&lt;br /&gt;CPPFLAGS=   -I. -I$(srcdir)/Include -I/home/sjing/tools/include&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-bash-3.2$ rpm -qa | grep ^tk&lt;br /&gt;tk-devel-8.4.13-5.el5_1.1&lt;br /&gt;tk-8.4.13-5.el5_1.1&lt;br /&gt;tk-devel-8.4.13-5.el5_1.1&lt;br /&gt;tk-8.4.13-5.el5_1.1&lt;br /&gt;-bash-3.2$ rpm -qa | grep ^tcl&lt;br /&gt;tcl-8.4.13-4.el5&lt;br /&gt;tcl-devel-8.4.13-4.el5&lt;br /&gt;tcl-8.4.13-4.el5&lt;br /&gt;tclx-8.4.0-5.fc6&lt;br /&gt;tcl-devel-8.4.13-4.el5&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Once make can find the header files, build it and see the process of&lt;br /&gt;building _tkinter.so file.&lt;br /&gt;&lt;br /&gt;-------------&lt;br /&gt;make&lt;br /&gt;&lt;br /&gt;building '_tkinter' extension&lt;br /&gt;gcc -pthread -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -fno-strict-aliasing -DWITH_APPINIT=1 -I/usr/X11/include -I. -I/home/sjing/downloads/Python-2.4.3/./Include -I/home/sjing/tools/include -I/usr/local/include -I/home/sjing/downloads/Python-2.4.3/Include -I/home/sjing/downloads/Python-2.4.3 -c /home/sjing/downloads/Python-2.4.3/Modules/_tkinter.c -o build/temp.linux-x86_64-2.4/_tkinter.o&lt;br /&gt;gcc -pthread -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -fno-strict-aliasing -DWITH_APPINIT=1 -I/usr/X11/include -I. -I/home/sjing/downloads/Python-2.4.3/./Include -I/home/sjing/tools/include -I/usr/local/include -I/home/sjing/downloads/Python-2.4.3/Include -I/home/sjing/downloads/Python-2.4.3 -c /home/sjing/downloads/Python-2.4.3/Modules/tkappinit.c -o build/temp.linux-x86_64-2.4/tkappinit.o&lt;br /&gt;gcc -pthread -shared build/temp.linux-x86_64-2.4/_tkinter.o build/temp.linux-x86_64-2.4/tkappinit.o -L/usr/X11/lib -L/home/sjing/tools/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o build/lib.linux-x86_64-2.4/_tkinter.so&lt;br /&gt;--------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Build matplotlib&lt;br /&gt;Edit setupext.py and add tcl/tk location in 'basdir' dictionary.&lt;br /&gt;(x84_64 bit uses 'linux2' key)&lt;br /&gt;50 basedir = {&lt;br /&gt;...&lt;br /&gt;57     'linux2'  : ['/usr/local', '/usr','/home/sjing/tools'],&lt;br /&gt;...&lt;br /&gt;78 }&lt;br /&gt;&lt;br /&gt;To confirm Tkinter will be built with matplotlib.&lt;br /&gt;Make sure you use the Python compiler you just built with tcl/tk by adding the path of Python in front of your old python path.&lt;br /&gt;&lt;br /&gt;-bash-3.2$ export PATH=/home/sjing/tools/bin:$PATH&lt;br /&gt;( or /home/sjing/tools/bin/python setup.py build )&lt;br /&gt;&lt;br /&gt;-bash-3.2$ python setup.py build&lt;br /&gt;basedirlist is: ['/usr/local', '/usr', '/home/sjing/tools']&lt;br /&gt;============================================================================&lt;br /&gt;BUILDING MATPLOTLIB&lt;br /&gt;matplotlib: 1.0.1&lt;br /&gt;  python: 2.4.3 (#1, Mar 29 2011, 14:57:37)  [GCC 4.1.2&lt;br /&gt;          20080704 (Red Hat 4.1.2-48)]&lt;br /&gt;platform: linux2&lt;br /&gt;&lt;br /&gt;REQUIRED DEPENDENCIES&lt;br /&gt;   numpy: 1.2.0&lt;br /&gt;freetype2: 9.10.3&lt;br /&gt;&lt;br /&gt;OPTIONAL BACKEND DEPENDENCIES&lt;br /&gt;  libpng: 1.2.10&lt;br /&gt; Tkinter: Tkinter: 39220, Tk: 8.4, Tcl: 8.4&lt;br /&gt;&lt;br /&gt;Install matplotlib module:&lt;br /&gt;-bash-3.2$ python setup.py install --prefix=/home/sjing/tools&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. Download matplotlib examples at http://matplotlib.sourceforge.net/examples/index.html&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;run the examples that use tk&lt;br /&gt;animation example code: animate_decay_tk_blit.py&lt;br /&gt;mplot3d example code: 2dcollections3d_demo.py&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. As long as your newly build and system python compilers are the same version and build with the same paramters (ucs), you should be able to run all your existing python codes/modules with the new compiler.  But the best way is your System Adminsitrator update the system wide Python compile with tcl/tk following this guide.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reference 1:&lt;br /&gt;&lt;br /&gt;To check your Python is built with ucs2 or ucs4&lt;br /&gt;1. ucs4&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; import sys&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print sys.maxunicode&lt;br /&gt;1114111&lt;br /&gt;&lt;br /&gt;2. ucs2&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; import sys&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print sys.maxunicode&lt;br /&gt;65535&lt;br /&gt;&lt;br /&gt;Reference 2:&lt;br /&gt;&lt;br /&gt;matplotlibrc (lines defining backend and interactive mode)&lt;br /&gt;--------------------------------------&lt;br /&gt;backend      : TKAgg&lt;br /&gt;backend_fallback: True&lt;br /&gt;interactive  : False&lt;br /&gt;------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-224793415359410770?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/224793415359410770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/224793415359410770'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2011/03/configuring-python-matplotlib-displays.html' title='Configuring Python Matplotlib plot to GUI/X and Configuring TK for Python'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-SYZLKCCfEK0/TZOkvjT_5kI/AAAAAAAAC3M/0l5CyLmhBIc/s72-c/matplot1.bmp' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8630107084869918163</id><published>2011-03-28T11:23:00.000-07:00</published><updated>2011-03-28T11:42:19.600-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix System Programming (C Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Memcache and Binary Protocol</title><content type='html'>A very good &lt;a href="http://code.google.com/p/memcached/wiki/TutorialCachingStory"&gt;Memcache Story&lt;/a&gt; explains memcache basic.&lt;br /&gt;&lt;br /&gt;Article about &lt;a href="http://code.google.com/p/memcached/wiki/MemcacheBinaryProtocol"&gt;binary protocol&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8630107084869918163?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8630107084869918163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8630107084869918163'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2011/03/memcache-story.html' title='Memcache and Binary Protocol'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8586550667851954750</id><published>2011-02-15T10:08:00.001-08:00</published><updated>2011-04-05T13:30:38.213-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>bash login profiles for all scenarios</title><content type='html'>&lt;pre&gt;When invoked as bash (not sh) the start-up files that bash reads for a&lt;br /&gt;login shell are, in order:&lt;br /&gt;&lt;br /&gt;i) /etc/profile&lt;br /&gt;&lt;br /&gt;and then the first of any of the following that exists:&lt;br /&gt;&lt;br /&gt;ii) ~/.bash_profile OR&lt;br /&gt;iii) ~/.bash_login OR&lt;br /&gt;iv) ~/.profile&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Non-login interactive bash shells (when changing or starting new shells&lt;br /&gt;during a session) read only ~/.bashrc.&lt;br /&gt;&lt;br /&gt;Non-login non-interactive bash shells (ie-when launched from inside a&lt;br /&gt;script) check the startup file in $BASH_ENV, or $ENV if that doesn't&lt;br /&gt;exist.&lt;br /&gt;&lt;br /&gt;An easy way to make sure all three invocations of bash reference the same&lt;br /&gt;start-up file is:&lt;br /&gt;&lt;br /&gt;i) use .bashrc as your customized startup file&lt;br /&gt;&lt;br /&gt;ii) create a .bash_profile containing only:&lt;br /&gt;&lt;br /&gt; export BASH_ENV=~/.bashrc&lt;br /&gt; if [ -f ~/.bashrc ]; then source ~/.bashrc; fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This way, after reading /etc/profile a login shell will read the first&lt;br /&gt;file found, ~/.bash_profile, which in turn reads ~/.bashrc&lt;br /&gt;&lt;br /&gt;Non-login interactive shells will read ~/.bashrc as usual&lt;br /&gt;&lt;br /&gt;Non-login non-interactive shells will read the ~/.bashrc assigned in&lt;br /&gt;$BASH_ENV.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reference 1: BASH's sourcing profiles order in execution&lt;br /&gt;&lt;br /&gt;[sjing@prodpmcf151 ~]$ bash -cx 'env'&lt;br /&gt;+ '[' -f /etc/bashrc ']'&lt;br /&gt;+ source /etc/bashrc&lt;br /&gt;++ '[' 17934 -gt 99 ']'&lt;br /&gt;+++ id -gn&lt;br /&gt;+++ id -un&lt;br /&gt;++ '[' techdept = sjing ']'&lt;br /&gt;++ umask 022&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ shopt -q login_shell&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/colorls.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/colorls.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/glib2.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/glib2.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/gnome-ssh-askpass.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/gnome-ssh-askpass.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/krb5-workstation.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/krb5-workstation.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/lang.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/lang.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/less.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/less.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/vim.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/vim.sh&lt;br /&gt;++ for i in '/etc/profile.d/*.sh'&lt;br /&gt;++ '[' -r /etc/profile.d/which-2.sh ']'&lt;br /&gt;++ '[' '' ']'&lt;br /&gt;++ . /etc/profile.d/which-2.sh&lt;br /&gt;++ unset i&lt;br /&gt;++ unset pathmunge&lt;br /&gt;+ '[' '!' 1 ']'&lt;br /&gt;+ env&lt;br /&gt;&lt;br /&gt;Reference 2: &lt;a href="http://www.cl.cam.ac.uk/%7Emgk25/unicode.html"&gt;UNIX/LINUX UNICODE FAQ&lt;/a&gt;&lt;br /&gt;Reference 3: &lt;a href="http://content.hccfl.edu/pollock/unix/findcmd.htm"&gt;Useful 'find' Page&lt;/a&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8586550667851954750?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8586550667851954750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8586550667851954750'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2011/02/bash-login-profiles-for-all-scenarios.html' title='bash login profiles for all scenarios'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7014860852471182421</id><published>2010-10-03T10:52:00.001-07:00</published><updated>2010-10-03T10:52:32.952-07:00</updated><title type='text'>Blog Index</title><content type='html'>&lt;p style="font-weight: bold;"&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;&lt;/p&gt;&lt;p style="font-weight: bold; color: rgb(255, 0, 0);"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Gauge Your Unix Skill Level!&lt;/a&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;Python Debugging Tips for pdb and IPython/ipdb&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;ul style="font-weight: bold;"&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/08/python-check-python-syntax-with-m.html"&gt;Python Check Syntax with -m Switch&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-ipython-and-ipdb.html"&gt;Python Debugging in ipython and ipdb&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;Python Debugging in pdb and setup &lt;/a&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;breakpoints&lt;/a&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt; from Python code&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/11/jump-between-your-code-and-python.html"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/vimrc-for-python.html"&gt;.vimrc for Python (vim settings for Python)&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style="font-weight: bold;"&gt;Solaris Administrations&lt;/p&gt;&lt;ul&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/solaris-svm-quick-reference.html"&gt;Solaris Volume Manager Quick Reference&lt;/a&gt; &lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/fix-solaris-10-smf-related-errors-in-1.html"&gt;Fix Solaris 10 SMF Errors in 1 Minute!&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-managing-network-service-via.html"&gt;Solaris 10 SMF for Network Services&lt;/a&gt; &lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/implement.html"&gt;Implement a Basic Solaris Jumpstart Server&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-jumpstart-1.html"&gt;Solaris Jumpstart Client Boot Sequence&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/troubleshoot-solaris-jumpstart.html"&gt;Troubleshoot Solaris Jumpstart&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/solaris-nfs.html"&gt;Solaris NFS Server &lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/nfs-quick-setup.html"&gt;Solaris NFS Client&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-syslog.html"&gt;Solaris Syslog&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-swap.html"&gt;Solaris Swap Configuration&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-nscd.html"&gt;Solaris NSCD&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-crashdumps.html"&gt;Solaris Crash Dump Administration&lt;/a&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-autofs.html"&gt;Solaris AutoFS&lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;Solaris Remote Procedure Call&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2010/05/solaris-10-performance-tuning-cpu_17.html"&gt;Solaris 10 Performance Tuning - Analyzing CPU&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;AIX Administrations&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-adjust-vritual-memory-paging.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Adjust Vritual Memory Paging Settings for Optimal ASE Performance&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-checkpoints.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Checkpoints&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-breaking-root-disk-mirrors-for-os.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Breaking Root Disk Mirrors for OS Upgrade&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-boot-related-administration-notes_18.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Boot Related Administration Notes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-mirrorring-rootdisk.html"&gt;AIX Mirrorring Rootdisk&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-paging-space-management.html"&gt;AIX Paging Space Management&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;strong&gt;Linux Administrations&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-rpm-and-open-source-development.html"&gt;&lt;strong&gt;Linux RPM and Open-Source Development Tools&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-ext3-quick-guide.html"&gt;&lt;strong&gt;Linux Filesystem Ext3/Ext2 Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-nfs-quickguide.html"&gt;&lt;strong&gt;Linux NFS Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;&lt;strong&gt;Linux Portmapper/RPC Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-performance-tuning-1.html"&gt;&lt;strong&gt;Linux Performance Tuning, Kernel Tuning Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-security-1.html"&gt;&lt;strong&gt;Linux System Security Part 1&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understands-openssl-and-public-key.html"&gt;&lt;strong&gt;Linux Openssl Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understand-ssh-agent-forwarding-in-1.html"&gt;&lt;strong&gt;Linux OpenSSH Agent Forwarding Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;&lt;strong&gt;Linux Generating Certificate for Apache&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/setup-kerberos-kds-in-1-minute.html"&gt;&lt;strong&gt;Linux Compile and Setup Kerberos Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html"&gt;&lt;strong&gt;Installing Ubuntu 9.10 on Vmware Host&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;strong&gt;Perl, Shell Scriptings&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;&lt;strong&gt;Compiling and Installing Net::SSH::Perl - SSH Module for Perl&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;&lt;strong&gt;Perl Regular Expression Summary&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/troubleshooting-perls-dbdmysql.html"&gt;&lt;strong&gt;Accessing MySQL Database with Perl DBD:DBI&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/auto-fetch-webpagessign-in-websites.html"&gt;&lt;strong&gt;Auto Sign-in Websites/Auto Fetch Webpages with Curl and Perl&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/advanced-shell-part-1.html"&gt;&lt;strong&gt;Shell Scripting Part 1&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/interesting-tasks-for-shell-scripting.html"&gt;&lt;strong&gt;Shell Scripting Challenging Tasks&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;&lt;/a&gt;&lt;/p&gt;&lt;strong&gt;&lt;br /&gt;Web (Apache, Weblogic, Tomcat)&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/weblogic-setup-quick-guide.html"&gt;&lt;strong&gt;Weblogic Setup Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/installing-modjk-in-1-minute.html"&gt;&lt;strong&gt;Installing modjk Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;&lt;strong&gt;Generating SSL Certificate for Apache Web Server&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;TCP/IP&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/tcp-connection-states-vs-netstat-output.html"&gt;&lt;strong&gt;Understanding TCP Connection States&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/understanding-tcp-headers-in-1-minute.html"&gt;&lt;span style="font-weight: bold;"&gt;Understanding TCP Headers in 1 Minute!&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/tcpip-3-way-handshake.html"&gt;Data Encapsulation&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/dns-security-in-1-minute.html"&gt;Understanding DNS Security in 1 Minute!&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/analyzing-arp-weakness-in-1-minute.html"&gt;Analyzing ARP Weakness in 1 Minute!&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/understanding-ethernet-and-ip-in-1.html"&gt;Understanding Ethernet and ARP Security in 1 Minute!&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Unix Internal and System Programming (C, Perl, Python)&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/unix-file-and-directory-properties.html"&gt;&lt;strong&gt;Files and Directories&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/understanding-unix-terminal-and-devices.html"&gt;&lt;strong&gt;Terminal and Devices&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/understand-unix-processes-in-1-minute.html"&gt;&lt;strong&gt;Processes &lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/unix-process-control.html"&gt;&lt;strong&gt;Process Control&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/io-redirection-and-pipes.html"&gt;&lt;strong&gt;I/O Redirection and Pipes&lt;/strong&gt;&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Vim,mintty,vimshell, ubuntu, etc.&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html"&gt;Installing Ubuntu 9.1 in vmware virtual host&lt;/a&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Kerberos, NIS, DNS, NFS, etc.&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/10/setup-kerberos-kds-in-1-minute.html"&gt;Compile and Setup Open Source Kerberos KDC&lt;br /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/setup-nis-environment-in-1-minute.html"&gt;Compile and Setup Open Source NIS&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Veritas Volume Manager and Veritas Cluster Server (VCS)&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Open Source Projects&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://hadoop.apache.org/"&gt;Hadoop/MapReduce&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; (Cloud Computing)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://www.sos-berlin.com/modules/cjaycontent/index.php?id=osource_scheduler_introduction_en.htm"&gt;Job Scheduler &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fresh Catches of the Day&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a style="font-weight: bold;" href="http://www.vim.org/scripts/script.php?script_id=2771"&gt;vim Conque Shell&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; (run bash, ipython, pdb inside vim!)&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7014860852471182421?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7014860852471182421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7014860852471182421'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/10/blog-index.html' title='Blog Index'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5641378339046576497</id><published>2010-08-27T09:52:00.000-07:00</published><updated>2010-08-27T10:12:03.669-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Python: Check Python Syntax with -m Switch</title><content type='html'>Use Python -m switch and py_compile module to check Python syntax.&lt;br /&gt;&lt;br /&gt;Python code with error at line 11&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  1 #!/usr/bin/python&lt;br /&gt;  2&lt;br /&gt;  3 import os&lt;br /&gt;  4 import time&lt;br /&gt;  5&lt;br /&gt;  6 prcfile="/home/sjing/prod/man/python/batch_cf/tmpfile"&lt;br /&gt;  7 while True:&lt;br /&gt;  8     fsize=int(os.path.getsize(prcfile))&lt;br /&gt;  9     print "file %s size is : %d" % (prcfile,fsize)&lt;br /&gt; 10     time.sleep(10)&lt;br /&gt; 11     if fsize == int(os.path.getsize(prcfile))&lt;br /&gt; 12         print "transaction is done. Exit\n"&lt;br /&gt; 13         break&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;-bash-3.2$ python -m py_compile test.py&lt;br /&gt;  File "test.py", line 11&lt;br /&gt;    if fsize == int(os.path.getsize(prcfile))&lt;br /&gt;                                             ^&lt;br /&gt;SyntaxError: invalid syntax&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;python -v will disply module initialization message:&lt;br /&gt;&lt;br /&gt;-bash-3.2$ python -v -m py_compile test.py&lt;br /&gt;# installing zipimport hook&lt;br /&gt;import zipimport # builtin&lt;br /&gt;# installed zipimport hook&lt;br /&gt;# /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.pyc matches /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.py&lt;br /&gt;import site # precompiled from /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.pyc&lt;br /&gt;import imp # builtin&lt;br /&gt;# /usr/lib64/python2.4/os.pyc matches /usr/lib64/python2.4/os.py&lt;br /&gt;import os # precompiled from /usr/lib64/python2.4/os.pyc&lt;br /&gt;import posix # builtin&lt;br /&gt;# /usr/lib64/python2.4/posixpath.pyc matches /usr/lib64/python2.4/posixpath.py&lt;br /&gt;import posixpath # precompiled from /usr/lib64/python2.4/posixpath.pyc&lt;br /&gt;# /usr/lib64/python2.4/stat.pyc matches /usr/lib64/python2.4/stat.py&lt;br /&gt;import stat # precompiled from /usr/lib64/python2.4/stat.pyc&lt;br /&gt;import errno # builtin&lt;br /&gt;# /usr/lib64/python2.4/UserDict.pyc matches /usr/lib64/python2.4/UserDict.py&lt;br /&gt;import UserDict # precompiled from /usr/lib64/python2.4/UserDict.pyc&lt;br /&gt;# /usr/lib64/python2.4/copy_reg.pyc matches /usr/lib64/python2.4/copy_reg.py&lt;br /&gt;import copy_reg # precompiled from /usr/lib64/python2.4/copy_reg.pyc&lt;br /&gt;# /usr/lib64/python2.4/types.pyc matches /usr/lib64/python2.4/types.py&lt;br /&gt;import types # precompiled from /usr/lib64/python2.4/types.pyc&lt;br /&gt;# /usr/lib64/python2.4/site.pyc matches /usr/lib64/python2.4/site.py&lt;br /&gt;import site # precompiled from /usr/lib64/python2.4/site.pyc&lt;br /&gt;import japanese # directory /usr/lib64/python2.4/site-packages/japanese&lt;br /&gt;# /usr/lib64/python2.4/site-packages/japanese/__init__.pyc matches /usr/lib64/python2.4/site-packages/japanese/__init__.py&lt;br /&gt;import japanese # precompiled from /usr/lib64/python2.4/site-packages/japanese/__init__.pyc&lt;br /&gt;import japanese.aliases # directory /usr/lib64/python2.4/site-packages/japanese/aliases&lt;br /&gt;# /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.pyc matches /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.py&lt;br /&gt;import japanese.aliases # precompiled from /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.pyc&lt;br /&gt;import encodings # directory /usr/lib64/python2.4/encodings&lt;br /&gt;# /usr/lib64/python2.4/encodings/__init__.pyc matches /usr/lib64/python2.4/encodings/__init__.py&lt;br /&gt;import encodings # precompiled from /usr/lib64/python2.4/encodings/__init__.pyc&lt;br /&gt;# /usr/lib64/python2.4/codecs.pyc matches /usr/lib64/python2.4/codecs.py&lt;br /&gt;import codecs # precompiled from /usr/lib64/python2.4/codecs.pyc&lt;br /&gt;import _codecs # builtin&lt;br /&gt;# /usr/lib64/python2.4/encodings/aliases.pyc matches /usr/lib64/python2.4/encodings/aliases.py&lt;br /&gt;import encodings.aliases # precompiled from /usr/lib64/python2.4/encodings/aliases.pyc&lt;br /&gt;# zipimport: found 10 names in /appl/mtg/dev/vendor/python/lib64/python2.4/site-packages/python_sybase-0.39-py2.4-linux-x86_64.egg&lt;br /&gt;# zipimport: found 50 names in /appl/mtg/dev/vendor/python/lib64/python2.4/site-packages/simplejson-2.0.9-py2.4-linux-x86_64.egg&lt;br /&gt;# zipimport: found 77 names in /appl/mtg/dev/vendor/html5lib/lib/python/html5lib-0.90-py2.4.egg&lt;br /&gt;# /usr/lib64/python2.4/new.pyc matches /usr/lib64/python2.4/new.py&lt;br /&gt;import new # precompiled from /usr/lib64/python2.4/new.pyc&lt;br /&gt;# /usr/lib64/python2.4/warnings.pyc matches /usr/lib64/python2.4/warnings.py&lt;br /&gt;import warnings # precompiled from /usr/lib64/python2.4/warnings.pyc&lt;br /&gt;# /usr/lib64/python2.4/linecache.pyc matches /usr/lib64/python2.4/linecache.py&lt;br /&gt;import linecache # precompiled from /usr/lib64/python2.4/linecache.pyc&lt;br /&gt;# /usr/lib64/python2.4/encodings/ascii.pyc matches /usr/lib64/python2.4/encodings/ascii.py&lt;br /&gt;import encodings.ascii # precompiled from /usr/lib64/python2.4/encodings/ascii.pyc&lt;br /&gt;Python 2.4.3 (#1, Jun 11 2009, 14:09:37)&lt;br /&gt;[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2&lt;br /&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;br /&gt;import marshal # builtin&lt;br /&gt;# /usr/lib64/python2.4/traceback.pyc matches /usr/lib64/python2.4/traceback.py&lt;br /&gt;import traceback # precompiled from /usr/lib64/python2.4/traceback.pyc&lt;br /&gt;  File "test.py", line 11&lt;br /&gt;    if fsize == int(os.path.getsize(prcfile))&lt;br /&gt;                                             ^&lt;br /&gt;SyntaxError: invalid syntax&lt;br /&gt;# clear __builtin__._&lt;br /&gt;# clear sys.path&lt;br /&gt;# clear sys.argv&lt;br /&gt;# clear sys.ps1&lt;br /&gt;# clear sys.ps2&lt;br /&gt;# clear sys.exitfunc&lt;br /&gt;# clear sys.exc_type&lt;br /&gt;# clear sys.exc_value&lt;br /&gt;# clear sys.exc_traceback&lt;br /&gt;# clear sys.last_type&lt;br /&gt;# clear sys.last_value&lt;br /&gt;# clear sys.last_traceback&lt;br /&gt;# clear sys.path_hooks&lt;br /&gt;# clear sys.path_importer_cache&lt;br /&gt;# clear sys.meta_path&lt;br /&gt;# restore sys.stdin&lt;br /&gt;# restore sys.stdout&lt;br /&gt;# restore sys.stderr&lt;br /&gt;# cleanup __main__&lt;br /&gt;# cleanup[1] japanese&lt;br /&gt;# cleanup[1] errno&lt;br /&gt;# cleanup[1] imp&lt;br /&gt;# cleanup[1] _codecs&lt;br /&gt;# cleanup[1] new&lt;br /&gt;# cleanup[1] zipimport&lt;br /&gt;# cleanup[1] warnings&lt;br /&gt;# cleanup[1] site&lt;br /&gt;# cleanup[1] signal&lt;br /&gt;# cleanup[1] traceback&lt;br /&gt;# cleanup[1] linecache&lt;br /&gt;# cleanup[1] posix&lt;br /&gt;# cleanup[1] marshal&lt;br /&gt;# cleanup[1] japanese.aliases&lt;br /&gt;# cleanup[1] encodings&lt;br /&gt;# cleanup[1] encodings.ascii&lt;br /&gt;# cleanup[1] codecs&lt;br /&gt;# cleanup[1] types&lt;br /&gt;# cleanup[1] encodings.aliases&lt;br /&gt;# cleanup[1] exceptions&lt;br /&gt;# cleanup[2] copy_reg&lt;br /&gt;# cleanup[2] posixpath&lt;br /&gt;# cleanup[2] os.path&lt;br /&gt;# cleanup[2] stat&lt;br /&gt;# cleanup[2] UserDict&lt;br /&gt;# cleanup[2] os&lt;br /&gt;# cleanup sys&lt;br /&gt;# cleanup __builtin__&lt;br /&gt;# cleanup ints: 810 unfreed ints in 21 out of 26 blocks&lt;br /&gt;# cleanup floats&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Correct the code's error and check again&lt;br /&gt;&lt;br /&gt;  1 #!/usr/bin/python&lt;br /&gt;  2&lt;br /&gt;  3 import os&lt;br /&gt;  4 import time&lt;br /&gt;  5&lt;br /&gt;  6 prcfile="/home/sjing/prod/man/python/batch_cf/tmpfile"&lt;br /&gt;  7 while True:&lt;br /&gt;  8     fsize=int(os.path.getsize(prcfile))&lt;br /&gt;  9     print "file %s size is : %d" % (prcfile,fsize)&lt;br /&gt; 10     time.sleep(10)&lt;br /&gt; 11     if fsize == int(os.path.getsize(prcfile)):&lt;br /&gt; 12         print "transaction is done. Exit\n"&lt;br /&gt; 13         break&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;-bash-3.2$ python -m py_compile test.py&lt;br /&gt;-bash-3.2$&lt;br /&gt;&lt;br /&gt;No error found.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-5641378339046576497?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5641378339046576497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5641378339046576497'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/08/python-check-python-syntax-with-m.html' title='Python: Check Python Syntax with -m Switch'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4170608720302090814</id><published>2010-06-27T18:17:00.000-07:00</published><updated>2010-08-27T10:13:57.584-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='* Blog Index *'/><title type='text'>Blog Index</title><content type='html'>&lt;p style="FONT-WEIGHT: bold"&gt;&lt;/p&gt;&lt;p style="FONT-WEIGHT: bold"&gt;&lt;/p&gt;&lt;p style="FONT-WEIGHT: bold; COLOR: rgb(255,0,0)"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Gauge Your Unix Skill Level!&lt;/a&gt;&lt;/p&gt;&lt;p style="FONT-WEIGHT: bold"&gt;Python Debugging Tips for pdb and IPython/ipdb&lt;span style="FONT-WEIGHT: bold"&gt; &lt;/span&gt;&lt;/p&gt;&lt;ul style="FONT-WEIGHT: bold"&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/08/python-check-python-syntax-with-m.html"&gt;Python Check Syntax with -m Switch&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-ipython-and-ipdb.html"&gt;Python Debugging in ipython and ipdb&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;Python Debugging in pdb and setup &lt;/a&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;breakpoints&lt;/a&gt;&lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt; from Python code&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/11/jump-between-your-code-and-python.html"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/06/vimrc-for-python.html"&gt;.vimrc for Python (vim settings for Python)&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style="FONT-WEIGHT: bold"&gt;Solaris Administrations&lt;/p&gt;&lt;ul&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/solaris-svm-quick-reference.html"&gt;Solaris Volume Manager Quick Reference&lt;/a&gt; &lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/fix-solaris-10-smf-related-errors-in-1.html"&gt;Fix Solaris 10 SMF Errors in 1 Minute!&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-managing-network-service-via.html"&gt;Solaris 10 SMF for Network Services&lt;/a&gt; &lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/implement.html"&gt;Implement a Basic Solaris Jumpstart Server&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-jumpstart-1.html"&gt;Solaris Jumpstart Client Boot Sequence&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/troubleshoot-solaris-jumpstart.html"&gt;Troubleshoot Solaris Jumpstart&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/solaris-nfs.html"&gt;Solaris NFS Server &lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/nfs-quick-setup.html"&gt;Solaris NFS Client&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-syslog.html"&gt;Solaris Syslog&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-swap.html"&gt;Solaris Swap Configuration&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-nscd.html"&gt;Solaris NSCD&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-crashdumps.html"&gt;Solaris Crash Dump Administration&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-autofs.html"&gt;Solaris AutoFS&lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;a style="FONT-WEIGHT: bold" href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;Solaris Remote Procedure Call&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2010/05/solaris-10-performance-tuning-cpu_17.html"&gt;Solaris 10 Performance Tuning - Analyzing CPU&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;AIX Administrations&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-adjust-vritual-memory-paging.html"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;AIX Adjust Vritual Memory Paging Settings for Optimal ASE Performance&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-checkpoints.html"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;AIX Checkpoints&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-breaking-root-disk-mirrors-for-os.html"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;AIX Breaking Root Disk Mirrors for OS Upgrade&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-boot-related-administration-notes_18.html"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;AIX Boot Related Administration Notes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-mirrorring-rootdisk.html"&gt;AIX Mirrorring Rootdisk&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-paging-space-management.html"&gt;AIX Paging Space Management&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;strong&gt;Linux Administrations&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-rpm-and-open-source-development.html"&gt;&lt;strong&gt;Linux RPM and Open-Source Development Tools&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-ext3-quick-guide.html"&gt;&lt;strong&gt;Linux Filesystem Ext3/Ext2 Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-nfs-quickguide.html"&gt;&lt;strong&gt;Linux NFS Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;&lt;strong&gt;Linux Portmapper/RPC Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-performance-tuning-1.html"&gt;&lt;strong&gt;Linux Performance Tuning, Kernel Tuning Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-security-1.html"&gt;&lt;strong&gt;Linux System Security Part 1&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understands-openssl-and-public-key.html"&gt;&lt;strong&gt;Linux Openssl Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understand-ssh-agent-forwarding-in-1.html"&gt;&lt;strong&gt;Linux OpenSSH Agent Forwarding Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;&lt;strong&gt;Linux Generating Certificate for Apache&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/setup-kerberos-kds-in-1-minute.html"&gt;&lt;strong&gt;Linux Compile and Setup Kerberos Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html"&gt;&lt;strong&gt;Installing Ubuntu 9.10 on Vmware Host&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;strong&gt;Perl, Shell Scriptings&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;&lt;strong&gt;Compiling and Installing Net::SSH::Perl - SSH Module for Perl&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;&lt;strong&gt;Perl Regular Expression Summary&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/troubleshooting-perls-dbdmysql.html"&gt;&lt;strong&gt;Accessing MySQL Database with Perl DBD:DBI&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/auto-fetch-webpagessign-in-websites.html"&gt;&lt;strong&gt;Auto Sign-in Websites/Auto Fetch Webpages with Curl and Perl&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/advanced-shell-part-1.html"&gt;&lt;strong&gt;Shell Scripting Part 1&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/interesting-tasks-for-shell-scripting.html"&gt;&lt;strong&gt;Shell Scripting Challenging Tasks&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;&lt;/a&gt;&lt;/p&gt;&lt;strong&gt;&lt;br /&gt;Web (Apache, Weblogic, Tomcat)&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/weblogic-setup-quick-guide.html"&gt;&lt;strong&gt;Weblogic Setup Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/installing-modjk-in-1-minute.html"&gt;&lt;strong&gt;Installing modjk Quick Guide&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;&lt;strong&gt;Generating SSL Certificate for Apache Web Server&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;TCP/IP&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/tcp-connection-states-vs-netstat-output.html"&gt;&lt;strong&gt;Understanding TCP Connection States&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/understanding-tcp-headers-in-1-minute.html"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Understanding TCP Headers in 1 Minute!&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/tcpip-3-way-handshake.html"&gt;Data Encapsulation&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/dns-security-in-1-minute.html"&gt;Understanding DNS Security in 1 Minute!&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/analyzing-arp-weakness-in-1-minute.html"&gt;Analyzing ARP Weakness in 1 Minute!&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/understanding-ethernet-and-ip-in-1.html"&gt;Understanding Ethernet and ARP Security in 1 Minute!&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Unix Internal and System Programming (C, Perl, Python)&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/unix-file-and-directory-properties.html"&gt;&lt;strong&gt;Files and Directories&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/understanding-unix-terminal-and-devices.html"&gt;&lt;strong&gt;Terminal and Devices&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/10/understand-unix-processes-in-1-minute.html"&gt;&lt;strong&gt;Processes &lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/unix-process-control.html"&gt;&lt;strong&gt;Process Control&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/io-redirection-and-pipes.html"&gt;&lt;strong&gt;I/O Redirection and Pipes&lt;/strong&gt;&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Vim,mintty,vimshell, ubuntu, etc.&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html"&gt;Installing Ubuntu 9.1 in vmware virtual host&lt;/a&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Kerberos, NIS, DNS, NFS, etc.&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;a href="http://shanit.blogspot.com/2009/10/setup-kerberos-kds-in-1-minute.html"&gt;Compile and Setup Open Source Kerberos KDC&lt;br /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/09/setup-nis-environment-in-1-minute.html"&gt;Compile and Setup Open Source NIS&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Veritas Volume Manager and Veritas Cluster Server (VCS)&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Open Source Projects&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a style="FONT-WEIGHT: bold" href="http://hadoop.apache.org/"&gt;Hadoop/MapReduce&lt;/a&gt;&lt;span style="FONT-WEIGHT: bold"&gt; (Cloud Computing)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;a href="http://www.sos-berlin.com/modules/cjaycontent/index.php?id=osource_scheduler_introduction_en.htm"&gt;Job Scheduler &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Fresh Catches of the Day&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a style="FONT-WEIGHT: bold" href="http://www.vim.org/scripts/script.php?script_id=2771"&gt;vim Conque Shell&lt;/a&gt;&lt;span style="FONT-WEIGHT: bold"&gt; (run bash, ipython, pdb inside vim!)&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4170608720302090814?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4170608720302090814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4170608720302090814'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/06/blog-index.html' title='Blog Index'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5314530370814015467</id><published>2010-06-27T17:23:00.000-07:00</published><updated>2011-03-27T15:16:58.871-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Debugging Python in ipython and ipdb</title><content type='html'>In this blog, I'm going to demonstrate some very useful features of ipython, especially when debugging python using ipdb; examining objects and step into pdb/ipdb from  Python code, etc.&lt;br /&gt;&lt;br /&gt;You should know how to use pdb to debug python, if not, please visit &lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;my other blog article&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I'll briefly describe how to exam objects and name space in iPython and then demonstrate how to debug Python in iPython/ipdb.&lt;br /&gt;&lt;br /&gt;Note: &lt;a href="http://ipython.scipy.org/moin/"&gt;a quick link to ipython&lt;/a&gt;. (make sure you come back here after reading the external page)&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;(*** Very Important ***)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;If your ipython is 0.10 or earlier version, you need to do the following to fix a bug in checkline() method in IPython/Debugger.py.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;shan@ub1:~/code$ python&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;[GCC 4.4.1] on linux2&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;&amp;gt;&amp;gt;&amp;gt; import IPython&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;&amp;gt;&amp;gt;&amp;gt; IPython.Debugger.__file__&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;'/usr/local/lib/python2.6/dist-packages/IPython/Debugger.py'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt;wget the updated Debugger.py from &lt;/span&gt;&lt;a style="COLOR: rgb(204,51,204)" href="http://bazaar.launchpad.net/%7Eipython-dev/ipython/0.10.1/download/head%3A/debugger.py-20080216095032-xb0is4a97lmosv2z-24/Debugger.py"&gt;here&lt;/a&gt;&lt;span style="COLOR: rgb(204,51,204)"&gt; and replace the above Debugger.py with the new one. That's it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let's start with examining object and name space in ipython:&lt;br /&gt;&lt;br /&gt;1. Start ipdb from ipython: (a very useful way to debug python code)&lt;br /&gt;&lt;br /&gt;First, let's start ipython&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;shan@ub1:~/code$ ipython&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Type "copyright", "credits" or "license" for more information.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;IPython 0.10 -- An enhanced Interactive Python.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;?         -&amp;gt; Introduction and overview of IPython's features.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;%quickref -&amp;gt; Quick reference.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;help      -&amp;gt; Python's own help system.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;object?   -&amp;gt; Details about 'object'. ?object also works, ?? prints more.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [1]:&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The first few lines already show the most important tricks of ipython. The problem is most people rarely read it!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, let's import test code and see some of the features python IDLE doesn't offer.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;shan@ub1:~/code$ ipython&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Type "copyright", "credits" or "license" for more information.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;IPython 0.10 -- An enhanced Interactive Python.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;?         -&amp;gt; Introduction and overview of IPython's features.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;%quickref -&amp;gt; Quick reference.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;help      -&amp;gt; Python's own help system.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;object?   -&amp;gt; Details about 'object'. ?object also works, ?? prints more.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [1]: &lt;span style="COLOR: rgb(255,255,102)"&gt;import test2&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [2]: &lt;span style="COLOR: rgb(255,255,102)"&gt;import sys&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [3]: &lt;span style="COLOR: rgb(255,255,102)"&gt;import os&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [4]: &lt;span style="COLOR: rgb(255,255,102)"&gt;who&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;os      sys     test2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [5]: &lt;span style="COLOR: rgb(255,255,102)"&gt;whos&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Variable   Type      Data/Info&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;os         module    &lt;/span&gt;&lt;module style="COLOR: rgb(255,153,102)" pyc="" 6="" lib="" usr="" from="" os=""&gt;&lt;br /&gt;sys        module    &lt;module sys=""&gt;&lt;br /&gt;test2      module    &lt;module pyc="" from="" test2=""&gt;&lt;br /&gt;&lt;br /&gt;In [6]: &lt;span style="COLOR: rgb(255,255,102)"&gt;test2?&lt;/span&gt;&lt;br /&gt;Type:           module&lt;br /&gt;Base Class:     &lt;type module=""&gt;&lt;br /&gt;String Form:    &lt;module pyc="" from="" test2=""&gt;&lt;br /&gt;Namespace:      Interactive&lt;br /&gt;File:           /home/shan/code/test2.py&lt;br /&gt;Docstring:&lt;br /&gt;&lt;no docstring=""&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In [7]: &lt;span style="COLOR: rgb(255,255,102)"&gt;test2??&lt;/span&gt;&lt;br /&gt;Type:           module&lt;br /&gt;Base Class:     &lt;type module=""&gt;&lt;br /&gt;String Form:    &lt;module pyc="" from="" test2=""&gt;&lt;br /&gt;Namespace:      Interactive&lt;br /&gt;File:           /home/shan/code/test2.py&lt;br /&gt;Source:&lt;br /&gt;#/usr/bin/env python&lt;br /&gt;&lt;br /&gt;class Employee:&lt;br /&gt;def __init__(self, name, title=None, phone=5551212):&lt;br /&gt;self.name = name&lt;br /&gt;self.title = title&lt;br /&gt;self.phone = phone&lt;br /&gt;&lt;br /&gt;def employee():&lt;br /&gt;shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;br /&gt;import pdb;pdb.set_trace()&lt;br /&gt;joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;print (shan.name, shan.title, shan.phone)&lt;br /&gt;print (joe.name, joe.title, joe.phone)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if __name__ == '__main__':&lt;br /&gt;employee()&lt;br /&gt;&lt;br /&gt;In [8]:&lt;br /&gt;&lt;/module&gt;&lt;/type&gt;&lt;/no&gt;&lt;/module&gt;&lt;/type&gt;&lt;/module&gt;&lt;/module&gt;&lt;/module&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In the above, we typed 7 commands (3 imports, who, whos, test2? and test2??):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;From the output, I'm sure you already know what each command does. But just in case you need to know the detail about these commands, type '%cmd?' in ipython. (see below). By the way, this was printed in the last line of the ipython's startup message - "object? -&amp;gt; Details about 'object'. ?? prints more details about the object."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;In [9]: %who?&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Type:           Magic function&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Base Class:     &lt;/span&gt;&lt;type instancemethod=""&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;String Form:    &lt;/span&gt;&lt;bound of="" magic_who="" method=""&gt;&lt;ipython.iplib.interactiveshell 0xb778476c="" at="" object=""&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Namespace:      IPython internal&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;File:           /usr/local/lib/python2.6/dist-packages/IPython/Magic.py&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Definition:     %who(self, parameter_s='')&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;Docstring:&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; Print all interactive variables, with some minimal formatting.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; If any arguments are given, only variables whose type matches one of&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; these are printed.  For example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;   %who function str&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; will only list functions and strings, excluding all other types of&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; variables.  To find the proper type names, simply use type(var) at a&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; command line to see how python prints type names.  For example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;   In [1]: type('hello')&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;   Out[1]: &lt;/span&gt;&lt;type str=""&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; indicates that the type name for strings is 'str'.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; %who always excludes executed names loaded through your configuration&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; file and things which are internal to IPython.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; This is deliberate, as typically you may load many modules and the&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt; purpose of %who is to show you only what you've manually defined.&lt;/span&gt;&lt;br /&gt;&lt;/type&gt;&lt;/ipython.iplib.interactiveshell&gt;&lt;/bound&gt;&lt;/type&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;whos gives extra information about an object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, let's see how to use ipython to debug our code.&lt;br /&gt;&lt;br /&gt;If you are already inside ipython, to start pdb/ipdb, all you need to do is run the code with -d option:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;In [14]: run -d test2.py&lt;br /&gt;*** Blank or comment&lt;br /&gt;*** Blank or comment&lt;br /&gt;Breakpoint 1 at /home/shan/code/test2.py:3&lt;br /&gt;NOTE: Enter 'c' at the ipdb&amp;gt;  prompt to start your script.&lt;br /&gt;&amp;gt; &lt;string&gt;(1)&lt;module&gt;()&lt;br /&gt;&lt;br /&gt;ipdb&amp;gt; c&lt;br /&gt;&amp;gt; /home/shan/code/test2.py(3)&lt;module&gt;()&lt;br /&gt;2&lt;br /&gt;1---&amp;gt; 3 class Employee:&lt;br /&gt;4     def __init__(self, name, title=None, phone=5551212):&lt;br /&gt;&lt;br /&gt;ipdb&amp;gt; l&lt;br /&gt;1 #/usr/bin/env python&lt;br /&gt;&lt;br /&gt;2&lt;br /&gt;1---&amp;gt; 3 class Employee:&lt;br /&gt;4     def __init__(self, name, title=None, phone=5551212):&lt;br /&gt;5        self.name = name&lt;br /&gt;6        self.title = title&lt;br /&gt;7        self.phone = phone&lt;br /&gt;8&lt;br /&gt;9 def employee():&lt;br /&gt;10     shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;br /&gt;11     import pdb;pdb.set_trace()&lt;br /&gt;ipdb&amp;gt; h&lt;br /&gt;&lt;br /&gt;Documented commands (type help &lt;topic&gt;):&lt;br /&gt;========================================&lt;br /&gt;EOF    bt         cont      enable  jump  pdef   r        tbreak   w&lt;br /&gt;a      c          continue  exit    l     pdoc   restart  u        whatis&lt;br /&gt;alias  cl         d         h       list  pinfo  return   unalias  where&lt;br /&gt;args   clear      debug     help    n     pp     run      unt&lt;br /&gt;b      commands   disable   ignore  next  q      s        until&lt;br /&gt;break  condition  down      j       p     quit   step     up&lt;br /&gt;&lt;br /&gt;Miscellaneous help topics:&lt;br /&gt;==========================&lt;br /&gt;exec  pdb&lt;br /&gt;&lt;br /&gt;Undocumented commands:&lt;br /&gt;======================&lt;br /&gt;retval  rv&lt;br /&gt;&lt;/topic&gt;&lt;/module&gt;&lt;/module&gt;&lt;/string&gt;&lt;br /&gt;&lt;/pre&gt;As we can see, 'run -d code' brings us into ipdb. The rest is same as pdb except ipdb offers good features like command line completion, etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Set ipdb breakpoints from Python source code&lt;br /&gt;&lt;br /&gt;First, you can always set pdb breakpoints as I described in a &lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;previous blog&lt;/a&gt;. After you pdb.set_trace(), when you run codes from ipython, it will open pdb instead of ipdb. The differences between pdb and ipdb is ipdb offers some features that ipython offers while pdb doesn't.&lt;br /&gt;&lt;br /&gt;Now, if you want to set breakpoint and opens ipdb inside ipython when your code reaches the breakpoint, all you need to do is:&lt;br /&gt;&lt;br /&gt;insert the following code at your breakpoint:&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,153,102)"&gt;from IPython.Debugger import Tracer; breakpoint1 = Tracer()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Challenge: Write a vim key map to map F1 key in insert mode to insert a breakpoint in your source code without the need of typing the above import code. Also, map F6 key to open a shell in a split window then start ipython/ipdb to debug the code you are editting. Hint: vim's % variable and ConqueShell or Vimshell.&lt;br /&gt;&lt;br /&gt;Answer: please refer to my previous blog &lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html"&gt;Debugging Python with pdb&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-5314530370814015467?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5314530370814015467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5314530370814015467'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/06/debugging-python-with-ipython-and-ipdb.html' title='Debugging Python in ipython and ipdb'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4880971373474799730</id><published>2010-06-27T15:51:00.000-07:00</published><updated>2010-06-29T00:03:17.048-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Debugging Python in pdb and setup breakpoints from Python code</title><content type='html'>This blog describes some techniques/tips on how to debug Python using the Python debugger pdb.&lt;br /&gt;&lt;br /&gt;My "Vim Python IDE"&lt;br /&gt;The following screen shot shows VIM configured as an almost full function Python IDE  - there are 3 windows in VIM. I edit source code in the upper left window and open the lower left window for ipython, which shows imported objects in current namespace; finally, I have pdb debugging the source code at the right side window. All these can be done with a single key stroke inside VIM! (click the image to enlarge and click again to maximize it)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/TChSyMYoYxI/AAAAAAAAC0c/WJZtjYVoouY/s1600/python-pdb.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://3.bp.blogspot.com/_if8QouXbicI/TChSyMYoYxI/AAAAAAAAC0c/WJZtjYVoouY/s400/python-pdb.bmp" alt="" id="BLOGGER_PHOTO_ID_5487727168222421778" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, I'll show how to use basic Python pdb commands to debug Python code; then  I'll show how to setup pdb breakpoints from the source code.&lt;br /&gt;&lt;br /&gt;Then, I'll list vim key mapping that inserts breakpoints by just pressing &lt;f1&gt;F1 in vim and use F5 key to debug Python code without leaving Vim editor. Use this technique, you can debug Python code and travel back-and-forth between vim and pdb quickly.&lt;br /&gt;&lt;br /&gt;At the end, I'll list additional vim key mappings (Thanks &lt;a href="http://www.vim.org/scripts/script.php?script_id=2771"&gt;ConqueShell&lt;/a&gt;!!) that enable a single key stroke to trigger a pdb/ipython/ipdb in a split window inside Vim. This will turn your Vim into a full function Python IDE, you can edit and debug source code, evaluate attributes, objects in one vim screen!&lt;br /&gt;&lt;br /&gt;Assume I'm working on the follow code and want to debug it:&lt;br /&gt;&lt;pre&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;shan@ub1:~/code$ nl test.py&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;1  #/usr/bin/env python&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;2  class Employee:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;3      def __init__(self, name, title=None, phone=5551212):&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;4         self.name = name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;5         self.title = title&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;6         self.phone = phone&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;7  def employee():&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;8      shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;9      joe = Employee("Joe Smith","Application Developer","7207837")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;10      print (shan.name, shan.title, shan.phone)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;11      print (joe.name, joe.title, joe.phone)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;12  if __name__ == '__main__':&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;13      employee()&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;1. Use pdb to debug python (from Python IDLE):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Basic procedures:&lt;br /&gt;a. start python IDLE&lt;br /&gt;b. import pdb module&lt;br /&gt;c. import python-code&lt;br /&gt;d. type &lt;span style="color: rgb(255, 255, 102);"&gt;pdb.run('module.method()') &lt;/span&gt;and you will stop at (Pdb) prompt:&lt;br /&gt;&lt;br /&gt;For exmaple:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;shan@ub1:~/code$ python&lt;br /&gt;Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)&lt;br /&gt;[GCC 4.4.1] on linux2&lt;br /&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;&gt;&gt;&gt; import pdb&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;&gt;&gt;&gt; import test&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;&gt;&gt;&gt; pdb.run('test.employee()')&lt;/span&gt;&lt;br /&gt;&gt; &lt;string&gt;(1)&lt;module&gt;()-&gt;None&lt;br /&gt;(Pdb)&lt;br /&gt;&lt;br /&gt;&lt;/module&gt;&lt;/string&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, type pdb command 's' to step into your code.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;--Call--&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 0);"&gt;&gt; /home/shan/code/test.py(9)employee()&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The line&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&gt;/home/shan/code/test.py(9)employee()&lt;/span&gt;&lt;br /&gt;means the we stop at code /home/shan/code/test.py line 9 which is &lt;span style="font-style: italic;"&gt;employee() &lt;/span&gt;method/function.&lt;br /&gt;&lt;br /&gt;The "--Call--" indicates we step into a function/method, if you don't want to step into a function but want to execute it, use the 'n' command instead (explained later)&lt;br /&gt;&lt;br /&gt;type pdb command 'l' to list source code. If you want to see more lines of code, you can type 'l range' eg 'l 12,22' to display line 12 to 22.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) l&lt;/span&gt;&lt;br /&gt;4         def __init__(self, name, title=None, phone=5551212):&lt;br /&gt;5            self.name = name&lt;br /&gt;6            self.title = title&lt;br /&gt;7            self.phone = phone&lt;br /&gt;8&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;9  -&gt; def employee():&lt;/span&gt;&lt;br /&gt;10         shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;br /&gt;11         joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;12         print (shan.name, shan.title, shan.phone)&lt;br /&gt;13         print (joe.name, joe.title, joe.phone)&lt;br /&gt;14&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Please note, from the above output, the following line shows the NEXT line of code Python is about to execute.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;'9  -&gt; def employee():'&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When using 's' (step command), it's good to know two other related commands - 'n' and 'c'.&lt;br /&gt;&lt;br /&gt;Command 'n' (next) will execute the command one line at a time without stepping into functions.&lt;br /&gt;&lt;br /&gt;Command 'c' (continue) will continue to execute until the end of current function.&lt;br /&gt;&lt;br /&gt;Another useful pdb command is 'w' (where), it shows how the python compiler gets to the current line. It's very useful if your current position is nested.&lt;br /&gt;&lt;br /&gt;Finally, to inspect attribute's value, use p (print) command. Or just type attribute's name.&lt;br /&gt;&lt;br /&gt;Here's a complete run:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;shan@ub1:~/code$ python&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;[GCC 4.4.1] on linux2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt;&gt;&gt; import pdb&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt;&gt;&gt; import test&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt;&gt;&gt; pdb.run('test.employee()')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; &lt;/span&gt;&lt;string&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(1)&lt;/span&gt;&lt;module&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;--Call--&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(9)employee()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; def employee():&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) l&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;4         def __init__(self, name, title=None, phone=5551212):&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;5            self.name = name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;6            self.title = title&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;7            self.phone = phone&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;8&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;9  -&gt; def employee():&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;10         shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;11         joe = Employee("Joe Smith","Application Developer","7207837")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;12         print (shan.name, shan.title, shan.phone)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;13         print (joe.name, joe.title, joe.phone)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;14&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(10)employee()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;--Call--&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(4)__init__()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; def __init__(self, name, title=None, phone=5551212):&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(5)__init__()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; self.name = name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(6)__init__()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; self.title = title&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(7)__init__()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; self.phone = phone&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;--Return--&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(7)__init__()-&gt;None&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; self.phone = phone&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(11)employee()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; joe = Employee("Joe Smith","Application Developer","7207837")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) shan.title&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;'UNIX ADMIN'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) print shan.phone&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;2720748&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) w&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;/usr/lib/python2.6/bdb.py(368)run()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; exec cmd in globals, locals&lt;/span&gt;&lt;br /&gt;&lt;string&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(1)&lt;/span&gt;&lt;module&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;&gt; /home/shan/code/test.py(11)employee()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;-&gt; joe = Employee("Joe Smith","Application Developer","7207837")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;(Pdb) c&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;('Shan Jing', 'UNIX ADMIN', '2720748')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;('Joe Smith', 'Application Developer', '7207837')&lt;/span&gt;&lt;br /&gt;&lt;/module&gt;&lt;/string&gt;&lt;/module&gt;&lt;/string&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 51);"&gt;2. Setting breakpoints from Python code&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sometimes, you don't want to go thru the entire code line by line to debug. All you need is to jump into certain point in your code and debug that section only, you can do that by setting up a breakpoint in Python code.&lt;br /&gt;&lt;br /&gt;Just add 'import pdb;pdb.set_trace()' at the point where you want to mark as breakpoint then run your code as normal, it will stop at the breakpoint and gives you pdb prompt.&lt;br /&gt;&lt;br /&gt;See below line 9:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;1  #/usr/bin/env python&lt;br /&gt;&lt;br /&gt;2  class Employee:&lt;br /&gt;3      def __init__(self, name, title=None, phone=5551212):&lt;br /&gt;4         self.name = name&lt;br /&gt;5         self.title = title&lt;br /&gt;6         self.phone = phone&lt;br /&gt;&lt;br /&gt;7  def employee():&lt;br /&gt;8      shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;9      import pdb;pdb.set_trace()&lt;/span&gt;&lt;br /&gt;10      joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;11      print (shan.name, shan.title, shan.phone)&lt;br /&gt;12      print (joe.name, joe.title, joe.phone)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;13  if __name__ == '__main__':&lt;br /&gt;14      employee()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;shan@ub1:~/code$ python test2.py&lt;br /&gt;&gt; /home/shan/code/test2.py(12)employee()&lt;br /&gt;-&gt; joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;(Pdb) l&lt;br /&gt;7            self.phone = phone&lt;br /&gt;8&lt;br /&gt;9     def employee():&lt;br /&gt;10         shan = Employee("Shan Jing","UNIX ADMIN","2720748")&lt;br /&gt;11         &lt;span style="color: rgb(255, 102, 102);"&gt;import pdb;pdb.set_trace()&lt;/span&gt;&lt;br /&gt;12  -&gt;     joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;13         print (shan.name, shan.title, shan.phone)&lt;br /&gt;14         print (joe.name, joe.title, joe.phone)&lt;br /&gt;15&lt;br /&gt;16&lt;br /&gt;17     if __name__ == '__main__':&lt;br /&gt;(Pdb) w&lt;br /&gt;/home/shan/code/test2.py(18)&lt;module&gt;()&lt;br /&gt;-&gt; employee()&lt;br /&gt;&gt; /home/shan/code/test2.py(12)employee()&lt;br /&gt;-&gt; joe = Employee("Joe Smith","Application Developer","7207837")&lt;br /&gt;(Pdb) shan.title&lt;br /&gt;'UNIX ADMIN'&lt;br /&gt;(Pdb) c&lt;br /&gt;('Shan Jing', 'UNIX ADMIN', '2720748')&lt;br /&gt;('Joe Smith', 'Application Developer', '7207837')&lt;br /&gt;shan@ub1:~/code$&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/module&gt;&lt;/pre&gt;Assume you are editing your code in Vim editor, wouldn't it be nice if just hit one key to set a breakpoint and hit another key to debug the code without leaving Vim?&lt;br /&gt;&lt;br /&gt;Put the following lines in ~/.vimrc&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;"pdb setting : insert pdb breakpoints&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;imap &lt;/span&gt;&amp;lt;F1&gt;&lt;span style="color: rgb(255, 102, 0);"&gt; import pdb;pdb.set_trace()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;au BufRead *.py nmap &lt;/span&gt;&amp;lt;F5&gt;&lt;span style="color: rgb(255, 102, 0);"&gt; :!python %&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;/cr&gt;&lt;/pre&gt;&lt;br /&gt;Now, at Vim's insert mode, find the place you want to insert a breakpoint, hit F1 key. To debug your code, (save it first) and hit F5 key, you will be stopped at the breakpoint in a shell, once done debugging just type 'exit' to close pdb and go back to vim continue your coding.&lt;br /&gt;&lt;br /&gt;If you have conqueshell installed in vim, using the following Vim mappings, you will be able to open ipython and debug your code from a new buffer in a split window on the same screen on vim.  Basically, you turn Vim into a dynamic Python/iPython IDE with a full function debugger!&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;" ConqueShell Mappings&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F1&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :ConqueTermSplit bash&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F2&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :ConqueTermVSplit bash&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F3&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :ConqueTermSplit ipython&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F4&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :ConqueTermVSplit ipython&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F6&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :execute 'ConqueTermSplit ipython '.expand('%:p')&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;nmap &lt;/span&gt;&amp;lt;F7&gt;&lt;span style="color: rgb(255, 102, 102);"&gt; :execute 'ConqueTermVSplit ipython '.expand('%:p')&lt;/span&gt;&lt;cr&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;let g:ConqueTerm_EscKey = '&lt;/span&gt;&lt;c-k&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;/c-k&gt;&lt;/cr&gt;&lt;/cr&gt;&lt;/cr&gt;&lt;/cr&gt;&lt;/cr&gt;&lt;/cr&gt;&lt;/pre&gt;&lt;br /&gt;I have posted my .vimrc in another blog.&lt;br /&gt;&lt;br /&gt;If you want to use ipython (which is a much better IDE)  and ipdb to debug Python, please read my next blog - &lt;a href="http://shanit.blogspot.com/2010/06/debugging-python-with-ipython-and-ipdb.html"&gt;Debugging Python with ipython and ipdb.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 51);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/f1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4880971373474799730?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4880971373474799730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4880971373474799730'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/06/debugging-python-with-pdb-and-ipython.html' title='Debugging Python in pdb and setup breakpoints from Python code'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_if8QouXbicI/TChSyMYoYxI/AAAAAAAAC0c/WJZtjYVoouY/s72-c/python-pdb.bmp' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8658028173883928833</id><published>2010-06-14T21:40:00.000-07:00</published><updated>2010-06-14T22:02:39.418-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Desktop - vim cygwin mintty firefox etc'/><title type='text'>.vimrc for Python</title><content type='html'>&lt;pre&gt;&lt;br /&gt;"My .vimrc file (Shan Jing)&lt;br /&gt;"&lt;br /&gt;" Part 1. Python Vim settings&lt;br /&gt;" Part 2. Misc Settings&lt;br /&gt;" Part 3. Global Format Settings&lt;br /&gt;&lt;br /&gt;" &amp;lt;F1&gt; opens bash in a horizonal split window&lt;br /&gt;" &amp;lt;F2&gt; opens bash in a vertical split window&lt;br /&gt;" &amp;lt;F3&gt; opens ipython in a horizonal split window&lt;br /&gt;" &amp;lt;F4&gt; opens ipython in a vertical split window&lt;br /&gt;" &amp;lt;F5&gt; debug/run current python file in a shell&lt;br /&gt;" &amp;lt;c-,&gt; opens a shell in a buffer/work with tabnew&lt;br /&gt;" &amp;lt;c-w&gt;t&amp;lt;c-w&gt;H swap windows shapes H-&gt;V&lt;br /&gt;" &amp;lt;c-w&gt;t&amp;lt;c-w&gt;K swap windows shapes V-&gt;H&lt;br /&gt;" :map or :map! to show current mappings&lt;br /&gt;" :nmap - Display normal mode maps&lt;br /&gt;" :imap - Display insert mode maps&lt;br /&gt;" :vmap - Display visual and select mode maps&lt;br /&gt;" :smap - Display select mode maps&lt;br /&gt;" :xmap - Display visual mode maps&lt;br /&gt;" :cmap - Display command-line mode maps&lt;br /&gt;" :omap - Display operator pending mode maps&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"1. Python vim settings&lt;br /&gt;set tabstop=4       " numbers of spaces of tab character&lt;br /&gt;set shiftwidth=4    " numbers of spaces to (auto)indent&lt;br /&gt;set smarttab&lt;br /&gt;set expandtab       " tabs are converted to spaces,use only when  required&lt;br /&gt;set autoindent&lt;br /&gt;set smartindent&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if has("autocmd")&lt;br /&gt;    " clear au, note: au = autocmd&lt;br /&gt;    au!&lt;br /&gt;    " Restore cursor position&lt;br /&gt;    au BufReadPost * if line("'\"") &gt; 0|if line("'\"") &amp;lt;=  line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif&lt;br /&gt;&lt;br /&gt;"omnicompletion&lt;br /&gt;filetype plugin on&lt;br /&gt;set ofu=syntaxcomplete#Complete&lt;br /&gt;    au FileType python set omnifunc=pythoncomplete#&lt;div id=":9p" class="ii gt"&gt;&lt;wbr&gt;Complete&lt;br /&gt;    au FileType javascript set omnifunc=javascriptcomplete#&lt;wbr&gt;CompleteJS&lt;br /&gt;    au FileType html set omnifunc=htmlcomplete#&lt;wbr&gt;CompleteTags&lt;br /&gt;    au FileType css set omnifunc=csscomplete#&lt;wbr&gt;CompleteCSS&lt;br /&gt;    au FileType xml set omnifunc=xmlcomplete#&lt;wbr&gt;CompleteTags&lt;br /&gt;    au FileType php set omnifunc=phpcomplete#&lt;wbr&gt;CompletePHP&lt;br /&gt;    au FileType c set omnifunc=ccomplete#Complete&lt;br /&gt;&lt;br /&gt;"&lt;a href="http://vim.wikia.com/wiki/Python_-_check_syntax_and_run_script" target="_blank"&gt;http://vim.wikia.com/wiki/&lt;wbr&gt;Python_-_check_syntax_and_run_&lt;wbr&gt;script&lt;/a&gt;&lt;br /&gt;"nmap &amp;lt;buffer&gt; &amp;lt;F5&gt; :w&lt;esc&gt;mwG:r!python %&amp;lt;cr&gt;`.&lt;br /&gt;   au BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\  sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"&lt;br /&gt;   au BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\  %l%.%#,%Z%[%^\ ]%\\@=%m&lt;br /&gt;   au BufRead *.py nmap &amp;lt;F5&gt; :!python %&amp;lt;cr&gt;&lt;br /&gt;   au BufRead *.py set nowrap&lt;br /&gt;   au BufRead *.py set go+=b&lt;br /&gt;   au BufRead *.py set tabstop=4&lt;br /&gt;"Python settings: auto indent the next line after these key words:&lt;br /&gt;   au BufRead *.py set smartindent cinwords=def,if,elif,else,for,&lt;wbr&gt;while,try,except,finall&lt;br /&gt;&lt;br /&gt;   " Automatically chmod +x Python, Perl and Shell scripts&lt;br /&gt;   au BufWritePost   *.py             !chmod +x %&lt;br /&gt;   au BufWritePost   *.sh             !chmod +x %&lt;br /&gt;   au BufWritePost   *.pl             !chmod +x %&lt;br /&gt;&lt;br /&gt;   "remove all training space when editing&lt;br /&gt;   "au BufWritePre *.py :%s/\s\+$//e&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;"3. Other global setttings&lt;br /&gt;"3a. A Python Calculator&lt;br /&gt;"3b. ConqueShell Mappings&lt;br /&gt;"3c. vim 7+ tabs settings&lt;br /&gt;"3d. color scheme settings&lt;br /&gt;"3e. general coding settings for c,cpp,php,java, etc&lt;br /&gt;"3f. global format settings&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"A Python Calculator for python aware vim&lt;br /&gt;"usage : command mode: Calc x*y&lt;br /&gt;:command! -nargs=+ Calc :py print &amp;lt;args&gt;&lt;br /&gt;:py from math import *&lt;br /&gt;&lt;br /&gt;" ConqueShell Mappings&lt;br /&gt;nmap &amp;lt;F1&gt; :ConqueTermSplit bash&amp;lt;cr&gt;&lt;br /&gt;nmap &amp;lt;F2&gt; :ConqueTermVSplit bash&amp;lt;cr&gt;&lt;br /&gt;nmap &amp;lt;F3&gt; :ConqueTermSplit ipython&amp;lt;cr&gt;&lt;br /&gt;nmap &amp;lt;F4&gt; :ConqueTermVSplit ipython&amp;lt;cr&gt;&lt;br /&gt;nmap &amp;lt;F6&gt; :ConqueTerm bash -o vi&amp;lt;cr&gt;&lt;br /&gt;let g:ConqueTerm_EscKey = '&amp;lt;c-k&gt;'&lt;br /&gt;&lt;br /&gt;"map &amp;lt;F9&gt; :previous&amp;lt;cr&gt;  " map F9 to open previous buffer&lt;br /&gt;"map &amp;lt;F10&gt; :next&amp;lt;cr&gt;      " map F10 to open next buffer&lt;br /&gt;&lt;br /&gt;" turn off highlighted search&lt;br /&gt;map &amp;lt;silent&gt; &amp;lt;c-h&gt; :silent noh&amp;lt;cr&gt;&lt;br /&gt;&lt;br /&gt;"editting and sourcing .vimrc&lt;br /&gt;map ,e :vsp ~/.vimrc&amp;lt;cr&gt;      " edit my .vimrc file&lt;br /&gt;map ,u :source ~/.vimrc&amp;lt;cr&gt;   " update vim setting&lt;br /&gt;&lt;br /&gt;"insert the directory name of the current buffer&lt;br /&gt;imap &amp;lt;2&gt; &amp;lt;c-r&gt;=expand('%:p:h')&amp;lt;cr&gt;&lt;br /&gt;&lt;br /&gt;"For vim 7.0+ tabs limit (default is 10)&lt;br /&gt;set tabpagemax=15&lt;br /&gt;"open a new tab&lt;br /&gt;map ,t :tabnew&amp;lt;cr&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"command mode mappings&lt;br /&gt;"insert the directory name of the current buffer at command mode&lt;br /&gt;"e.g., :!ls &amp;lt;2&gt; will do ls dir at current cursor&lt;br /&gt;cmap &amp;lt;F2&gt; &amp;lt;c-r&gt;=expand('%:p:h')&amp;lt;cr&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"color scheme setting&lt;br /&gt;if has("gui_running")&lt;br /&gt;    " See ~/.gvimrc&lt;br /&gt;    set guifont=Monospace\ 10  " use this font&lt;br /&gt;    set lines=50       " height = 50 lines&lt;br /&gt;    set columns=100        " width = 100 columns&lt;br /&gt;    set background=light   " adapt colors for background&lt;br /&gt;    set selectmode=mouse,key,cmd&lt;br /&gt;    set keymodel=&lt;br /&gt;else&lt;br /&gt;    colorscheme elflord    " use this color scheme&lt;br /&gt;    set background=dark        " adapt colors for background&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;if has("autocmd")&lt;br /&gt;    " Filetypes (au = autocmd)&lt;br /&gt;    au FileType helpfile set nonumber      " no line numbers when  viewing help&lt;br /&gt;    au FileType helpfile nnoremap &amp;lt;buffer&gt;&amp;lt;cr&gt; &amp;lt;c-]&gt;    " Enter selects subject&lt;br /&gt;    au FileType helpfile nnoremap &amp;lt;buffer&gt;&amp;lt;bs&gt; &amp;lt;c-t&gt;    " Backspace to go back&lt;br /&gt;&lt;br /&gt;    " When using mutt, text width=72&lt;br /&gt;    au FileType mail,tex set textwidth=72&lt;br /&gt;    au FileType cpp,c,java,sh,pl,php,asp  set autoindent&lt;br /&gt;    au FileType cpp,c,java,sh,pl,php,asp  set smartindent&lt;br /&gt;    au FileType cpp,c,java,sh,pl,php,asp  set cindent&lt;br /&gt;    "au BufRead mutt*[0-9] set tw=72&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    " File formats&lt;br /&gt;    au BufNewFile,BufRead  *.pls    set syntax=dosini&lt;br /&gt;    au BufNewFile,BufRead  modprobe.conf    set syntax=modconf&lt;br /&gt;    "remove all training space when editing&lt;br /&gt;    au BufWritePre *.py :%s/\s\+$//e&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;"Global format settings&lt;br /&gt;set nocompatible    " use vim defaults&lt;br /&gt;set ls=2            " allways show status line&lt;br /&gt;set scrolloff=3     " keep 3 lines when scrolling&lt;br /&gt;set showcmd         " display incomplete commands&lt;br /&gt;set hlsearch        " highlight searches&lt;br /&gt;set incsearch       " do incremental searching&lt;br /&gt;set ruler           " show the cursor position all the time&lt;br /&gt;set visualbell t_vb=    " turn off error beep/flash&lt;br /&gt;set novisualbell    " turn off visual bell&lt;br /&gt;set nobackup        " do not keep a backup file&lt;br /&gt;set number          " show line numbers&lt;br /&gt;set ignorecase      " ignore case when searching&lt;br /&gt;"set noignorecase   " don't ignore case&lt;br /&gt;set title           " show title in console title bar&lt;br /&gt;set ttyfast         " smoother changes&lt;br /&gt;"set ttyscroll=0        " turn off scrolling, didn't work well with  PuTTY&lt;br /&gt;set modeline        " last lines in document sets vim mode&lt;br /&gt;set modelines=3     " number lines checked for modelines&lt;br /&gt;set shortmess=atI   " Abbreviate messages&lt;br /&gt;set nostartofline   " don't jump to first character when paging&lt;br /&gt;set whichwrap=b,s,h,l,&amp;lt;,&gt;,[,]   " move freely between files&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;syntax on&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8658028173883928833?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8658028173883928833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8658028173883928833'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/06/vimrc-for-python.html' title='.vimrc for Python'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8408201223545797560</id><published>2010-05-17T15:16:00.000-07:00</published><updated>2010-05-17T15:25:10.723-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Solaris 10 Administration'/><title type='text'>Solaris 10 Performance Tuning - Analyzing CPU</title><content type='html'>&lt;pre&gt;&lt;br /&gt;Solaris 10 Performance Tuning – Analyzing CPU&lt;br /&gt;&lt;br /&gt;Tools :&lt;br /&gt;psrinfo&lt;br /&gt;uptime&lt;br /&gt;vmstat&lt;br /&gt;sar -u&lt;br /&gt;sar -q  (cpu queue, same as vmstat kthr:r)&lt;br /&gt;mpstat&lt;br /&gt;dtrace&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ psrinfo -vp&lt;br /&gt;The physical processor has 8 virtual processors (32-39)&lt;br /&gt;  SPARC64-VII (portid 1056 impl 0x7 ver 0x91 clock 2400 MHz)&lt;br /&gt;The physical processor has 8 virtual processors (40-47)&lt;br /&gt;  SPARC64-VII (portid 1064 impl 0x7 ver 0x91 clock 2400 MHz)&lt;br /&gt;The physical processor has 8 virtual processors (48-55)&lt;br /&gt;  SPARC64-VII (portid 1072 impl 0x7 ver 0x91 clock 2400 MHz)&lt;br /&gt;The physical processor has 8 virtual processors (56-63)&lt;br /&gt;  SPARC64-VII (portid 1080 impl 0x7 ver 0x91 clock 2400 MHz)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ uptime&lt;br /&gt;  1:04pm  up 114 day(s), 14:15,  6 users,  load average: 4.41, 4.39, 3.76&lt;br /&gt;&lt;br /&gt;the intervals are 1,5,15 minutes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ vmstat 5&lt;br /&gt; kthr      memory            page            disk          faults      cpu&lt;br /&gt; r b w   swap    free     re  mf pi po fr de sr s0 s1 sd sd   in   sy     cs    us sy id&lt;br /&gt; 0 0 0 107752976 11913152 74 296 901 2 2  0  0  2  2 -0 -349 5960  727992 5910  9  2 89&lt;br /&gt; 0 0 0 106811152 8983688  8  31  2   0 0  0  0  0  0  0  2   8818  615705 13764 13 2 85&lt;br /&gt; 0 0 0 106701904 8884808  0  14  0   0 0  0  0  0  0  0  2   14250 584633 24692 12 3 85&lt;br /&gt; 0 0 0 106535552 8730784  9  87  0   0 0  0  0  9  9  0  0   9247  379414 14642 12 2 87&lt;br /&gt; 0 0 0 106403648 8603144  0  10  0   0 0  0  0  0  0  0  0   6668  550100 9664  12 2 87&lt;br /&gt; 0 0 0 106296328 8504712  0  5   0   0 0  0  0  0  0  0  0   10490 471906 17677 12 2 85&lt;br /&gt; 0 0 0 106277472 8510232  1  3   6   0 0  0  0  0  0  0  0   12011 535986 20477 11 2 87&lt;br /&gt; 0 0 0 106277472 8527712  3  37  0   0 0  0  0  0  0  0  0   13685 668057 23689 9  2 89&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The first line is the summary since boot. vmstat reads its statistic from kstat,&lt;br /&gt;which maintains CPU utilizztion statistics for each CPU.&lt;br /&gt;&lt;br /&gt;cpu:id : for percent idle.&lt;br /&gt;kthr:r : the total number of threads on the ready to run queues, CPU saturation.&lt;br /&gt;&lt;br /&gt;faults:in : number of interrupts/sec&lt;br /&gt;faults:sys: number of system calls/sec&lt;br /&gt;faults:cs : number of context switches/sec&lt;br /&gt;&lt;br /&gt;cpu:us  : percent user time/user-mode threads&lt;br /&gt;cpu:sy  : percent system time&lt;br /&gt;cpu:id  : percent idle&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sar : turn on sar if it's not on.&lt;br /&gt;&lt;br /&gt;$ svcs -a | grep sar&lt;br /&gt;online         Jan_22   svc:/system/sar:default&lt;br /&gt;$ svcs -l svc:/system/sar:default&lt;br /&gt;fmri         svc:/system/sar:default&lt;br /&gt;name         system activity reporting package&lt;br /&gt;enabled      true&lt;br /&gt;state        online&lt;br /&gt;next_state   none&lt;br /&gt;state_time   Fri Jan 22 22:08:22 2010&lt;br /&gt;logfile      /var/svc/log/system-sar:default.log&lt;br /&gt;restarter    svc:/system/svc/restarter:default&lt;br /&gt;dependency   require_all/none svc:/system/filesystem/minimal (online)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ sar 5 10&lt;br /&gt;&lt;br /&gt;SunOS betapm 5.10 Generic_142900-03 sun4u    05/17/2010&lt;br /&gt;&lt;br /&gt;13:07:48    %usr    %sys    %wio   %idle&lt;br /&gt;13:07:53      13       4       0      84&lt;br /&gt;13:07:58      11       4       0      85&lt;br /&gt;13:08:03       9       3       0      88&lt;br /&gt;13:08:08       9       3       0      88&lt;br /&gt;13:08:13      11       4       0      85&lt;br /&gt;13:08:18      11       3       0      86&lt;br /&gt;13:08:23      10       3       0      86&lt;br /&gt;13:08:28       9       3       0      88&lt;br /&gt;13:08:33       9       3       0      88&lt;br /&gt;13:08:38      11       3       0      86&lt;br /&gt;&lt;br /&gt;Average       10       3       0      86&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;%usr vs %sys : 70% vs 30%&lt;br /&gt;&lt;br /&gt;%wio is always 0 in solaris 10 (disabled)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ sar -q 2 10&lt;br /&gt;&lt;br /&gt;SunOS betapm 5.10 Generic_142900-03 sun4u    05/17/2010&lt;br /&gt;&lt;br /&gt;13:11:34 runq-sz %runocc swpq-sz %swpocc&lt;br /&gt;13:11:36     1.0      50     0.0       0&lt;br /&gt;13:11:38     0.0       0     0.0       0&lt;br /&gt;13:11:40     0.0       0     0.0       0&lt;br /&gt;13:11:42     0.0       0     0.0       0&lt;br /&gt;13:11:44     0.0       0     0.0       0&lt;br /&gt;13:11:46     0.0       0     0.0       0&lt;br /&gt;13:11:48     0.0       0     0.0       0&lt;br /&gt;13:11:50     1.0      50     0.0       0&lt;br /&gt;13:11:52     0.0       0     0.0       0&lt;br /&gt;13:11:54     0.0       0     0.0       0&lt;br /&gt;&lt;br /&gt;Average      1.0      10     0.0       0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;runq-sz: run queue size , same as vmstat kthr:r&lt;br /&gt;&lt;br /&gt;%runocc: identify short bursts of run queue activity occurred&lt;br /&gt;&lt;br /&gt;swpq-sz: number of swapped-out threads&lt;br /&gt;&lt;br /&gt;%swpocc: swapped out occupancy, percentage of time there were swapped out threads&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ mpstat 3&lt;br /&gt;&lt;br /&gt;CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl&lt;br /&gt; 32    0   0   18   460  126  257    0    3   10    0  2858    0   0   0  99&lt;br /&gt; 33    0   0   14   131   34  180    1    7   49    0   740    5   1   0  94&lt;br /&gt; 34    0   0    5   134   45  161    1    6    3    0   879    0   0   0 100&lt;br /&gt; 35    0   0   60    78   33   93    0    7   54    0   457    0   0   0 100&lt;br /&gt; 36    0   0    3   199   91  204    0    4    2    0  1125    0   0   0 100&lt;br /&gt; 37    0   0  105    49   13   55    0    3   17    0   164    0   0   0 100&lt;br /&gt; 38    0   0    2   124   56  126    0    2    1    0  1716    0   0   0  99&lt;br /&gt; 39   30   0   21     5    0    7    0    2    4    0    13    0   0   0 100&lt;br /&gt; 40    0   0    1     6    2    3    0    1    0    0    50    0   0   0 100&lt;br /&gt; 41    0   0    0     3    0    5    0    3    5    0     0    0   0   0 100&lt;br /&gt; 42    0   0   10    22   10    0    0    0    0    0     0    0   0   0 100&lt;br /&gt; 43    0   0    1     7    1   10    0    5   12    0     1    0   0   0 100&lt;br /&gt; 44    0   0    0     2    0    0    0    0    0    0     0    0   0   0 100&lt;br /&gt; 45    0   0    1     6    0    8    0    4    7    0     2    0   0   0 100&lt;br /&gt; 46    0   0   29    68   30    0    6    0  510    0 795891   72  28   0   0&lt;br /&gt; 47    0   0    2     5    1    2    0    1    4    0     0    0   0   0 100&lt;br /&gt; 48    0   0   26   346  153  331    1    6    8    0  4467    1   0   0  99&lt;br /&gt; 49    0   0    0     3    0    7    0    4    8    0     0    0   0   0 100&lt;br /&gt; 50    0   0   53   129   92   22    0    0    3    0     8    0   0   0 100&lt;br /&gt; 51    0   0   65   131   42  142    0    7   61    0   568    1   0   0  99&lt;br /&gt; 52    0   0   23   878  671  382    0    4   22    0  3765    1   2   0  97&lt;br /&gt; 53    0   0   43    43   32   15    0    3    9    0     0    0   0   0 100&lt;br /&gt; 54    0   0    0    22    6   27    0    0    0    0    39    0   0   0 100&lt;br /&gt; 55    0   0   91   237  108  241    0    6   11    0   213    0   0   0 100&lt;br /&gt; 56    0   0   38   303  143  231    0    5    2    0  3360    1   1   0  99&lt;br /&gt; 57    0   0    8    59   14   81    0    2   19    0   352    3   0   0  97&lt;br /&gt; 58    0   0    1     5    1    3    0    1    0    0     7    0   0   0 100&lt;br /&gt; 59    0   0    9    61   18   57    0    3   13    0    62    0   1   0  99&lt;br /&gt; 60    0   0   23   212   96  183    1    6    2    0  1159    0   0   0  99&lt;br /&gt; 61    0   0   25   134   38  169    0    5   81    0   921    5   0   0  95&lt;br /&gt; 62    0   0    0    19    3   27    0    0    2    0    27    0   0   0 100&lt;br /&gt; 63    0   0    6    62   22   62    0    6    7    0   271    0   0   0 100&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;csw : the number of context switch (both voluntary and involuntary);&lt;br /&gt;occurs when a thread perfomrs a blocking system call e.g. performing I/O when&lt;br /&gt;the thread sleeps until the I/O event has completed.&lt;br /&gt;&lt;br /&gt;icsw: the number of involuntary context switches; indicates if there were more&lt;br /&gt;threads ready to run than available phyiscal processors.&lt;br /&gt;&lt;br /&gt;migr: migrations of threads between processors; the number of times  the OS&lt;br /&gt;scheduler moves ready-to-run threads to an idle prcessor. OS normally keeps&lt;br /&gt;the threads on the last processor it ran unless the process is busy, then the&lt;br /&gt;thread migrates. Such migration is bad for performance.&lt;br /&gt;&lt;br /&gt;intr: the number of interrupts taken on CPU.&lt;br /&gt;&lt;br /&gt;ithr: the number of interrupts that are converted to real threads, as result of&lt;br /&gt;inbound network packets, blocking for a mutex, or a synchronization event.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;smtx: the number of mutex contentions in the kernel, high shows high %sys time.&lt;br /&gt;&lt;br /&gt;srw : the number of reader-writer lock contention events in the kernel.&lt;br /&gt;Excessive reader/write lock contention results in nonscaling performance and&lt;br /&gt;systems that are unable to use all the available CPU resources (symptom is idle time).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ mpstat -ap 5 20&lt;br /&gt;SET minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl sze&lt;br /&gt;  0  183   1 1186   874  207 1104    7  158  156    0  4229    0   1   0  99  16&lt;br /&gt;  1  112 104 2329  5085 2222 4805  215  710 1958  187 723869   17   4   0  80  16&lt;br /&gt;SET minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl sze&lt;br /&gt;  0  107   0 1505   995  323 1128    5   78  368    0  3755    2   1   0  97  16&lt;br /&gt;  1    0   0  374  3011 1364 2399    7   68   35    0 38155    0   0   0  99  16&lt;br /&gt;SET minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl sze&lt;br /&gt;  0    4   0  244  1010  322 1170    4   74  304    0  3549    2   0   0  98  16&lt;br /&gt;  1    0   0  472  2907 1313 2303    5   62   25    0 45064    0   0   0  99  16&lt;br /&gt;SET minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl sze&lt;br /&gt;  0    1   0  290   990  323 1156    4   79  322    0  3577    2   1   0  97  16&lt;br /&gt;  1    0   0  265  2600 1119 2080    6   51   37    0 48610    1   0   0  99  16&lt;br /&gt;SET minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl sze&lt;br /&gt;  0   74   0  715  1074  323 1275    6   90  287    0  3816    3   1   0  96  16&lt;br /&gt;  1    0   0  325  2695 1203 2077    6   67   31    0 59557    1   0   0  99  16&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$prstat&lt;br /&gt;   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP&lt;br /&gt; 29302 sybase     11G   11G sleep   59    0 195:35:53 0.1% dataserver/259&lt;br /&gt; 29347 sybase     11G   11G sleep   59    0 151:18:42 0.1% dataserver/259&lt;br /&gt; 29348 sybase     11G   11G sleep   59    0 153:15:41 0.0% dataserver/259&lt;br /&gt; 29340 sybase     11G   11G sleep   59    0 147:23:56 0.0% dataserver/259&lt;br /&gt; 29341 sybase     11G   11G sleep   59    0 153:08:31 0.0% dataserver/259&lt;br /&gt; 29342 sybase     11G   11G sleep   59    0 149:55:02 0.0% dataserver/259&lt;br /&gt; 29346 sybase     11G   11G sleep   59    0 149:56:52 0.0% dataserver/259&lt;br /&gt; 29334 sybase     11G   11G sleep   59    0 153:15:53 0.0% dataserver/259&lt;br /&gt; 29349 sybase     11G   11G sleep   59    0 182:37:54 0.0% dataserver/259&lt;br /&gt; 29343 sybase     11G   11G sleep   59    0 148:44:13 0.0% dataserver/259&lt;br /&gt; 29345 sybase     11G   11G sleep   59    0 152:04:00 0.0% dataserver/259&lt;br /&gt; 29333 sybase     11G   11G sleep   59    0 154:10:37 0.0% dataserver/259&lt;br /&gt; 29332 sybase     11G   11G sleep   59    0 146:54:46 0.0% dataserver/259&lt;br /&gt; 29335 sybase     11G   11G sleep   59    0 156:39:37 0.0% dataserver/259&lt;br /&gt; 29344 sybase     11G   11G sleep   59    0 144:58:21 0.0% dataserver/259&lt;br /&gt;  1540 sybase     14M   11M sleep   59    0   0:00:00 0.0% xpserver/1&lt;br /&gt; 29320 sybase     10M 9152K sleep   59    0   0:00:15 0.0% backupserver/1&lt;br /&gt; 28892 sybase   4296K 2136K sleep   59    0   0:00:06 0.0% SYBASE/1&lt;br /&gt; 29304 sybase     10M 6872K sleep   59    0   0:00:00 0.0% backupserver/1&lt;br /&gt; 28891 sybase   3440K 1880K sleep   59    0   0:00:06 0.0% lmgrd/1&lt;br /&gt;Total: 20 processes, 3890 lwps, load averages: 1.02, 1.73, 2.12&lt;br /&gt;&lt;br /&gt;Quick note for prstat:&lt;br /&gt;CPU field is thread-&gt;pr_pctcpu&lt;br /&gt;load average is the same as 'uptime'&lt;br /&gt;When average load average exceeds the number of CPUs in the system (psrinfo),&lt;br /&gt;the system is very likely over loaded.&lt;br /&gt;&lt;br /&gt;prstat -mL  ; turn on microstates '-m' and show per-thread '-L'&lt;br /&gt;   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID&lt;br /&gt; 14853 sjing     21  72 0.7 0.0 0.0 0.0 6.5 0.0  73  73 78K   0 prstat/1&lt;br /&gt; 12047 betapm    34 0.8 0.0 0.0 0.0 0.0  65 0.1 773  21 12K   0 MathKernel/1&lt;br /&gt; 29302 sybase    22 4.5 0.0 0.0 0.0 0.0  74 0.0 227  71 .3M   9 dataserver/1&lt;br /&gt; 29349 sybase    20 3.7 0.0 0.0 0.0 0.0  76 0.0 234  75 .2M   7 dataserver/1&lt;br /&gt; 29335 sybase    17 3.4 0.0 0.0 0.0 0.0  79 0.0 240  67 .2M   7 dataserver/1&lt;br /&gt; 29333 sybase    17 3.4 0.0 0.0 0.0 0.0  79 0.0 242  67 .2M   8 dataserver/1&lt;br /&gt; 29341 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 244  66 .2M   9 dataserver/1&lt;br /&gt; 29348 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 243  67 .2M   8 dataserver/1&lt;br /&gt; 29334 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 242  67 .2M   7 dataserver/1&lt;br /&gt; 29345 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 242  66 .2M   7 dataserver/1&lt;br /&gt; 29347 sybase    17 3.1 0.0 0.0 0.0 0.0  80 0.0 243  67 .2M   8 dataserver/1&lt;br /&gt; 29342 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 245  66 .2M  11 dataserver/1&lt;br /&gt; 29346 sybase    17 3.2 0.0 0.0 0.0 0.0  80 0.0 244  67 .2M   8 dataserver/1&lt;br /&gt; 29343 sybase    17 3.0 0.0 0.0 0.0 0.0  80 0.0 244  67 .2M   8 dataserver/1&lt;br /&gt; 29340 sybase    17 3.1 0.0 0.0 0.0 0.0  80 0.0 245  66 .2M   8 dataserver/1&lt;br /&gt;Total: 141 processes, 4479 lwps, load averages: 0.87, 1.24, 1.83&lt;br /&gt;   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID&lt;br /&gt; 29302 sybase    10 4.5 0.0 0.0 0.0 0.0  85 0.0 367   9 .3M 126 dataserver/1&lt;br /&gt; 29347 sybase   9.9 4.0 0.0 0.0 0.0 0.0  86 0.0 373   8 .2M 127 dataserver/1&lt;br /&gt; 12047 betapm   9.1 0.4 0.0 0.0 0.0 0.0  90 0.1 536   6  8K   0 MathKernel/1&lt;br /&gt; 29348 sybase   1.0 0.4 0.0 0.0 0.0 0.0  99 0.0 303   1 29K  12 dataserver/1&lt;br /&gt; 29340 sybase   0.8 0.4 0.0 0.0 0.0 0.0  99 0.0 302   2 26K   9 dataserver/1&lt;br /&gt; 14853 sjing    0.3 0.8 0.0 0.0 0.0 0.0  99 0.0  17   1 727   0 prstat/1&lt;br /&gt; 14831 dbop     0.0 0.9 0.0 0.0 0.0 0.0  99 0.1 826   2  1K   0 find/1&lt;br /&gt; 29341 sybase   0.6 0.3 0.0 0.0 0.0 0.0  99 0.0 297   1 19K   7 dataserver/1&lt;br /&gt; 29342 sybase   0.6 0.2 0.0 0.0 0.0 0.0  99 0.0 298   0 17K   4 dataserver/1&lt;br /&gt; 29349 sybase   0.5 0.2 0.0 0.0 0.0 0.0  99 0.0 298   1 16K   5 dataserver/1&lt;br /&gt; 12063 betapm   0.2 0.4 0.0 0.0 0.0 0.0  99 0.0 505   1  6K   0 MathAddon/1&lt;br /&gt; 29346 sybase   0.4 0.2 0.0 0.0 0.0 0.0  99 0.0 297   1 14K   4 dataserver/1&lt;br /&gt; 29333 sybase   0.4 0.2 0.0 0.0 0.0 0.0  99 0.0 297   0 11K   3 dataserver/1&lt;br /&gt; 29334 sybase   0.4 0.2 0.0 0.0 0.0 0.0  99 0.0 299   0 12K   3 dataserver/1&lt;br /&gt; 29335 sybase   0.4 0.2 0.0 0.0 0.0 0.0  99 0.0 297   1  9K   2 dataserver/1&lt;br /&gt;Total: 141 processes, 4479 lwps, load averages: 0.86, 1.23, 1.82&lt;br /&gt;&lt;br /&gt;LAT : (latency) is the amount of time spent waiting for CPU.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8408201223545797560?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8408201223545797560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8408201223545797560'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/05/solaris-10-performance-tuning-cpu_17.html' title='Solaris 10 Performance Tuning - Analyzing CPU'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3187545016741929786</id><published>2010-04-02T13:38:00.001-07:00</published><updated>2010-05-20T00:44:36.707-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='**Gauge Unix Skill Level**'/><title type='text'>Gauge UNIX Skill Level</title><content type='html'>&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Welcome to Shan's Gauge UNIX Skill Level Test.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here you will find some challenging Unix questions I put together from my daily tasks and readings. Some are the questions I answered at &lt;a href="http://it.toolbox.com/home/signin"&gt;it-toolbox forum&lt;/a&gt;. &lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;You may rate yourself from 1 to 10 first, then start to look at these interesting questions and check your rating again. All answers are discussed in my blog.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 153, 0);"&gt;The skill levels&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;3-5 : easy, user level, e.g. Java developer's UNIX knowledge or junior SA&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;6-7 : medium level, Mid to Senior Level UNIX SAs &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;8-9 : hard, creative, smart Senior SAs with strong computer science background or a guy who can teach UNIX courses at school of continuing eduction&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;10 : reserved for industry experts who can write books for the subject&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Have fun!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-size:85%;" &gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: rgb(255, 255, 102);"&gt;&lt;span style="font-weight: bold; color: rgb(255, 153, 102);"&gt;__BEGIN__&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;------------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;0.(hard)Which directory's "." and ".." have the same i-node number (st_ino) ?&lt;br /&gt;&lt;br /&gt;1.(medium) Why the UNIX command 'cd' must be built into a shell?&lt;br /&gt;&lt;br /&gt;1a. What's wrong with the following shell commands? List at least two ways to fix it?&lt;br /&gt;export pipe=""; ls $pipe wc -l&lt;br /&gt;&lt;br /&gt;1c. (medium) This one is for Linux Administrators - How do you adjust the Linux kernel value for tcp_fin_timeout, tcp_keepalive_time? Can you do it with a few lines of C code?&lt;br /&gt;&lt;br /&gt;2.(creative) Use shell utilities (Perl/sed/awk not allowed) and curl/wget to count the frequency of each word of this webpage.&lt;br /&gt;&lt;br /&gt;For example,&lt;br /&gt;curl http://webpage your_commands&lt;br /&gt;&lt;br /&gt;the output should be:&lt;br /&gt;577 n&lt;br /&gt;499 a&lt;br /&gt;476 data&lt;br /&gt;350 span&lt;br /&gt;336 class&lt;br /&gt;324 br&lt;br /&gt;295 b&lt;br /&gt;266 div&lt;br /&gt;210 post&lt;br /&gt;203 li&lt;br /&gt;199 http&lt;br /&gt;194 href&lt;br /&gt;192 com&lt;br /&gt;165 if&lt;br /&gt;136 the&lt;br /&gt;118 style&lt;br /&gt;115 color&lt;br /&gt;113 title&lt;br /&gt;108 quot&lt;br /&gt;106 blogspot&lt;br /&gt;&lt;br /&gt;2.5 (medium) Use shell utility to reverse text file upside down, e.g.&lt;br /&gt;line1&lt;br /&gt;line2&lt;br /&gt;line3&lt;br /&gt;...&lt;br /&gt;line99&lt;br /&gt;&lt;br /&gt;-&gt;&lt;br /&gt;line99&lt;br /&gt;line98&lt;br /&gt;...&lt;br /&gt;line1&lt;br /&gt;&lt;br /&gt;3.(medium)Use C, Python or Perl (pick 2) to implement a pipe. e.g. "my_pipe cat file1 wc -l" = "cat file1 | wc -l"&lt;br /&gt;&lt;br /&gt;4.(medium) Write a regular expression to match a valid IP address. ( 999.999.999.999 isn't a valid one)&lt;br /&gt;&lt;br /&gt;5.(hard)Why only root can set sticky bit for files?&lt;br /&gt;&lt;br /&gt;6.(web- creative) Write a curl command to login one of major sites with your id/password without using a browser. sites can be ebay, yahoo, youtube, etc.&lt;br /&gt;&lt;br /&gt;7.(creative)How do you copy a terminal to another one? Say tty0 to tty2 and see tty0's real time typing/output from tty2 ? (very useful , you want to know!)&lt;br /&gt;&lt;br /&gt;8.(Enterprise, medium) Write down the commands you use to extend or reduce the size of a mounted, live production vxfs filesystem (sitting on top of a mirrored volume) without using vxresize or veritas command line interface. Of course, you can't use the gui tool. (Hint, there's a difference in action sequence for extending and reducing the size)&lt;br /&gt;&lt;br /&gt;9.(Web, medium) Describe apache AJP connector, how to you configure it? Where the connector is defined inside J2EE container, for example tomcat.&lt;br /&gt;&lt;br /&gt;10.(Enterprise, medium) List 3 different commands you use on AIX to find out the amount of real memory? Describe the general UNIX/AIX performance tuning practice on a dedicated backend database server running AIX 5.3+, Sybase 12.5 with EMC SRDF. (Hint, only from UNIX SA's prospect, DBAs will do their parts)&lt;br /&gt;&lt;br /&gt;11.(medium)Write a sed command to wrap each word in a text file with parenthesis. e.g. abc def -&gt; (abc) (def)&lt;br /&gt;&lt;br /&gt;12.(Web, medium) Describe Apache DSO vs static modules, what's the difference and advantage of DSO? How to compile/configure apache and DSO? How do you find out if your running apache instance is DSO enabled?&lt;br /&gt;&lt;br /&gt;13.(hard) Write sed command to implement gnu grep command's -A1 and -B1 function, e.g. 'grep -A1 -B1'.&lt;br /&gt;&lt;br /&gt;14.(medium)Write a grep command to match "the" but not "them", "theory". etc.&lt;br /&gt;&lt;br /&gt;15.(Web, medium) What are tomcat workers? Describe what's inside workers.properties file&lt;br /&gt;&lt;br /&gt;16.(medium) Describe the procedure and write a sample code using Perl to access mysql database, do query and update records. Do it with Python, Java?&lt;br /&gt;&lt;br /&gt;17.(web- medium) Write a curl command to download a range of files from a site.&lt;br /&gt;&lt;br /&gt;18.(creative)What commands you will use to spy someone's typing and record all his/her terminal session in a file?&lt;br /&gt;&lt;br /&gt;19.(easy)At UNIX shell prompt, how do you find out which tty you are using?&lt;br /&gt;&lt;br /&gt;20.(easy)How do you set your terminal not to display what you type?&lt;br /&gt;&lt;br /&gt;21.(easy)What are ksh/bash "$$" and "$#" variables?&lt;br /&gt;&lt;br /&gt;22.(easy)What's the difference between shell variables "$*" and "$@"?&lt;br /&gt;&lt;br /&gt;23.(medium)Will this cd command "pwd; (cd/usr/local/bin); pwd" changes the current path? Why?&lt;br /&gt;&lt;br /&gt;24.(hard) Write a sed command to add commas to numeric strings, e.g. changing "1234567" to "1,234,567"&lt;br /&gt;&lt;br /&gt;25.(medium)Write a regular expression and use one utility (sed, perl, etc.) to look into a text file and remove all duplicated letters in any word, e.g. change abbcdee -&gt; abcde ... zzfwxxy -&gt;zfwxy.&lt;br /&gt;&lt;br /&gt;26.(medium)Write a sed command to count the number of lines in several files that don't begin with a "#:"&lt;br /&gt;&lt;br /&gt;27.(medium) Write a grep command to display 5 lines before and after the match.&lt;br /&gt;&lt;br /&gt;28.(medium)What does UNIX command "apropos" do?&lt;br /&gt;&lt;br /&gt;29.(medium)At UNIX prompt, how to find out all the commands related to sending signal to processes?&lt;br /&gt;&lt;br /&gt;30.(hard)What does pid "-1" represent in "kill" command?&lt;br /&gt;&lt;br /&gt;31.(medium)How to find out the list of available signals for kill command?&lt;br /&gt;&lt;br /&gt;32.(medium)What does sticky bit is set for file? for directory?&lt;br /&gt;&lt;br /&gt;33.(hard)Why only root can set sticky bit for files?&lt;br /&gt;&lt;br /&gt;34.(hard)Can a user write into a UNIX directory?&lt;br /&gt;&lt;br /&gt;35.(hard)From Unix internal prospect, describe a directory? How many hard links a leaf directory has?&lt;br /&gt;&lt;br /&gt;36.(medium)Who can create a new link that points to a directory?&lt;br /&gt;&lt;br /&gt;37.(hard)List and describe objects that a UNIX filesystem normally has.&lt;br /&gt;&lt;br /&gt;38.(hard)In "ls -l file1" command, what information is NOT included in the inode?&lt;br /&gt;&lt;br /&gt;39.(hard)Which directory's "." and ".." have the same i-node number (st_ino) ?&lt;br /&gt;&lt;br /&gt;40.(medium)How do you stop a running process?&lt;br /&gt;&lt;br /&gt;41.(medium)Which 'ls' option shows files' st_ctime, st_atime and mtime?&lt;br /&gt;&lt;br /&gt;42.(hard)Give examples of Unix functions/commands that change each of a file's 3 time values.&lt;br /&gt;&lt;br /&gt;43.(hard)Can you see an i-node's last access time?&lt;br /&gt;&lt;br /&gt;44.(medium)Explain what's RPC (remote procedure call)? How it works. List one major service relies on rpc.&lt;br /&gt;&lt;br /&gt;45.(medium)Explain the procedures to setup NIS (pick 2 from AIX,Solaris, Linux) and autofs so that users can login from any host inside NIS domain and automounte his/her home directory.&lt;br /&gt;&lt;br /&gt;46.(hard)Describe the difference between multithreaded and multiprocess in UNIX.&lt;br /&gt;&lt;br /&gt;47.(hard)Describe UNIX internal's "the lowest-available-file-descriptor" principle.&lt;br /&gt;&lt;br /&gt;48.(hard)Describe 3 ways to attach STDIN to a file. Use C, Python or Perl to implement it.&lt;br /&gt;&lt;br /&gt;49.(Web, medium) Describe the AJP connector and mod_jk module, function, configuration.&lt;br /&gt;&lt;br /&gt;50.(Web, medium) Describe load balancing tomcat with mod_proxy, configuration and testing.&lt;br /&gt;&lt;br /&gt;51.(Enterprise, creative) Create a solution that utilizes enterprise products Veritas VCS and Solaris 10 Zone to create virtual Solaris servers (v1, v2, v3...) that can have HA features on two physical servers, for example, two SUN M5Ks. Assume your environment has EMC SRDF, extend that design to remote replication and Disaster Recovery (DR) implementation on a remote site.&lt;br /&gt;&lt;br /&gt;52.(Enterprise, Web, hard) Describe a 3-tier web environment, all the products you use, the detail configuration and administration operation of each product (for example, what's .war file, where do you define url mapping in tomcat? what's apache DSO?), pick 2 environments out of the 3 - Linux, Solaris and AIX.&lt;br /&gt;&lt;br /&gt;53.(Enterprise, Web, hard) Describe the local High Availability implementation for each tier in the above 3-tier environment (the technology/products, the implementation)&lt;br /&gt;&lt;br /&gt;54.(Enterprise, Web, hard) Describe your DR/ remote replication design (the technology and implementation) for the above 3-tier environment at both infrastructure and application levels.(Hint, there's no budget issue and you can pick any enterprise or open source products you need)&lt;br /&gt;&lt;br /&gt;55.(Enterprise,medium) A company has over 2000 IT staffs around the world (app developers in India, SAs in Singapore, DBAs in Japan etc), as UNIX engineer, implement a solution to allow each user sign in her/his UNIX accounts and being able to have her/his home directories mounted automatically from any (Linux or Solaris) workstations around the world. Your team is also responsible backing up/restore all the users home directories.&lt;br /&gt;&lt;br /&gt;56.(Enterprise, hard) For the above implementation, add security layers for authentication and account management.&lt;br /&gt;&lt;br /&gt;57. (medium) List 7 types of items that a UNIX filesystem has. What are Perl's file test operators for each item?&lt;br /&gt;&lt;br /&gt;58. (medium) What's the difference between Perl's stat and lstat function?&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------------------------------&lt;br /&gt;ANSWERS: ( If answers are not here, search my blog to find out.)&lt;br /&gt;&lt;br /&gt;Which directory's "." and ".." have the same i-node number (st_ino)?&lt;br /&gt;ls -ila / will show the answer. Why? &lt;a href="http://shanit.blogspot.com/search/label/Unix%20System%20Programming%20%28C%20Python%29"&gt;Answer&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Why the UNIX "cd" command must be built into the shells?&lt;br /&gt;Because the shell forks a child process to run chdir function to change directory, once the child process terminates, the child's working directory can not affect the shell's. Therefore, the shell's working directory can never be changed by its child process. For this reason, the chdir function has to be called directly from the shell. This is why cd is built into the shells.&lt;br /&gt;&lt;br /&gt;export pipe=""; ls $pipe wc -l&lt;br /&gt;The shell take care of pipes and I/O redirection BEFORE variable substitution, therefore, it nver recognizes the pipe symbol inside pipe. The result is that the three arguments , wc and -l are passed to "ls" command as arguments.&lt;br /&gt;&lt;br /&gt;Solutions:&lt;br /&gt;a. eval export pipe=""; ls $pipe wc -l&lt;br /&gt;(eval will have shell scan the command sequence twice before executing it. If the variables contain any characters that must be seen by the shell directly on the command line, then eval can be useful.)&lt;br /&gt;&lt;br /&gt;b. Just type "ls wc -l".&lt;br /&gt;&lt;br /&gt;sysctl -p the following configuration file:&lt;br /&gt;&lt;br /&gt;# Decrease the time default value for tcp_fin_timeout connection.&lt;br /&gt;net.ipv4.tcp_fin_timeout = 30&lt;br /&gt;&lt;br /&gt;# Decrease the time default value for tcp_keepalive_time connection&lt;br /&gt;net.ipv4.tcp_keepalive_time = 1800&lt;br /&gt;&lt;br /&gt;# Turn off tcp_window_scaling&lt;br /&gt;net.ipv4.tcp_window_scaling = 0&lt;br /&gt;&lt;br /&gt;# Turn off the tcp_sack&lt;br /&gt;net.ipv4.tcp_sack = 0&lt;br /&gt;&lt;br /&gt;# Turn off tcp_timestamps&lt;br /&gt;net.ipv4.tcp_timestamps = 0&lt;br /&gt;&lt;br /&gt;See Hack #71 in &lt;a href="http://books.google.com/books?id=iAh6mU_sjgsC&amp;amp;printsec=frontcover&amp;amp;dq=Hack+Linux+Server+volume+two&amp;amp;ei=q9y0S6C5ComoM4HdwKEP&amp;amp;cd=1#v=onepage&amp;amp;q=Hack%20Linux%20Server%20volume%20two&amp;amp;f=false"&gt;this book&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Use shell utilities (Perl/Sed/awk not allowed) to count the frequency of each English word of this webpage.&lt;br /&gt;$ curl 'http://shanit.blogspot.com/2009/10/unix-handy-tools-for-system.html' tr -sc a-zA-Z '\012' sort uniq -c sort -nr&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current&lt;br /&gt;Dload  Upload   Total   Spent    Left  Speed&lt;br /&gt;100 83662    0 83662    0     0   305k      0 --:--:-- --:--:-- --:--:--  533k&lt;/pre&gt;&lt;br /&gt;497 n&lt;br /&gt;425 span&lt;br /&gt;409 data&lt;br /&gt;306 a&lt;br /&gt;241 b&lt;br /&gt;238 class&lt;br /&gt;230 br&lt;br /&gt;217 div&lt;br /&gt;185 style&lt;br /&gt;181 post&lt;br /&gt;142 font&lt;br /&gt;140 color&lt;br /&gt;&lt;br /&gt;To reverse file vertically, e.g. the last line becomes the first line.&lt;br /&gt;nl input_file  sort -nr  sed 's/^.\{7\}//'&lt;br /&gt;&lt;br /&gt;Will this cd command "pwd; (cd/usr/loca/bin); pwd" changes the current path? Why?&lt;br /&gt;No. Commands inside () are executed in a subshell.&lt;br /&gt;&lt;br /&gt;Write a sed command to wrap each word in a text file with parenthesis. e.g. abc def -&gt; (abc) (def)&lt;br /&gt;sed 's/[A-Za-z][A-Za-z]*/(&amp;amp;)/g' &amp;lt;inputfile&gt; output&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Use sed implement 'grep -A1 -B1' (note: grep -A -B options are NOT available on Solaris, you may sed or perl, awk instead. Sure, how do you implement it with Perl, awk? :-))&lt;br /&gt;sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h&lt;br /&gt;&lt;br /&gt;Write a sed command to add commas to numeric strings, e.g. changing "1234567" to "1,234,567"&lt;br /&gt;sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Write a regular expression and use one utility (sed, perl, etc.) to look into a text file and remove all duplicated letters in any word, e.g. change abbcdee -&gt; abcde ... zzfwxxy -&gt;zfwxy.&lt;br /&gt;&lt;br /&gt;2 ways to do it:&lt;br /&gt;a. &lt;span style="font-weight: bold;"&gt;[shan@ipc4 ~]$ sed -n 's@\([a-zA-Z]\)\1*@\1@pg' &amp;lt; input &amp;gt; output&lt;/span&gt;&lt;br /&gt;b. echo "aabccdee" tr -s [[:alpha:]]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Use curl to sign in a major site such as yahoo! youtube or ebay. &lt;a href="http://shanit.blogspot.com/2009/12/auto-fetch-webpagessign-in-websites.html"&gt;Answer.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;List 3 different commands you use on AIX to find out the amount of real memory? Describe the general UNIX/AIX performance tuning practice.&lt;br /&gt;&lt;a href="http://shanit.blogspot.com/search/label/AIX%20Administration"&gt;Answers.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Write a sed command to count the number of lines in several files that don't begin with a "#:"&lt;br /&gt;sed 's/^#.*//' file1 file2 file3 grep -v '^$' wc -l&lt;br /&gt;&lt;br /&gt;Write a grep command to match "the" not "thexyz..." such as "them", "theory".&lt;br /&gt;&lt;br /&gt;What are ksh/bash "$$" and "$#" variables ?&lt;br /&gt;$ is the pid of current shell&lt;br /&gt;$# is the number of the positional parameters to the command&lt;br /&gt;&lt;br /&gt;What's the difference between shell variables "$*" and "$@"?&lt;br /&gt;$* expands to all positional parameters passed to the command&lt;br /&gt;$@ expands to all positional parameters passed to the command, but individually quoted when "$@" is used.&lt;br /&gt;&lt;br /&gt;What does UNIX command "apropos" do?&lt;br /&gt;man -k keyword&lt;br /&gt;&lt;br /&gt;Usage: find out all the commands related to sending signal to processes:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);font-family:courier new;" &gt;[root@ipc4 ~]# apropos kill grep signal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;kill (2) - send signal to a process&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;killpg (2) - send signal to a process group&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;killpg (3) - send signal to all members of a process group&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;pkill [pgrep] (1) - look up or signal processes based on name and other attributes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;pthread_kill [pthread_sigmask] (3thr) - handling of signals in threads&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;skill (1) - send a signal or report process status&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;snice [skill] (1) - send a signal or report process status&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;tkill (2) - send a signal to a single process&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:georgia;"&gt;What's the default signal sent by "kill" command ?&lt;br /&gt;&lt;br /&gt;What's this command does? "kill -9 -1" &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;How to find out the list of available signals for kill command?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);font-family:courier new;" &gt;[root@ipc4 ~]# kill -l&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;64) SIGRTMAX&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or, we can see the linux programmer's manual&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 ~]# apropos signal grep list&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;signal (7) - list of available signals&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 ~]# man 7 signal col -b grep SIG head -20&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGNAL(7) Linux Programmerâs Manual SIGNAL(7)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGHUP 1 Term Hangup detected on controlling terminal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGINT 2 Term Interrupt from keyboard&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGQUIT 3 Core Quit from keyboard&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGILL 4 Core Illegal Instruction&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGABRT 6 Core Abort signal from abort(3)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGFPE 8 Core Floating point exception&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGKILL 9 Term Kill signal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGSEGV 11 Core Invalid memory reference&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGPIPE 13 Term Broken pipe: write to pipe with no readers&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGALRM 14 Term Timer signal from alarm(2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGTERM 15 Term Termination signal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGUSR1 30,10,16 Term User-defined signal 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGUSR2 31,12,17 Term User-defined signal 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGCHLD 20,17,18 Ign Child stopped or terminated&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGCONT 19,18,25 Continue if stopped&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGSTOP 17,19,23 Stop Stop process&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGTSTP 18,20,24 Stop Stop typed at tty&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGTTIN 21,21,26 Stop tty input for background process&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SIGTTOU 22,22,27 Stop tty output for background process&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What does sticky bit is set for file? for directory?&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;A sticky bit is set for an executable file, then a copy of the binary (after the first time it's executed) is saved in the swap area when the process terminated. For editors or other common programs, sticky bit is set.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;Only the superuser can set the sticky bit (S_ISVTX) of a regular file. This is to prevent malicious users from setting the sticky bit and trying to fill up the swap area.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;When a sticky bit is set for a directory (-t on the directories group access mode), a file in the directory can be removed or renamed only if the user has write permission for the directory and either owns the file, owns the directory or is the superuser. /tmp has sticky bit set for directory.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;Can a user write into a UNIX directory? NO. Only the kernel can write to a directory.&lt;br /&gt;&lt;br /&gt;A directory is just a file containing directory entries(filenames and associate i-node numbers). Adding, deleting, or modifying these directory entries can affect all three times associated with that directory. With permissions, we can create new files in the direcotry and remove files from it, but we can't write to the directory itself.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What is a directory? How many hard links a leaf directory has? Who can create a new link that points to a directory?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/SupUeeZe6bI/AAAAAAAACRk/nd1XGitKv6U/s1600-h/inode2.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5398219985889716658" style="display: block; margin: 0px auto 10px; width: 320px; cursor: pointer; height: 138px; text-align: center;" alt="" src="http://4.bp.blogspot.com/_if8QouXbicI/SupUeeZe6bI/AAAAAAAACRk/nd1XGitKv6U/s320/inode2.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A filesystem normally has boot block, super block, i-node list, directory and data blocks.&lt;br /&gt;&lt;br /&gt;The i-node contains all the information about the file: the file type, the file's access permission bits, the size of the file, pointers to the data blocks for the file, and so on. Most of the information in the stat structure is obtained from the i-node. Only two items are stored in the directory entry: the filename and the i-node number.&lt;br /&gt;&lt;br /&gt;When renaming a file without changing filesystems, the actual content of the file need not be moved - all that needs to be done is to have a new directory entry point to the existing i-node and have the old directory entry removed.&lt;br /&gt;&lt;br /&gt;Since the i-node number in the directory entry points to an i-node in the same filesystem, we cannot have a directory entry pint to an-inode in a different filesystem. This is why hardlink can't cross filesystems.&lt;br /&gt;&lt;br /&gt;With a symbolic link, the actual contents of the file (the data blocks) contains the name of the file that the symbolic link points to.&lt;br /&gt;&lt;br /&gt;Each i-node has a link count that contains the number of directory entries that point to the i-node. When the link count goes to 0 can the file be deleted. This is why "unlinking a file" does not always mean "deleting the blocks associated with the file." They is why the function that removes a directory is called unlink not delete.&lt;br /&gt;&lt;br /&gt;Which directory's "." and ".." have the same i-node number (st_ino) ? /&lt;br /&gt;&lt;br /&gt;How do you stop (not kill) a running process?&lt;br /&gt;control-Z&lt;br /&gt;bg - brings it to background&lt;br /&gt;fg - brings it to foreground&lt;br /&gt;% list jobs&lt;br /&gt;&lt;br /&gt;Which 'ls' option shows files' st_ctime, st_atime and mtime? Give examples of Unix functions/commands that change each of a file's 3 time values.&lt;br /&gt;&lt;br /&gt;&lt;table class="allBorders" style="color: rgb(255, 255, 255);" rules="groups" border="1" cellpadding="5" cellspacing="0"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th class="rightBorder bottomBorder thead" scope="col" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;Field&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;th class="rightBorder bottomBorder thead" scope="col" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;th class="rightBorder bottomBorder thead" scope="col" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;Example&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;th class="bottomBorder thead" scope="col" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;&lt;tt&gt;ls&lt;/tt&gt;(1) option&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;st_atime&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;last-access time of file data&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;read&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="docTableCell" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;-u&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;st_mtime&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;last-modification time of file data&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;write&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="docTableCell" align="middle" valign="top"&gt;&lt;p class="docText"&gt;default&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;st_ctime&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;last-change time of i-node status&lt;/p&gt;&lt;/td&gt;&lt;td class="rightBorder" align="left" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;chmod, chown&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;td class="docTableCell" align="middle" valign="top"&gt;&lt;p class="docText"&gt;&lt;tt&gt;-c&lt;/tt&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;ls -u : atime&lt;br /&gt;ls -t : mtime(default)&lt;br /&gt;ls -c : ctime&lt;br /&gt;&lt;br /&gt;st_mtime is the modification time - when the contents of the file were last changed.&lt;br /&gt;st_ctime is when the i-node of the file was last modified such as chmod, chown, link, etc.&lt;br /&gt;Because all the information in the i-node is stored separately from the actual contents of the file,we need the changed-status time.&lt;br /&gt;&lt;br /&gt;Can you see an i-node's last access time?&lt;br /&gt;No. The system doesn't maintain the last-access time for an i-node. This is why functions like 'access' and 'stat' don't change any of the three times.&lt;br /&gt;&lt;br /&gt;UNIX filesystem's 7 types of items and the Perl's file test operators for each item:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Item                    Perl's File Test&lt;br /&gt;====                    ================&lt;br /&gt;file                    -f&lt;br /&gt;directory               -d&lt;br /&gt;symbolic link           -l&lt;br /&gt;socket                  -S&lt;br /&gt;named pipe(fifo)        -p&lt;br /&gt;block-special file      -b&lt;br /&gt;character-special file  -c&lt;br /&gt;&lt;br /&gt;What's the difference between Perl's stat and lstat function?&lt;br /&gt;stat returns fs information for files and directories while lstat returns information for symbolic links.&lt;br /&gt;&lt;/pre&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/SupUyAdqxQI/AAAAAAAACRs/j42HYxwvZOA/s1600-h/inode-detail.jpg"&gt;Figure - i-node structure&lt;/a&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;All tomcat/apache questions are discussed at my blog's &lt;a href="http://shanit.blogspot.com/search/label/Web%20Admin%20-%20Apache%20Tomcat%20Weblogic%20Java"&gt;Web/Apache Section&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;All AIX/Solaris related questions are discussed at my blog's &lt;a href="http://shanit.blogspot.com/search/label/Solaris%2010%20Administration"&gt;Solaris&lt;/a&gt; and &lt;a href="http://shanit.blogspot.com/2009/12/aix-paging-space-management.html"&gt;AIX&lt;/a&gt; Sections.&lt;br /&gt;&lt;br /&gt;All TCP/IP related questions are discussed at my blog's &lt;a href="http://shanit.blogspot.com/search/label/TCP%2FIP%20Protocols%20and%20Security"&gt;TCP/IP Sections&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;My thoughts about "UNIX Administrator" vs "Enterprise Administrator in UNIX environments" -&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:georgia;font-size:100%;"  &gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;In my personal opinion, to gauge a UNIX SA's skill level, the general UNIX and computer science background are more important than the knowledge of certain enterprise products. For over 10 years, I have been working with all kinds of enterprise technologies such as Veritas VCS, VXFS, EMC, AIX, Solaris, etc. I have 12 - 15 certificates for enterprise products; but I just don't feel it is very hard to learn and adm&lt;span style="color: rgb(255, 255, 102);"&gt;inistrate these enterprise products at senior levels (compare to mastering vim, sed or regular expressions); moreover, you don't need a computer science degree to create a Veritas filesystem or setup a cluster.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;It is very common that a good portion of "UNIX" administrators who know how to jumpstart Solaris, attach EMC luns or setup NFS in AIX or Solaris still cut and paste/use bash shell's arrow keys to recall commands in UNIX shell; still manually update text file without knowing how to use sed/regular expression. These folks are &lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;"Enterprise System Administrators"&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);"&gt; not UNIX administrators. They happen to work in UNIX environment instead of Windows. Please keep mind that people will gauge UNIX skill levels by just watching a few things you do in UNIX such as how you use shell utilities, use vi/vim, etc. If you are weak in these areas, please fix them asap because, at least, these tools can increase your productivity.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;On the other hand, people don't have experience on those enterprise products is not because they can't understand them; it is because they don't have access to the enterprise environment.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Finally, I rate what I know about UNIX as a drop of water in the UNIX knowledge sea. I'm very happy to work inside UNIX/Linux environment because I can always learn something new everyday.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3187545016741929786?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3187545016741929786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3187545016741929786'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html' title='Gauge UNIX Skill Level'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_if8QouXbicI/SupUeeZe6bI/AAAAAAAACRk/nd1XGitKv6U/s72-c/inode2.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4712357669318660239</id><published>2010-04-02T13:34:00.000-07:00</published><updated>2010-04-02T13:45:08.514-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Admin - Apache Tomcat Weblogic Java'/><title type='text'>Web Admin - Apache Tomcat Weblogic Java</title><content type='html'>&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/weblogic-setup-quick-guide.html"&gt;Weblogic Setup Quick Guide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/installing-modjk-in-1-minute.html"&gt;Installing modjk Quick Guide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;Generating SSL Certificate for Apache Web Server&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Test Your UNIX Skills&lt;/a&gt; (fun test!)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4712357669318660239?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4712357669318660239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4712357669318660239'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/web-admin-apache-tomcat-weblogic-java.html' title='Web Admin - Apache Tomcat Weblogic Java'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5050387889990651145</id><published>2010-04-02T13:23:00.000-07:00</published><updated>2010-04-02T13:54:49.757-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Scripting (Perl, Shell, Python)</title><content type='html'>&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;Compiling and Installing Net::SSH::Perl - SSH Module for Perl&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html"&gt;Perl  Regular Expression Summary&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/troubleshooting-perls-dbdmysql.html"&gt;Accessing MySQL Database with Perl DBD:DBI&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/auto-fetch-webpagessign-in-websites.html"&gt;Auto Sign-in Websites/Auto Fetch Webpages with Curl and Perl&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/advanced-shell-part-1.html"&gt;Shell Scripting Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/interesting-tasks-for-shell-scripting.html"&gt;Shell Scripting Challenging Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/11/jump-between-your-code-and-python.html"&gt;Configure Vim as Python IDE&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Test Your Scripting Skills &lt;/a&gt; (New!)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3 class="post-title entry-title"&gt;&lt;a href="http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-5050387889990651145?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5050387889990651145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5050387889990651145'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/scripting-perl-shell-python.html' title='Scripting (Perl, Shell, Python)'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7207064958929691363</id><published>2010-04-02T12:53:00.000-07:00</published><updated>2010-04-02T13:47:57.029-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux Administration (RHEL Ubuntu)</title><content type='html'>&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-rpm-and-open-source-development.html"&gt;Linux RPM and Open-Source Development Tools&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-ext3-quick-guide.html"&gt;Linux Filesystem Ext3/Ext2 Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-nfs-quickguide.html"&gt;Linux NFS Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;Linux Portmapper/RPC Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-performance-tuning-1.html"&gt;Linux Performance Tuning, Kernel Tuning Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/04/linux-security-1.html"&gt;Linux System Security Part 1&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understands-openssl-and-public-key.html"&gt;Linux Openssl Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/understand-ssh-agent-forwarding-in-1.html"&gt;Linux OpenSSH Agent Forwarding Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html"&gt;Linux Generating Certificate for Apache&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/setup-kerberos-kds-in-1-minute.html"&gt;Linux Compile and Setup Kerberos Quick Guide&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html"&gt;Installing Ubuntu 9.10 on Vmware Host&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Test Your Linux/Unix Skills&lt;/a&gt; (new!)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S7ZNukAq3SI/AAAAAAAACxA/ZsAske2KJxw/s1600/linux.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 225px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S7ZNukAq3SI/AAAAAAAACxA/ZsAske2KJxw/s400/linux.jpg" alt="" id="BLOGGER_PHOTO_ID_5455633460941741346" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7207064958929691363?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7207064958929691363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7207064958929691363'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-administration-rhel-ubuntu.html' title='Linux Administration (RHEL Ubuntu)'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_if8QouXbicI/S7ZNukAq3SI/AAAAAAAACxA/ZsAske2KJxw/s72-c/linux.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8385278356484352380</id><published>2010-04-02T12:41:00.000-07:00</published><updated>2010-04-02T12:43:53.797-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux RPM and Open-Source Development Tools</title><content type='html'>rpm -Querying/Verifying, -  &lt;br /&gt;&lt;br /&gt;-q selection-options  -l&lt;br /&gt;&lt;br /&gt;rpm -q --whatprovides /usr/bin/gcc   ; rpm -ql gcc&lt;br /&gt;&lt;br /&gt;-U (--upgrade)  -F (--freshen : only upgrade the installed packages)&lt;br /&gt;&lt;br /&gt;rpm --showrc&lt;br /&gt;&lt;br /&gt;shows the values rpm will use for all of the options are currently set in rpmrc and macros configuration file(s). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rpm -ivh {rpm-file}   Install the package   &lt;br /&gt;Examples:&lt;br /&gt;rpm -ivh mozilla-mail-1.7.5-17.i586.rpm&lt;br /&gt;rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm&lt;br /&gt;&lt;br /&gt;rpm -Uvh {rpm-file}  Upgrade package  &lt;br /&gt;Examples:&lt;br /&gt;rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm&lt;br /&gt;rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm&lt;br /&gt;&lt;br /&gt;rpm -ev {package}  Erase/remove/ an installed package  &lt;br /&gt;Examples:&lt;br /&gt;rpm -ev mozilla-mail&lt;br /&gt;rpm -ev --nodeps {package}  Erase/remove/ an installed package without checking for dependencies  &lt;br /&gt;rpm -ev --nodeps mozilla-mail&lt;br /&gt;&lt;br /&gt;rpm -qa  Display list all installed packages  &lt;br /&gt;rpm -qa&lt;br /&gt;rpm -qa | less&lt;br /&gt;&lt;br /&gt;rpm -qi {package}  Display installed information along with package version and short description  &lt;br /&gt;rpm -qi mozilla-mail&lt;br /&gt;&lt;br /&gt;rpm -qf {/path/to/file} Find out what package a file belongs to i.e. find what package owns the file  &lt;br /&gt;rpm -qf /etc/passwd&lt;br /&gt;rpm -qf /bin/bash&lt;br /&gt;&lt;br /&gt;rpm -qc {pacakge-name}  Display list of configuration file(s) for a package  &lt;br /&gt;rpm -qc httpd&lt;br /&gt;&lt;br /&gt;rpm -qcf {/path/to/file}  Display list of configuration files for a command  &lt;br /&gt;rpm -qcf /usr/X11R6/bin/xeyes&lt;br /&gt;&lt;br /&gt;rpm -qa --last  Display list of all recently installed RPMs  &lt;br /&gt;rpm -qa --last&lt;br /&gt;rpm -qa --last | less&lt;br /&gt;&lt;br /&gt;rpm -qpR {.rpm-file}&lt;br /&gt;rpm -qR {package}  Find out what dependencies a rpm file has  &lt;br /&gt;rpm -qpR mediawiki-1.4rc1-4.i586.rpm&lt;br /&gt;rpm -qR bash&lt;br /&gt;&lt;br /&gt;Compile Open Source Code:&lt;br /&gt;&lt;br /&gt;Static Libraries&lt;br /&gt;&lt;br /&gt;also known as archives, have their names end with .a . /usr/lib/libss.a&lt;br /&gt;&lt;br /&gt;.a is created and maintained by ar utility.  &lt;br /&gt;&lt;br /&gt;To create static library:&lt;br /&gt;&lt;br /&gt;ar crv lib1.a prog1.o prog2.o&lt;br /&gt;&lt;br /&gt;[root@localhost lib]# ar -t libss.a&lt;br /&gt;ss_err.o&lt;br /&gt;std_rqs.o&lt;br /&gt;invocation.o&lt;br /&gt;help.o&lt;br /&gt;execute_cmd.o&lt;br /&gt;listen.o&lt;br /&gt;parse.o&lt;br /&gt;error.o&lt;br /&gt;prompt.o&lt;br /&gt;request_tbl.o&lt;br /&gt;list_rqs.o&lt;br /&gt;pager.o&lt;br /&gt;requests.o&lt;br /&gt;data.o&lt;br /&gt;get_readline.o&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost lib]# cd&lt;br /&gt;[root@localhost ~]# vi prog1.c&lt;br /&gt;[root@localhost ~]# vi prog2.c&lt;br /&gt;[root@localhost ~]# vi prog1.c&lt;br /&gt;[root@localhost ~]# gcc -c prog1.c prog2.c&lt;br /&gt;[root@localhost ~]# ls *.o&lt;br /&gt;prog1.o  prog2.o&lt;br /&gt;[root@localhost ~]# vi lib.h&lt;br /&gt;[root@localhost ~]# vi prog2.c&lt;br /&gt;[root@localhost ~]# gcc -c prog1.c prog2.c&lt;br /&gt;[root@localhost ~]# vi program.c&lt;br /&gt;[root@localhost ~]# gcc -c program.c&lt;br /&gt;[root@localhost ~]# gcc -o program program.o prog1.o&lt;br /&gt;[root@localhost ~]# ./program&lt;br /&gt;Shan: you won 134513872&lt;br /&gt;&lt;br /&gt;[root@localhost ~]# ar crv libshan.a prog1.o prog2.o&lt;br /&gt;a - prog1.o&lt;br /&gt;a - prog2.o&lt;br /&gt;&lt;br /&gt;[root@localhost ~]# ar -t libshan.a&lt;br /&gt;prog1.o&lt;br /&gt;prog2.o&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;extra member from archive&lt;br /&gt;[root@localhost tmp]# ar x libshan.a&lt;br /&gt;[root@localhost tmp]# ls&lt;br /&gt;libshan.a  prog1.o  prog2.o&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Use nm to see which functions are included in an object file, library or executable program(if compiled with symbols).&lt;br /&gt;[root@localhost tmp]# nm program.o&lt;br /&gt;         U exit&lt;br /&gt;00000000 T main&lt;br /&gt;         U prog1&lt;br /&gt;[root@localhost tmp]# cat ../program.c&lt;br /&gt;#include "lib.h"&lt;br /&gt;int main ()&lt;br /&gt;{&lt;br /&gt;        prog1("1000000");&lt;br /&gt;exit (0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost ~]# ldd program&lt;br /&gt;        libc.so.6 =&gt; /lib/tls/libc.so.6 (0x0018a000)&lt;br /&gt;        /lib/ld-linux.so.2 (0x00171000)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Probem with Static libraries: when many running processes need to use the same function (provided by static lib),&lt;br /&gt;the system ends up with many copies of the same code/functions in memory.&lt;br /&gt;&lt;br /&gt;Shared Library solves this problem.  When a program uses a shred lib, it doesn't contain the function code but&lt;br /&gt;it references to shared code that will be available at run time.  When the resulting program is loaded into &lt;br /&gt;memory to be executed, the function references are resolved and calls are made to the shared library, which will&lt;br /&gt;be loaded into the memory if needed.&lt;br /&gt;&lt;br /&gt;In this way, the system can just have a single copy of a shared library to be used by many applications at once.&lt;br /&gt;An additional benefit is that the shared library can be updated independently of the programs that rely on it &lt;br /&gt;because symbolic links from the file /lib/libc.so.6 to the actual library revision libc-2.3.4.so is used. &lt;br /&gt;&lt;br /&gt;rwxrwxrwx  1 root root 13 Oct 30 12:04 /lib/tls/libc.so.6 -&gt; libc-2.3.4.so&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cyberciti.biz/howto/question/linux/linux-rpm-cheat-sheet.php"&gt;RMP cheat page.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8385278356484352380?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8385278356484352380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8385278356484352380'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-rpm-and-open-source-development.html' title='Linux RPM and Open-Source Development Tools'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4242456688085438390</id><published>2010-04-02T12:40:00.000-07:00</published><updated>2010-04-02T12:41:04.121-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux Security 1</title><content type='html'>Network Security&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; # Controls IP packet forwarding&lt;br /&gt; net.ipv4.ip_forward = 0&lt;br /&gt;&lt;br /&gt;        # Disable response to broadcasts.&lt;br /&gt;        net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt; net.ipv4.icmp_ignore_bogus_error_responses = 1&lt;br /&gt;        &lt;br /&gt;        # enable route verification on all interfaces&lt;br /&gt;        net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NFS Security&lt;br /&gt;&lt;br /&gt;Only run NFS as needed, apply latest patches. &lt;br /&gt;When creating your /etc/exports file, be certain to use limited access flags when possible such as readonly or &lt;br /&gt;nosuid. By using fully qualified hostnames, you are guaranteed that only the host you want to be able to &lt;br /&gt;access the filesystem can access it. &lt;br /&gt;&lt;br /&gt;If you are exporting file-systems using NFS, be sure to configure /etc/exports with the most restrictive access &lt;br /&gt;possible. This means not using wild cards, not allowing root write access, and exporting read-only wherever &lt;br /&gt;possible. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Device Security&lt;br /&gt;&lt;br /&gt;Device files /dev/null, /dev/tty &amp; /dev/console should be world writeable but NEVER executable. Most other &lt;br /&gt;device files should be unreadable and unwriteable by regular users. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Script Security&lt;br /&gt;&lt;br /&gt;Never write setuid/setgid shell scripts (can break out). Instead, write a compiled program in a language &lt;br /&gt;like "C". Scripts should ALWAYS have full pathnames. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Program Security&lt;br /&gt;&lt;br /&gt;Always get your programs from a known source. Verify that it hasn't been hampered with via checksum. If &lt;br /&gt;you are compiling your own program, make sure you know that the compiler hasn't been tampered with as well. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;General Security Measures&lt;br /&gt;&lt;br /&gt;Create minimal writable filesystems (esp. system files/directories!). Generally, users should only be able &lt;br /&gt;to write in their own directories, and /tmp. In addition, there will be directories for a specific group to &lt;br /&gt;write in. This way you control how each user can access specific areas of the system. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;root#  find / -type f \( -perm -04000 -o -perm -02000 \)&lt;br /&gt;&lt;br /&gt;root# find / -perm -2 ! -type l -ls&lt;br /&gt;&lt;br /&gt;root# find / \( -nouser -o -nogroup \) -print&lt;br /&gt;&lt;br /&gt;root# find /home -name .rhosts -print&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Set file system limits instead of allowing unlimited  as is the default. You can control the per-user limits using the resource-limits PAM module and /etc/pam.d/limits.conf. For example, limits for group users might look like this:&lt;br /&gt;&lt;br /&gt;  @users     hard  core    0&lt;br /&gt;  @users     hard  nproc   50&lt;br /&gt;  @users     hard  rss     5000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can also use the /etc/login.defs configuration file to set the same limits.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4242456688085438390?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4242456688085438390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4242456688085438390'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-security-1.html' title='Linux Security 1'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8101251972813791857</id><published>2010-04-02T12:34:00.000-07:00</published><updated>2010-04-30T10:27:40.580-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux - Performance Tuning 1</title><content type='html'>Linux - Performance Tuning 1&lt;br /&gt;&lt;br /&gt;Useful top and pstree commands  to show process/threads&lt;br /&gt;&lt;br /&gt;#show process tree with pid -p owned by user -u&lt;br /&gt;&lt;span style="color:#ffff66;"&gt;$pstree -aG -p -u username&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#same as above but use ASCII chars to draw the tree. -A&lt;br /&gt;&lt;span style="color:#ffff66;"&gt;$pstree -aA -p -u username&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#top in batch mode -b , show 3 iternations -n and delay 2.5sec -d for user -u&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;&lt;span style="color:#ffff66;"&gt;$top -b -n 3 -d 2.5 -u username&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;#same as above but display threads instead of just process -H&lt;br /&gt;&lt;span style="color:#ffff66;"&gt;$top -H -b -n 3 -d 2.5 -u sjing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$top -p pid&lt;br /&gt;&lt;br /&gt;#Linux : check if Processor (hardware) is 64 bit lm (long mode)&lt;br /&gt;$grep lm /proc/cpuinfo&lt;br /&gt;&lt;br /&gt;(inside top, type "A" will enter multi-windows mode)&lt;br /&gt;&lt;br /&gt;vmstat -d -p partition&lt;br /&gt;&lt;br /&gt;vmstat -m&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Probably sysctl is the best tool for tuning linux systems. It can configure a lot of system parameters while the linux kernel&lt;br /&gt;is running. It handles this, by reading and writing to kernel variables through procfs files.&lt;br /&gt;&lt;br /&gt;sysctl - configure kernel parameters at runtime. The parameters available are those listed under /proc/sys/.&lt;br /&gt;&lt;br /&gt;sysctl -a&lt;br /&gt;&lt;br /&gt;sysctl -w variable=value. For example, sysctl -w net.ipv6.conf.all.forwarding=1&lt;br /&gt;&lt;br /&gt;sysctl -w kernel.shmmax=63554432&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sysctl -p&lt;br /&gt;&lt;br /&gt;root@ubuntu:~# sysctl -a&lt;br /&gt;kernel.sched_min_granularity_ns = 8000000&lt;br /&gt;kernel.sched_latency_ns = 40000000&lt;br /&gt;kernel.sched_wakeup_granularity_ns = 10000000&lt;br /&gt;kernel.sched_shares_ratelimit = 500000&lt;br /&gt;kernel.sched_shares_thresh = 4&lt;br /&gt;kernel.sched_child_runs_first = 1&lt;br /&gt;kernel.sched_features = 113916&lt;br /&gt;kernel.sched_migration_cost = 500000&lt;br /&gt;kernel.sched_nr_migrate = 32&lt;br /&gt;kernel.timer_migration = 1&lt;br /&gt;kernel.sched_rt_period_us = 1000000&lt;br /&gt;kernel.sched_rt_runtime_us = 950000&lt;br /&gt;kernel.sched_compat_yield = 0&lt;br /&gt;kernel.panic = 0&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;sysctl displays kernel setting in the following categories:&lt;br /&gt;&lt;br /&gt;kernel&lt;br /&gt;vm&lt;br /&gt;fs&lt;br /&gt;debug&lt;br /&gt;dev&lt;br /&gt;net&lt;br /&gt;crypto&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A very good guide to "top" utility is at &lt;a href="http://www.linuxforums.org/articles/using-top-more-efficiently_89.html"&gt;here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost ~]# top -b -n 1&lt;br /&gt;top - 12:50:59 up 1:11, 5 users, load average: 0.22, 0.24, 0.17&lt;br /&gt;Tasks: 129 total, 2 running, 126 sleeping, 0 stopped, 1 zombie&lt;br /&gt;Cpu(s): 1.9% us, 2.8% sy, 0.1% ni, 89.0% id, 3.7% wa, 0.1% hi, 2.4% si&lt;br /&gt;Mem: 514516k total, 321012k used, 193504k free, 36688k buffers&lt;br /&gt;Swap: 1048568k total, 0k used, 1048568k free, 173132k cached&lt;br /&gt;&lt;br /&gt;PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND&lt;br /&gt;7438 root 16 0 2552 968 740 S 3.9 0.2 0:04.36 top&lt;br /&gt;8662 root 15 0 3784 856 648 R 3.9 0.2 0:00.03 top&lt;br /&gt;1 root 16 0 2372 548 468 S 0.0 0.1 0:04.49 init&lt;br /&gt;2 root RT 0 0 0 0 S 0.0 0.0 0:00.71 migration/0&lt;br /&gt;3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0&lt;br /&gt;4 root RT 0 0 0 0 S 0.0 0.0 0:00.62 migration/1&lt;br /&gt;5 root 34 19 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/1&lt;br /&gt;6 root 5 -10 0 0 0 S 0.0 0.0 0:00.78 events/0&lt;br /&gt;7 root 5 -10 0 0 0 S 0.0 0.0 0:00.52 events/1&lt;br /&gt;8 root 5 -10 0 0 0 S 0.0 0.0 0:00.11 khelper&lt;br /&gt;9 root 15 -10 0 0 0 S 0.0 0.0 0:00.00 kacpid&lt;br /&gt;90 root 5 -10 0 0 0 S 0.0 0.0 0:00.55 kblockd/0&lt;br /&gt;91 root 5 -10 0 0 0 S 0.0 0.0 0:00.51 kblockd/1&lt;br /&gt;92 root 15 0 0 0 0 S 0.0 0.0 0:00.00 khubd&lt;br /&gt;101 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pdflush&lt;br /&gt;102 root 15 0 0 0 0 S 0.0 0.0 0:01.38 pdflush&lt;br /&gt;104 root 7 -10 0 0 0 S 0.0 0.0 0:00.00 aio/0&lt;br /&gt;105 root 5 -10 0 0 0 S 0.0 0.0 0:00.00 aio/1&lt;br /&gt;103 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0&lt;br /&gt;179 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kseriod&lt;br /&gt;250 root 19 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0&lt;br /&gt;267 root 6 -10 0 0 0 S 0.0 0.0 0:00.00 kmirrord/0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Field Description&lt;br /&gt;PID : Process ID&lt;br /&gt;USER : Effective User ID&lt;br /&gt;PR : Dynamic priority&lt;br /&gt;NI : Nice value, also known as base priority&lt;br /&gt;VIRT : Virtual Size of the task. This includes the size of process's executable binary, the data area and all the loaded shared libraries.&lt;br /&gt;RES : The size of RAM currently consumed by the task. Swapped out portion of the task is not included.&lt;br /&gt;SHR : Some memory areas could be shared between two or more task, this field reflects that shared areas. The example of shared area are shared library and SysV shared memory.&lt;br /&gt;S : Task status&lt;br /&gt;%CPU : The percentage of CPU time dedicated to run the task since the last top's screen update.&lt;br /&gt;%MEM : The percentage of RAM currently consumed by the task.&lt;br /&gt;TIME+ : The total CPU time the task has been used since it started. "+" sign means it is displayed with hundreth of a second granularity. By default, TIME/TIME+ doesn't account the CPU time used by the task's dead children.&lt;br /&gt;COMMAND : Showing program names.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ top -p 4360,4358&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;top + "A" to see multiple windows mode&lt;br /&gt;&lt;br /&gt;1:Def - 13:16:02 up 1:37, 4 users, load average: 0.06, 0.04, 0.03&lt;br /&gt;Tasks: 122 total, 1 running, 120 sleeping, 0 stopped, 1 zombie&lt;br /&gt;Cpu(s): 0.7% us, 1.4% sy, 0.0% ni, 96.5% id, 0.0% wa, 0.0% hi, 1.4% si&lt;br /&gt;Mem: 514516k total, 320228k used, 194288k free, 37336k buffers&lt;br /&gt;Swap: 1048568k total, 0k used, 1048568k free, 174564k cached&lt;br /&gt;&lt;br /&gt;1 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND&lt;br /&gt;9234 root 16 0 3020 964 740 R 2.6 0.2 0:00.04 top&lt;br /&gt;3408 root 16 0 9768 7188 1628 S 1.3 1.4 0:46.53 hald&lt;br /&gt;8601 shan 15 0 7344 2228 1812 S 1.3 0.4 0:00.51 sshd&lt;br /&gt;1 root 16 0 2372 548 468 S 0.0 0.1 0:04.50 init&lt;br /&gt;2 root RT 0 0 0 0 S 0.0 0.0 0:00.76 migration/0&lt;br /&gt;3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0&lt;br /&gt;4 root RT 0 0 0 0 S 0.0 0.0 0:00.66 migration/1&lt;br /&gt;5 root 34 19 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/1&lt;br /&gt;6 root 5 -10 0 0 0 S 0.0 0.0 0:00.80 events/0&lt;br /&gt;7 root 5 -10 0 0 0 S 0.0 0.0 0:00.53 events/1&lt;br /&gt;8 root 5 -10 0 0 0 S 0.0 0.0 0:00.11 khelper&lt;br /&gt;9 root 15 -10 0 0 0 S 0.0 0.0 0:00.00 kacpid&lt;br /&gt;2 PID PPID TIME+ %CPU %MEM PR NI S VIRT SWAP RES UID COMMAND&lt;br /&gt;9234 8630 0:00.04 2.6 0.2 16 0 R 3020 2056 964 0 top&lt;br /&gt;8630 8629 0:00.17 0.0 0.3 16 0 S 5820 4396 1424 0 bash&lt;br /&gt;8629 8628 0:00.01 0.0 0.2 19 0 S 5036 3900 1136 0 su&lt;br /&gt;8628 8602 0:00.02 0.0 0.0 17 0 S 2680 2428 252 0 sesh&lt;br /&gt;8602 8601 0:00.05 0.0 0.3 16 0 S 5836 4460 1376 500 bash&lt;br /&gt;8601 8599 0:00.51 1.3 0.4 15 0 S 7344 5116 2228 500 sshd&lt;br /&gt;8599 3241 0:00.07 0.0 0.4 17 0 S 7164 5028 2136 0 sshd&lt;br /&gt;8537 1 0:00.00 0.0 0.2 16 0 S 3328 2336 992 0 dhclient&lt;br /&gt;7232 1 0:00.01 0.0 0.2 16 0 S 3004 2004 1000 0 dhclient&lt;br /&gt;6932 6931 0:00.21 0.0 0.3 16 0 S 4828 3400 1428 0 bash&lt;br /&gt;6931 6930 0:00.01 0.0 0.2 19 0 S 5228 4092 1136 0 su&lt;br /&gt;6930 6893 0:00.02 0.0 0.0 16 0 S 2392 2136 256 0 sesh&lt;br /&gt;3 PID %MEM VIRT SWAP RES CODE DATA SHR nFLT nDRT S PR NI %CPU COMMAND&lt;br /&gt;3937 4.2 155m 133m 21m 1520 16m 5232 0 0 S 16 0 0.0 X&lt;br /&gt;4838 3.5 40640 21m 17m 588 19m 9920 23 0 S 15 0 0.0 nautilus&lt;br /&gt;6891 2.4 36388 23m 12m 252 15m 8228 0 0 S 15 0 0.0 gnome-terminal&lt;br /&gt;4834 2.2 22848 11m 11m 436 4332 8220 8 0 S 15 0 0.0 gnome-panel&lt;br /&gt;5294 2.0 21696 11m 9.8m 28 2872 7544 9 0 S 15 0 0.0 mixer_applet2&lt;br /&gt;5292 1.9 21208 11m 9576 64 3036 7472 3 0 S 16 0 0.0 wnck-applet&lt;br /&gt;4555 1.8 20696 10m 9472 120 2776 6980 11 0 S 15 0 0.0 gnome-session&lt;br /&gt;5296 1.5 20496 12m 7932 92 2132 6680 6 0 S 16 0 0.0 clock-applet&lt;br /&gt;4620 1.5 12280 4700 7580 44 7272 1668 1 0 S 16 0 0.0 gconfd-2&lt;br /&gt;4868 1.4 40444 32m 7336 104 22m 6268 4 0 S 16 0 0.0 eggcups&lt;br /&gt;3408 1.4 9768 2580 7188 196 6712 1628 2 0 S 16 0 1.3 hald&lt;br /&gt;4696 1.4 14616 7436 7180 428 2304 6024 6 0 S 15 0 0.0 metacity&lt;br /&gt;4627 1.4 18552 11m 7008 140 1272 5924 7 0 S 15 0 0.0 gnome-settings-&lt;br /&gt;4 PID PPID UID USER RUSER TTY TIME+ %CPU %MEM S COMMAND&lt;br /&gt;3338 1 43 xfs xfs ? 0:00.17 0.0 0.3 S xfs&lt;br /&gt;3290 1 51 smmsp smmsp ? 0:00.00 0.0 0.5 S sendmail&lt;br /&gt;4838 1 500 shan shan ? 0:18.78 0.0 3.5 S nautilus&lt;br /&gt;6891 1 500 shan shan ? 0:06.95 0.0 2.4 S gnome-terminal&lt;br /&gt;4834 1 500 shan shan ? 0:11.20 0.0 2.2 S gnome-panel&lt;br /&gt;5294 1 500 shan shan ? 0:02.36 0.0 2.0 S mixer_applet2&lt;br /&gt;5292 1 500 shan shan ? 0:10.48 0.0 1.9 S wnck-applet&lt;br /&gt;4555 3893 500 shan shan ? 0:03.31 0.0 1.8 S gnome-session&lt;br /&gt;5296 1 500 shan shan ? 0:00.87 0.0 1.5 S clock-applet&lt;br /&gt;4620 1 500 shan shan ? 0:10.79 0.0 1.5 S gconfd-2&lt;br /&gt;4868 1 500 shan shan ? 0:01.52 0.0 1.4 S eggcups&lt;br /&gt;4696 1 500 shan shan ? 0:04.49 0.0 1.4 S metacity&lt;br /&gt;4627 1 500 shan shan ? 0:00.48 0.0 1.4 S gnome-settings-&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vmstat -d reports disk&lt;br /&gt;&lt;br /&gt;Procs&lt;br /&gt;r: The number of processes waiting for run time.&lt;br /&gt;b: The number of processes in uninterruptible sleep.&lt;br /&gt;&lt;br /&gt;Memory&lt;br /&gt;swpd: the amount of virtual memory used.&lt;br /&gt;free: the amount of idle memory.&lt;br /&gt;buff: the amount of memory used as buffers.&lt;br /&gt;cache: the amount of memory used as cache.&lt;br /&gt;inact: the amount of inactive memory. (-a option)&lt;br /&gt;active: the amount of active memory. (-a option)&lt;br /&gt;&lt;br /&gt;Swap&lt;br /&gt;si: Amount of memory swapped in from disk (/s).&lt;br /&gt;so: Amount of memory swapped to disk (/s).&lt;br /&gt;&lt;br /&gt;IO&lt;br /&gt;bi: Blocks received from a block device (blocks/s).&lt;br /&gt;bo: Blocks sent to a block device (blocks/s).&lt;br /&gt;&lt;br /&gt;System&lt;br /&gt;in: The number of interrupts per second, including the clock.&lt;br /&gt;cs: The number of context switches per second.&lt;br /&gt;&lt;br /&gt;CPU&lt;br /&gt;These are percentages of total CPU time.&lt;br /&gt;us: Time spent running non-kernel code. (user time, including nice time)&lt;br /&gt;sy: Time spent running kernel code. (system time)&lt;br /&gt;id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.&lt;br /&gt;wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.&lt;br /&gt;&lt;br /&gt;st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Page Fault:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Technically, page fault happens when the task access a non existant page in its address space.&lt;br /&gt;A page fault is said as "major" if kernel needs to access the disk to make the page available.&lt;br /&gt;On the contrary, soft minor page fault means the kernel only need to allocate pages in RAM without&lt;br /&gt;reading anything from disk.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For illustration, consider the size of program ABC is 8 kB and assume the page size is 4 kB.&lt;br /&gt;When the program is fully loaded to RAM, there will be 2 times major page fault (2 * 4 kB).&lt;br /&gt;&lt;br /&gt;The program itself allocates another 8 kB for temporary data storage in RAM. Thus, there will be 2 minor page fault.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A high number of nFLT could mean:&lt;br /&gt;&lt;br /&gt;1. The task is aggressively load some portions of its executable or library from the disk.&lt;br /&gt;&lt;br /&gt;2. The task is accessing a page that is swapped ou&lt;br /&gt;&lt;br /&gt;3. It is normal if you see a high number of major page fault when a program is run for first time.&lt;br /&gt;On the next invocations, buffer is utilized so likely you will see "0" or low number of nFLT.&lt;br /&gt;But, if a program is continously triggerring major page fault, big chance your program needs larger RAM size than currently installed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Dirty Pages:&lt;br /&gt;&lt;br /&gt;The number of dirty pages since they are written back to the disk.&lt;br /&gt;&lt;br /&gt;Maybe you wonder, what is dirty page? First, a little bac ground. As you know, Linux employ caching mechanism, so everything that is read&lt;br /&gt;from disk is also cached in RAM. The advantage of this action is, subsequent read to the same disk block can be served from RAM thus reading&lt;br /&gt;completes faster.&lt;br /&gt;&lt;br /&gt;But it also costs something. If the buffer's content is modified, it needs to be synchronized. Thus, sooner or la this modified buffer (dirty page)&lt;br /&gt;must be written back. The failure on the synchronization might cause data inconsistency on related disk.&lt;br /&gt;&lt;br /&gt;On mostly idle to fairly loaded system, nDRT is usually below 10 (this is just a raw prediction)or mostly zero. If it is constantly bigger than that:&lt;br /&gt;&lt;br /&gt;1. The task is aggresively write something to file(s). It is so often that disk I/O can't keep up with it&lt;br /&gt;&lt;br /&gt;2. The disk suffers I/O congestion, thus even the task only modifies small portion of file(s), it must wait a bit longer to be synchronized.&lt;br /&gt;Congestion happens when many processes access the disk at a time but cache hit is low.&lt;br /&gt;&lt;br /&gt;These days, (1) unlikely happens because I/O speed is getting faster and less CPU demanding (thanks to DMA). So (2) has bigger probability.&lt;br /&gt;&lt;br /&gt;Note: On 2.6.x, this field is always zero without unknown reason.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The configuration file consists of records that look identical to the output of sysctl -a.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's an example configuration file:&lt;br /&gt;&lt;br /&gt;# Controls IP packet forwarding&lt;br /&gt;net.ipv4.ip_forward = 0&lt;br /&gt;&lt;br /&gt;# Controls source route verification&lt;br /&gt;net.ipv4.conf.default.rp_filter = 1&lt;br /&gt;&lt;br /&gt;# Controls the System Request debugging functionality of the kernel&lt;br /&gt;kernel.sysrq = 0&lt;br /&gt;&lt;br /&gt;# Controls whether core dumps will append the PID to the core filename.&lt;br /&gt;# Useful for debugging multi-threaded applications.&lt;br /&gt;kernel.core_uses_pid = 1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Network Performance Tuning:&lt;br /&gt;&lt;br /&gt;# Decrease the time default value for tcp_fin_timeout connection.&lt;br /&gt;net.ipv4.tcp_fin_timeout = 30&lt;br /&gt;&lt;br /&gt;# Decrease the time default value for tcp_keepalive_time connection&lt;br /&gt;net.ipv4.tcp_keepalive_time = 1800&lt;br /&gt;&lt;br /&gt;# Turn off tcp_window_scaling&lt;br /&gt;net.ipv4.tcp_window_scaling = 0&lt;br /&gt;&lt;br /&gt;# Turn off the tcp_sack&lt;br /&gt;net.ipv4.tcp_sack = 0&lt;br /&gt;&lt;br /&gt;# Turn off tcp_timestamps&lt;br /&gt;net.ipv4.tcp_timestamps = 0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NFS Performance Tuning:&lt;br /&gt;&lt;br /&gt;# Increase transport socket buffers to improve performance of nfs (and&lt;br /&gt;networking in general)&lt;br /&gt;&lt;br /&gt;# 'rmem' is 'read memory', 'wmem' is 'write memory'.&lt;br /&gt;&lt;br /&gt;net.core.rmem_max = 262143&lt;br /&gt;&lt;br /&gt;net.core.rmem_default = 262143&lt;br /&gt;&lt;br /&gt;net.core.wmem_max = 262143&lt;br /&gt;&lt;br /&gt;net.core.wmem_default = 262143&lt;br /&gt;&lt;br /&gt;net.ipv4.tcp_rmem = 4096 87380 8388608&lt;br /&gt;&lt;br /&gt;net.ipv4.tcp_wmem = 4096 87380 8388608&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# These are for both security and performance&lt;br /&gt;&lt;br /&gt;net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;net.ipv4.icmp_ignore_bogus_error_responses = 1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8101251972813791857?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8101251972813791857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8101251972813791857'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-performance-tuning-1.html' title='Linux - Performance Tuning 1'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5080112676579706125</id><published>2010-04-02T12:28:00.000-07:00</published><updated>2010-04-02T13:53:47.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux ext3 Quick Guide</title><content type='html'>Related Topics:&lt;br /&gt;i-node structure is explained at &lt;a href="http://www.tux4u.nl/freedocs/unix/draw/inode.pdf"&gt;here&lt;/a&gt;.&lt;br /&gt;A very good introduction to ext2 is at &lt;a href="http://web.mit.edu/tytso/www/linux/ext2intro.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ext3 is compatible to ext2 filesystems; actually you can look at it as an ext2 filesystem with a journal file.&lt;br /&gt;&lt;br /&gt;The journaling capability means no more waiting for fsck's or worrying about metadata corruption.&lt;br /&gt;What is most noticeable is that you can switch back and forth between ext2 and ext3 on a partition without any problem:&lt;br /&gt;it is just a matter of giving the mount command the right filesystem type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ext3 journaling options&lt;br /&gt;&lt;br /&gt;-o data=writeback&lt;br /&gt;-o data=ordered  (default)&lt;br /&gt;-o data=journal&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These journaling modes are the following:  writing filesystem data and/or filesystem metadata&lt;br /&gt;&lt;br /&gt; journal - logs all filesystem data and metadata changes. The slowest of the three ext3 journaling modes,&lt;br /&gt; this journaling mode minimizes the chance of losing the changes you have made to any file in an ext3 filesystem.&lt;br /&gt;&lt;br /&gt; ordered - only logs changes to filesystem metadata, but flushes file data updates to disk before making changes&lt;br /&gt; to associated filesystem metadata. This is the default ext3 journaling mode.&lt;br /&gt;&lt;br /&gt; writeback - only logs changes to filesystem metadata but relies on the standard filesystem write process to write file&lt;br /&gt; data changes to disk. This is the fastest ext3 journaling mode.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The differences between these journaling modes are both subtle and profound. Using the "journal" mode requires that an ext3&lt;br /&gt;filesystem write every change to a filesystem twice - once to the journal, and then again to the filesystem itself. This can&lt;br /&gt;reduce the overall performance of your filesystem, but is the mode most beloved by users, because it minimizes the chances of&lt;br /&gt;losing changes to your files since both metatdata and data updates are recorded in the ext3 journal and can be replayed when&lt;br /&gt;a system reboots.&lt;br /&gt;&lt;br /&gt;Using the "ordered" mode, only filesystem metadata changes are logged, which reduces redundancy between writing to the filesystem&lt;br /&gt;and to the journal and is therefore faster. Though the changes to file data are not logged, they must be done before associated&lt;br /&gt;filesystem metadata changes are made by the ext3 journaling daemon, which can slightly reduce the performance of your system.&lt;br /&gt;However, using this journaling mode guarantees that files in the filesystem will never be out of sync with any related changes to&lt;br /&gt;filesystem metadata.&lt;br /&gt;&lt;br /&gt;Using the "writeback" mode is faster than the other two ext3 journaling modes because it only logs changes to filesystem metadata and&lt;br /&gt;does not wait for associated changes to file data to be written before updating things like file size and directory information.&lt;br /&gt;Because updates to file data are done asynchronously to journaled changes to filesystem metadata, files in the filesystem may exhibit&lt;br /&gt;metadata inconsistencies such as owning data blocks to which updated data was not yet written when the system went down.&lt;br /&gt;This isn't fatal, but can be disappointing to users.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Commands:&lt;br /&gt;&lt;br /&gt;e2fsck&lt;br /&gt;E2fsck will run the journal automatically, and if the filesystem is otherwise clean, it skip doing a full filesystem check.&lt;br /&gt;&lt;br /&gt;By default,  exhaustive fs check happens every twentieth mount or every 180 days, whichever comes first.&lt;br /&gt;&lt;br /&gt;You can view the filesystem check interval (as well as lots of other interesting information) by typing tune2fs -l /dev/sdXX.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost geyes]# tune2fs -l /dev/sdb1&lt;br /&gt;tune2fs 1.35 (28-Feb-2004)&lt;br /&gt;Filesystem volume name:   &lt;none&gt;&lt;br /&gt;Last mounted on:          &lt;not available=""&gt;&lt;br /&gt;Filesystem UUID:          22e4830c-7f65-43c5-9060-b017b402ecb6&lt;br /&gt;Filesystem magic number:  0xEF53&lt;br /&gt;Filesystem revision #:    1 (dynamic)&lt;br /&gt;Filesystem features:      has_journal ext_attr resize_inode filetype sparse_super&lt;br /&gt;Default mount options:    (none)&lt;br /&gt;Filesystem state:         clean&lt;br /&gt;Errors behavior:          Continue&lt;br /&gt;Filesystem OS type:       Linux&lt;br /&gt;Inode count:              32768&lt;br /&gt;Block count:              131056&lt;br /&gt;Reserved block count:     6552&lt;br /&gt;Free blocks:              121221&lt;br /&gt;Free inodes:              32733&lt;br /&gt;First block:              1&lt;br /&gt;Block size:               1024&lt;br /&gt;Fragment size:            1024&lt;br /&gt;Reserved GDT blocks:      256&lt;br /&gt;Blocks per group:         8192&lt;br /&gt;Fragments per group:      8192&lt;br /&gt;Inodes per group:         2048&lt;br /&gt;Inode blocks per group:   256&lt;br /&gt;Filesystem created:       Tue Mar 30 22:08:47 2010&lt;br /&gt;Last mount time:          Tue Mar 30 22:10:17 2010&lt;br /&gt;Last write time:          Tue Mar 30 23:21:51 2010&lt;br /&gt;Mount count:              0&lt;br /&gt;Maximum mount count:      36&lt;br /&gt;Last checked:             Tue Mar 30 23:21:51 2010&lt;br /&gt;Check interval:           15552000 (6 months)&lt;br /&gt;Next check after:         Mon Sep 27 00:21:51 2010&lt;br /&gt;Reserved blocks uid:      0 (user root)&lt;br /&gt;Reserved blocks gid:      0 (group root)&lt;br /&gt;First inode:              11&lt;br /&gt;Inode size:               128&lt;br /&gt;Journal inode:            8&lt;br /&gt;Default directory hash:   tea&lt;br /&gt;Directory Hash Seed:      33370d2c-2965-45ca-8751-9ba4cc28ecf0&lt;br /&gt;Journal backup:           inode blocks&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mke2fs -j /dev/hdax&lt;br /&gt;&lt;br /&gt;fsck.ext2 -f /dev/hdaX&lt;br /&gt;&lt;br /&gt;[root@localhost geyes]# e2fsck /dev/sdb1&lt;br /&gt;e2fsck 1.35 (28-Feb-2004)&lt;br /&gt;/dev/sdb1 is mounted.&lt;br /&gt;&lt;br /&gt;WARNING!!!  Running e2fsck on a mounted filesystem may cause&lt;br /&gt;SEVERE filesystem damage.&lt;br /&gt;&lt;br /&gt;Do you really want to continue (y/n)? yes&lt;br /&gt;&lt;br /&gt;/dev/sdb1: recovering journal&lt;br /&gt;/dev/sdb1: clean, 34/32768 files, 9835/131056 blocks&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can convert my ext2 partition to ext3 by two simple steps:&lt;br /&gt;1. creating a journal on it. e.g. "tune2fs -j /dev/hdaX "&lt;br /&gt;2. mount -t ext3 /dev/hdax /mnt/mount-point&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With mke2fs -j /dev/hdaX you can format a partition as ext3 (as always it will be also usable as ext2 partion).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This can be done on an unmounted or on a mounted filesystem.&lt;br /&gt;&lt;br /&gt;(on mounted partition)&lt;br /&gt;If you create the journal on a mounted filesystem you will see a .journal file.&lt;br /&gt;&lt;br /&gt;Don't try to delete this and don't back this up or restore it from backup!&lt;br /&gt;&lt;br /&gt;(on unmounted partition)&lt;br /&gt;If you run tune2fs -j on an unmounted partition an unvisible journal file will be created.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;'df' command says partition is full, while 'du' reports free space&lt;br /&gt;Some user process keeping a deleted file open.&lt;br /&gt;When this happens, the space is not visible via 'du', since the file is no longer visible in the directory tree.&lt;br /&gt;However, the space is still used by the file until it is deallocated, and that can only happen once the last process&lt;br /&gt;which has the file open either closes its file descriptor to the file, or the process exits.&lt;br /&gt;You can use the lsof program to try to find which process is keeping an open file.&lt;br /&gt;Usually it's some log file, or some large data base file which gets rotated out, but some older process are still keeping the log file open.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have ext2 compiled into the kernel and ext3 as a module and your root filesystem is ext2/3, then the kernel will always mount the root fs as ext2 and&lt;br /&gt;not as ext3 since at the time when the root filesystem is mounted, the kernel does not have access to the modules, since they are located on the root filesystem.&lt;br /&gt;(This is a chicken and egg problem!)&lt;br /&gt;&lt;br /&gt;If you have this setup, you might first want to consider whether it makes sense to compile ext3 as a module. If you want to use ext3 on your root filesystem,&lt;br /&gt;the ext3 filesystem module will always be loaded and can not be unloaded, so it might as well be compiled-in. Furthermore, modules waste a tiny amount of memory&lt;br /&gt;(on average 2k per module), and take up an extra entry in the TLB cache --- a slight, and perhaps not measurable disadvantage, but given that there is no real advantage&lt;br /&gt;to compiling ext3 as a module, why bother?&lt;br /&gt;&lt;br /&gt;If you do want to compile ext3 as a module and use it as your root filesystem, it can be done, but what you must do is do is boot into an initial ramdisk (initrd)&lt;br /&gt;image as your root image. This initrd image will contain the necessary modules (scsi, ext3, etc.) so you can mount your "real" root filesystem and then use pivot_root&lt;br /&gt;to replace the initrd root filesystem with the "real" root filesystem.&lt;br /&gt;&lt;br /&gt;Most distributions do the pivot_root trick automatically, but they differ in how the tool which builds the initrd image needs to be called.&lt;br /&gt;&lt;br /&gt; * On a SuSE system you have to put "jbd ext3" (in this order!) into the YaST setting INITRD_MODULES. Then do a mk_initrd and it should work.&lt;br /&gt; * On a Red Hat system it seems that it is sufficiant to just do a mkinitrd.&lt;br /&gt; * On a Debian system (woody and above) you must run the command:&lt;br /&gt;   mkinitrd -o boot/initrd.img-2.4.18-386 /lib/modules/2.4.18-386&lt;br /&gt;   where 2.4.18-386 must be substituted with the version number of the debian kernel which you are currently using. Note: this requires that you have the initrd-tools&lt;br /&gt;package installed, and if you currently are not using an initrd setup, your lilo or grub configuration files must be modified to tell the booting kernel to use&lt;br /&gt;the initrd image.&lt;br /&gt;&lt;br /&gt;How do I convert my ext3 partition back to ext2?&lt;br /&gt;Actually there is only little need to do so, because in most cases it is sufficient to mount the partition explicitely as ext2.&lt;br /&gt;But if you really need to convert your partion back to ext2 just do the following on an unmounted partition:&lt;br /&gt;&lt;br /&gt; tune2fs -O ^has_journal /dev/hdaX&lt;br /&gt;&lt;br /&gt;To be on the safe side you should force a fsck run on this partition afterwards:&lt;br /&gt;&lt;br /&gt; fsck.ext2 -f /dev/hdaX&lt;br /&gt;&lt;br /&gt;After this procedure you can safely delete the .journal file if there was any.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If a system shutdown hard, even with journaling is it at all necessary to run e2fsck?&lt;br /&gt;&lt;br /&gt;It's best to just always run e2fsck. [...]&lt;br /&gt;E2fsck will run the journal automatically, and if the filesystem is otherwise clean, it skip doing a full filesystem check.&lt;br /&gt;If the filesystem is not clean (because during the previous run the kernel noticed some filesystem inconsistencies), e2fsck will automatically do a full check&lt;br /&gt;if it is necessary.&lt;br /&gt;If you have multiple disks, fsck will run multiple e2fsck processes in parallel, thus speeding up your boot sequence than if you let the kernel replay the journal&lt;br /&gt;for each filesystem when it tries to mount it, since then the journal replays will be done sequentially, instead of in parallel.&lt;br /&gt;&lt;br /&gt;What is the largest possible size of an ext3 filesystem and of files on ext3?&lt;br /&gt;&lt;br /&gt;Ext3 can support files up to 1TB. With a 2.4 kernel the filesystem size is limited by the maximal block device size, which is 2TB.&lt;br /&gt;&lt;br /&gt;In 2.6 the maximum (32-bit CPU) limit is of block devices is 16TB, but ext3 supports only up to 4TB.&lt;br /&gt;&lt;br /&gt;How do I convert the journal file from version 1 to version 2?&lt;br /&gt;Just type:&lt;br /&gt;&lt;br /&gt; mount /dev/hdaX /mnt -o journal=update&lt;br /&gt;&lt;br /&gt;to convert your old (ext3 v0.0.3* and earlier) filesystem to the new journal format.&lt;br /&gt;&lt;br /&gt;How do I convert my root filesystem from version 1 to version 2?&lt;br /&gt;Just issue a "lilo -R linux rw rootflags=journal=update" and reboot.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I updated ext3 today. Got all of my mounts converted. Now on boot, I see: "EXT3-fs: mounted filesystem with ordered data mode". Is this normal?&lt;br /&gt;Nigel Metheringham answered this on the ext3-users mailing list as follows:&lt;br /&gt;&lt;br /&gt;That's fine. The EXT3-fs message is just telling you it mounted the fs OK. It's also telling you what form of journaling you are using.&lt;br /&gt;&lt;br /&gt;ext3 has 2 formats of journal:&lt;br /&gt;&lt;br /&gt; * version 1 - default and only possibility for ext3 releases 0.0.3* and earlier&lt;br /&gt; * version 2 - default for filesystems created with 0.0.4 and later&lt;br /&gt;&lt;br /&gt;Version 2 journals support additional semantics required to allow metadata journaling, and provide 2 new forms of journaling - ordered and writeback.&lt;br /&gt;Both V1 &amp;amp; V2 journals support data journaling (where everything that would go to disk is journaled).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Examples:&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# lvmdiskscan&lt;br /&gt;/dev/cdrom [       68.80 MB]&lt;br /&gt;/dev/sda1  [      101.94 MB]&lt;br /&gt;/dev/sda2  [        7.90 GB] LVM physical volume&lt;br /&gt;/dev/sdb   [      512.00 MB]&lt;br /&gt;2 disks&lt;br /&gt;1 partition&lt;br /&gt;0 LVM physical volume whole disks&lt;br /&gt;1 LVM physical volume&lt;br /&gt;[root@localhost sysconfig]# e2fsck /dev/sdb&lt;br /&gt;e2fsck 1.35 (28-Feb-2004)&lt;br /&gt;Couldn't find ext2 superblock, trying backup blocks...&lt;br /&gt;e2fsck: Bad magic number in super-block while trying to open /dev/sdb&lt;br /&gt;&lt;br /&gt;The superblock could not be read or does not describe a correct ext2&lt;br /&gt;filesystem.  If the device is valid and it really contains an ext2&lt;br /&gt;filesystem (and not swap or ufs or something else), then the superblock&lt;br /&gt;is corrupt, and you might try running e2fsck with an alternate superblock:&lt;br /&gt; e2fsck -b 8193 &lt;device&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;[root@localhost sysconfig]# fdisk /dev/sdb&lt;br /&gt;Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel&lt;br /&gt;Building a new DOS disklabel. Changes will remain in memory only,&lt;br /&gt;until you decide to write them. After that, of course, the previous&lt;br /&gt;content won't be recoverable.&lt;br /&gt;&lt;br /&gt;Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)&lt;br /&gt;&lt;br /&gt;Command (m for help): m&lt;br /&gt;Command action&lt;br /&gt;a   toggle a bootable flag&lt;br /&gt;b   edit bsd disklabel&lt;br /&gt;c   toggle the dos compatibility flag&lt;br /&gt;d   delete a partition&lt;br /&gt;l   list known partition types&lt;br /&gt;m   print this menu&lt;br /&gt;n   add a new partition&lt;br /&gt;o   create a new empty DOS partition table&lt;br /&gt;p   print the partition table&lt;br /&gt;q   quit without saving changes&lt;br /&gt;s   create a new empty Sun disklabel&lt;br /&gt;t   change a partition's system id&lt;br /&gt;u   change display/entry units&lt;br /&gt;v   verify the partition table&lt;br /&gt;w   write table to disk and exit&lt;br /&gt;x   extra functionality (experts only)&lt;br /&gt;&lt;br /&gt;Command (m for help): n&lt;br /&gt;Command action&lt;br /&gt;e   extended&lt;br /&gt;p   primary partition (1-4)&lt;br /&gt;p&lt;br /&gt;Partition number (1-4): 1&lt;br /&gt;First cylinder (1-512, default 1):&lt;br /&gt;Using default value 1&lt;br /&gt;Last cylinder or +size or +sizeM or +sizeK (1-512, default 512): 128M&lt;br /&gt;&lt;br /&gt;Command (m for help): n&lt;br /&gt;Command action&lt;br /&gt;e   extended&lt;br /&gt;p   primary partition (1-4)&lt;br /&gt;p&lt;br /&gt;Partition number (1-4): 2&lt;br /&gt;First cylinder (129-512, default 129):&lt;br /&gt;Using default value 129&lt;br /&gt;Last cylinder or +size or +sizeM or +sizeK (129-512, default 512): 128M&lt;br /&gt;Value out of range.&lt;br /&gt;Last cylinder or +size or +sizeM or +sizeK (129-512, default 512): +128M&lt;br /&gt;&lt;br /&gt;Command (m for help): p&lt;br /&gt;&lt;br /&gt;Disk /dev/sdb: 536 MB, 536870912 bytes&lt;br /&gt;64 heads, 32 sectors/track, 512 cylinders&lt;br /&gt;Units = cylinders of 2048 * 512 = 1048576 bytes&lt;br /&gt;&lt;br /&gt;Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;/dev/sdb1               1         128      131056   83  Linux&lt;br /&gt;/dev/sdb2             129         251      125952   83  Linux&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Command (m for help): v&lt;br /&gt;782367 unallocated sectors&lt;br /&gt;&lt;br /&gt;Command (m for help): w&lt;br /&gt;The partition table has been altered!&lt;br /&gt;&lt;br /&gt;Calling ioctl() to re-read partition table.&lt;br /&gt;Syncing disks.&lt;br /&gt;[root@localhost sysconfig]# lvmdiskscan&lt;br /&gt;/dev/cdrom [       68.80 MB]&lt;br /&gt;/dev/sda1  [      101.94 MB]&lt;br /&gt;/dev/sda2  [        7.90 GB] LVM physical volume&lt;br /&gt;/dev/sdb1  [      127.98 MB]&lt;br /&gt;/dev/sdb2  [      123.00 MB]&lt;br /&gt;1 disk&lt;br /&gt;3 partitions&lt;br /&gt;0 LVM physical volume whole disks&lt;br /&gt;1 LVM physical volume&lt;br /&gt;[root@localhost sysconfig]# pvscan&lt;br /&gt;PV /dev/sda2   VG VolGroup00   lvm2 [7.88 GB / 32.00 MB free]&lt;br /&gt;Total: 1 [7.88 GB] / in use: 1 [7.88 GB] / in no VG: 0 [0   ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# mke2fs -j /dev/sdb1&lt;br /&gt;mke2fs 1.35 (28-Feb-2004)&lt;br /&gt;Filesystem label=&lt;br /&gt;OS type: Linux&lt;br /&gt;Block size=1024 (log=0)&lt;br /&gt;Fragment size=1024 (log=0)&lt;br /&gt;32768 inodes, 131056 blocks&lt;br /&gt;6552 blocks (5.00%) reserved for the super user&lt;br /&gt;First data block=1&lt;br /&gt;Maximum filesystem blocks=67371008&lt;br /&gt;16 block groups&lt;br /&gt;8192 blocks per group, 8192 fragments per group&lt;br /&gt;2048 inodes per group&lt;br /&gt;Superblock backups stored on blocks:&lt;br /&gt;     8193, 24577, 40961, 57345, 73729&lt;br /&gt;&lt;br /&gt;Writing inode tables: done&lt;br /&gt;Creating journal (4096 blocks): done&lt;br /&gt;Writing superblocks and filesystem accounting information: done&lt;br /&gt;&lt;br /&gt;This filesystem will be automatically checked every 36 mounts or&lt;br /&gt;180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;/device&gt;&lt;/not&gt;&lt;/none&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-5080112676579706125?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5080112676579706125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/5080112676579706125'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-ext3-quick-guide.html' title='Linux ext3 Quick Guide'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7761449288750381913</id><published>2010-04-02T12:22:00.000-07:00</published><updated>2010-05-11T17:59:37.403-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Linux NFS QuickGuide</title><content type='html'>Linux NFS QuickGuide&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NFS Server Daemons&lt;br /&gt;&lt;br /&gt;portmap enables NFS clients to discover the NFS services available on a given NFS server&lt;br /&gt;&lt;br /&gt;nfsd provides all nfs servide except file locking and quota management&lt;br /&gt;&lt;br /&gt;mountd processes nfs client mount requests&lt;br /&gt;&lt;br /&gt;statd implements nfs lock recovery when an nfs server system crashes&lt;br /&gt;&lt;br /&gt;lockd starts the kernel's nfs lock manager&lt;br /&gt;&lt;br /&gt;rquotad provides file system quota information nfs exports to NFS clients using file system quotas&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Daemon start sequence : portmap, nfsd, mountd, statd, rquotad&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;files:&lt;br /&gt;&lt;br /&gt;/exports : lists nfs shares and permissions, mount options, etc&lt;br /&gt;&lt;br /&gt;/var/lib/nfs/rmtab : lists each NFS export that is mounted by an NFS client.&lt;br /&gt;each time rpc.mounted receives a mount request, it adds&lt;br /&gt;an entry to /var/lib/nfs/rmtab file.&lt;br /&gt;&lt;br /&gt;/var/lib/nfs/etab : contains currently exported filesystems&lt;br /&gt;&lt;br /&gt;[root@localhost usr]# cat /etc/exports&lt;br /&gt;#&lt;br /&gt;/usr/share 192.168.200.0/255.255.255.0(rw,insecure,sync,anonuid=600,anongid=600)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;share options:&lt;br /&gt;&lt;br /&gt;secure : requires client request to originate fr om secure port&lt;br /&gt;secure_lock : requires that clients requsting lock authentication before activating the lock&lt;br /&gt;&lt;br /&gt;async : allows the server to cache disk write to improve performance&lt;br /&gt;&lt;br /&gt;subtree_check : if only part of a filesystem is exported, this checks to make sure the file is&lt;br /&gt;in the exported protion of the fs&lt;br /&gt;&lt;br /&gt;root_squash : maps all requests from a user ID of 0 to uid of anonymous user -2 in linux&lt;br /&gt;&lt;br /&gt;anonuid = uid : set the UID of annomous account to uid&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To start nfs service:&lt;br /&gt;1. #service nfs start&lt;br /&gt;2. #/etc/rc.d/init.d/nfs start&lt;br /&gt;&lt;br /&gt;By default 8 copies of nfsd started, to enable the server to process multiple requests, change this value&lt;br /&gt;/etc/sysconfig/nfs RPCNFSDCOUNT=8&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# vi /etc/sysconfig/nfs&lt;br /&gt;[root@localhost sysconfig]# service nfs restart&lt;br /&gt;Shutting down NFS mountd: [ OK ]&lt;br /&gt;Shutting down NFS daemon: [ OK ]&lt;br /&gt;Shutting down NFS quotas: [ OK ]&lt;br /&gt;Shutting down NFS services: [ OK ]&lt;br /&gt;Starting NFS services: [ OK ]&lt;br /&gt;Starting NFS quotas: [ OK ]&lt;br /&gt;Starting NFS daemon: [ OK ]&lt;br /&gt;Starting NFS mountd: [ OK ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# ps -ef grep nfsd grep -v grep&lt;br /&gt;root 5847 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5848 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5849 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5850 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5851 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5852 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5853 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5854 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5855 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5856 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5857 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5858 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5859 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5860 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5861 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;root 5862 1 0 20:34 ? 00:00:00 [nfsd]&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# rpcinfo -p&lt;br /&gt;program vers proto port&lt;br /&gt;100000 2 tcp 111 portmapper&lt;br /&gt;100000 2 udp 111 portmapper&lt;br /&gt;100024 1 udp 32768 status&lt;br /&gt;100024 1 tcp 32770 status&lt;br /&gt;100011 1 udp 932 rquotad&lt;br /&gt;100011 2 udp 932 rquotad&lt;br /&gt;100011 1 tcp 935 rquotad&lt;br /&gt;100011 2 tcp 935 rquotad&lt;br /&gt;100003 2 udp 2049 nfs&lt;br /&gt;100003 3 udp 2049 nfs&lt;br /&gt;100003 4 udp 2049 nfs&lt;br /&gt;100003 2 tcp 2049 nfs&lt;br /&gt;100003 3 tcp 2049 nfs&lt;br /&gt;100003 4 tcp 2049 nfs&lt;br /&gt;100021 1 udp 32770 nlockmgr&lt;br /&gt;100021 3 udp 32770 nlockmgr&lt;br /&gt;100021 4 udp 32770 nlockmgr&lt;br /&gt;100021 1 tcp 32776 nlockmgr&lt;br /&gt;100021 3 tcp 32776 nlockmgr&lt;br /&gt;100021 4 tcp 32776 nlockmgr&lt;br /&gt;100005 1 udp 956 mountd&lt;br /&gt;100005 1 tcp 959 mountd&lt;br /&gt;100005 2 udp 956 mountd&lt;br /&gt;100005 2 tcp 959 mountd&lt;br /&gt;100005 3 udp 956 mountd&lt;br /&gt;100005 3 tcp 959 mountd&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# cat /var/lib/nfs/rmtab&lt;br /&gt;192.168.200.135:192.168.200.0/255.255.255.0:0x00000001&lt;br /&gt;192.168.200.0/255.255.255.0:/usr/share:0x00000002&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# cat /var/lib/nfs/etab&lt;br /&gt;/usr/share 192.168.200.0/255.255.255.0(rw,sync,wdelay,hide,nocrossmnt,insecure,root_squash,no_all_squash,subtree_check,secure_locks,mapping=identity,anonuid=600,anongid=600)&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# cat /etc/exports&lt;br /&gt;#&lt;br /&gt;/usr/share 192.168.200.0/255.255.255.0(rw,insecure,sync,anonuid=600,anongid=600)&lt;br /&gt;&lt;br /&gt;[root@localhost sysconfig]# exportfs -v&lt;br /&gt;/usr/share 192.168.200.0/255.255.255.0(rw,wdelay,insecure,root_squash,anonuid=600,anongid=600)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;root@ubuntu:/mnt# showmount 192.168.200.128&lt;br /&gt;Hosts on 192.168.200.128:&lt;br /&gt;192.168.200.0/255.255.255.0&lt;br /&gt;192.168.200.135&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;root@ubuntu:/mnt# showmount -a 192.168.200.128&lt;br /&gt;All mount points on 192.168.200.128:&lt;br /&gt;192.168.200.0/255.255.255.0:/usr/share&lt;br /&gt;192.168.200.135:192.168.200.0/255.255.255.0&lt;br /&gt;&lt;br /&gt;root@ubuntu:/mnt# showmount -e 192.168.200.128&lt;br /&gt;Export list for 192.168.200.128:&lt;br /&gt;/usr/share 192.168.200.0/255.255.255.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;root@ubuntu:/mnt# showmount -d 192.168.200.128&lt;br /&gt;Directories on 192.168.200.128:&lt;br /&gt;/usr/share&lt;br /&gt;192.168.200.0/255.255.255.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NFS Client&lt;br /&gt;&lt;br /&gt;/etc/fstab&lt;br /&gt;* is the default value&lt;br /&gt;&lt;br /&gt;rsize = n *4096 sets the nfs read buffer size to n bytes&lt;br /&gt;wsize = n *4096 sets the nfs write buffer size to n bytes&lt;br /&gt;timeo = n *7 sets the RPC transmission timeout to n thenths of a second&lt;br /&gt;retry = n *10000 sets the time to retry a mount before giving up&lt;br /&gt;port = n *2049 sets the NFS server port to which to connect to&lt;br /&gt;bg *no enables mount attempts to run in the background if first mount attempt time out&lt;br /&gt;fg *yes causes mount attempts to run in foreground if the first mount attempt time out&lt;br /&gt;soft *no allows an NFS file operation to fail and terminate&lt;br /&gt;hard *yes allows an NFS file operation to continue retry after reporting "server not responding"&lt;br /&gt;&lt;br /&gt;intr *no allows signals (control+c) to interrupt a failed NFS operation&lt;br /&gt;&lt;br /&gt;lock enables NFS locking and starts the statd and lockd daemons&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;exportfs -o async,rw 192.168.200.128:/var/tmp&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mount -t nfs server:/share -o rsize=8192, wsize=8192, hard, intr, nolock&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mount -t iso9660 -o ro /dev/cdrom /cdrom&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;fstab file structure:&lt;br /&gt;&lt;br /&gt;/etc/fstab six fields: fstab-sync&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(1)block-device-to-be-mounted:&lt;br /&gt;(2)mount-point:&lt;br /&gt;(3)fs-type:&lt;br /&gt;(4)mount-options:&lt;br /&gt;(5)dump command to determine if it needs to be dumped or not 0=no&lt;br /&gt;(6)fsck check-order&lt;br /&gt;&lt;br /&gt;[root@localhost /]# cat /etc/fstab&lt;br /&gt;# This file is edited by fstab-sync - see 'man fstab-sync' for details&lt;br /&gt;/dev/VolGroup00/LogVol00 / ext3 defaults 1 1&lt;br /&gt;LABEL=/boot /boot ext3 defaults 1 2&lt;br /&gt;none /dev/pts devpts gid=5,mode=620 0 0&lt;br /&gt;none /dev/shm tmpfs defaults 0 0&lt;br /&gt;none /proc proc defaults 0 0&lt;br /&gt;none /sys sysfs defaults 0 0&lt;br /&gt;/dev/VolGroup00/LogVol01 swap swap defaults 0 0&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;NFS Troubleshooting:&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;1. when mount -t nfs remote:share local_mount_point, the system stalls and can't mount...&lt;br /&gt;&lt;br /&gt;check /var/log/messages file and see error "kernel: RPC: failed to contact portmap (errno -5)"&lt;br /&gt;portmap (rpc ) is not started.&lt;br /&gt;&lt;br /&gt;service portmap status ; to verify portmap is running or stopped&lt;br /&gt;service portmap start or /etc/init.d/portmap start to start portmap&lt;br /&gt;&lt;br /&gt;make sure also enable portmap at reboot, e.g. 'chkconfig --level 345 portmap on'&lt;br /&gt;&lt;br /&gt;why portmap/rpc must be started to use NFS? check out my blog article &lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;"understanding UNIX RPC in 1 minute!"&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Thanks for viewing!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7761449288750381913?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7761449288750381913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7761449288750381913'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/04/linux-nfs-quickguide.html' title='Linux NFS QuickGuide'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7349051906615836893</id><published>2010-03-25T17:20:00.000-07:00</published><updated>2010-04-02T12:51:16.766-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Installing Net::SSH::Perl  - SSH module for Perl</title><content type='html'>Before reading further, do you know how to find out what Perl modules are installed on your system? Hmm... &lt;br /&gt;&lt;br /&gt;How about "perldoc perllocal" or &lt;br /&gt;&lt;br /&gt;sed -n -e "/head2/p" /usr/local/lib/perl/5.10.0/perllocal.pod | cut -dL -f2 | sort &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Anyway, there are few other ways to do it. Make sure you know one of them.&lt;br /&gt;&lt;br /&gt;Today, I'm given a task to write a Perl script to scan 200 servers' Interwoven, EPA, JVM and web server configurations.  Normally, I'd like to use shell script to do anything related to SSH.  However, with so many text files to scan why don't we use Perl to do it?&lt;br /&gt;&lt;br /&gt;Perl SSH?  Google over the Internet (thanks for the US for not censoring Google's searching result), it appears Net::SSH::Perl is a good but tough candidate.  Most reviews complain about the painful installation process which makes it a challenge to me. I like pain, right? (not really)&lt;br /&gt;&lt;br /&gt;Now, let's see what is Net::SSH::Perl.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"Net::SSH::Perl is an all-Perl module implementing an SSH client. It is compatible with both the SSH1 and SSH2 protocols.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Net::SSH::Perl enables you to simply and securely execute commands on remote machines, and receive the STDOUT, STDERR, and exit status of that remote command."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Good enough. Let's do it. (For more information about Net::SSH::Perl, see &lt;a href="http://search.cpan.org/dist/Net-SSH-Perl/lib/Net/SSH/Perl.pm"&gt;CPAN&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Installation of Net::SSH::Perl is really painful if your system doesn't have the required Math packages. &lt;br /&gt;&lt;br /&gt;For cygwin, as of today (March 25,2010), because Perl 5.10.1 is compiled with gcc 4.3.4 (20090804) while gcc for cygwin is only at 3.4.4, the -fstack-protector gcc flags kills you.  I tried to force install the module, it always stop at complaining the -fstack-protector flag when running perl script calling SSH module. &lt;br /&gt;&lt;br /&gt;You have to recompile gcc in cygwin in order to use this module. To compile gcc, you need m4, Math::Pari, GMP, MFPR... OK, just kill me. I'm giving up.&lt;br /&gt;&lt;br /&gt;Luckily, we have Ubuntu. With the pleasant apt-get utility, installation is much better than cygwin.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Installing Net::SSH::Perl module on Linux server (Ubuntu 9.x)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I'm using a dirty quick solution, first, let's cpan the module with force; then, we clean up the mess. Don't try it on production systems.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Force install Net::SSH::Perl&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;cpan&gt; force install Net::SSH::Perl&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Clean up work.  Let's see the error messages at the end of installation and re-install these packages manually.&lt;br /&gt;&lt;br /&gt;Go to .cpan/build/ and compile the following packages manually. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt; ILYAZ/modules/Math-Pari-2.01080604.tar.gz    : writemakefile NO '/usr/bin/perl Makefile.PL INSTALLDIRS=site' returned status 2304&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; VIPUL/Crypt-Random-1.25.tar.gz               : make_test FAILED but failure ignored because 'force' in effect&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; VIPUL/Crypt-Primes-0.50.tar.gz               : make_test FAILED but failure ignored because 'force' in effect&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; VIPUL/Crypt-RSA-1.99.tar.gz                  : make_test FAILED but failure ignored because 'force' in effect&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; TURNSTEP/Math-GMP-2.06.tar.gz                : make NO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; TURNSTEP/Net-SSH-Perl-1.34.tar.gz            : make_test FAILED but failure ignored because 'force' in effect&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For GMP, because it was never installed, download it from http://gmplib.org/.&lt;br /&gt;However, before we install GMP, we need to install m4...&lt;br /&gt;To Install m4, we need to install (nothing)... there's always a clue that leads to another clue before you can find the treasure.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;sudo apt-get install m4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;download gmp  from http://gmplib.org/  and compile/install it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, we need to check what Perl modules are installed on our server: (yes, another good interview question).&lt;br /&gt;&lt;br /&gt;1. If "instmodsh" is available, use that.&lt;br /&gt;&lt;br /&gt;2. Or use "perldoc perllocal". Or&lt;br /&gt;&lt;br /&gt;3. Check the &lt;span style="font-family: courier new;"&gt;perllocal.pod&lt;/span&gt; directly:&lt;br /&gt;&lt;br /&gt;root@ubuntu:~/perl# sed -n -e "/head2/p" /usr/local/lib/perl/5.10.0/perllocal.pod | cut -dL -f2 | sort&lt;br /&gt;&amp;lt Class::&lt;br /&gt;&amp;lt convert::ascii::armour|convert::ascii::armour&gt;&lt;br /&gt;&amp;lt convert::asn1|convert::asn1&gt;&lt;br /&gt;&amp;lt convert::pem|convert::pem&gt;&lt;br /&gt;&amp;lt crypt::blowfish|crypt::blowfish&gt;&lt;br /&gt;&amp;lt crypt::cbc|crypt::cbc&gt;&lt;br /&gt;&amp;lt crypt::des|crypt::des&gt;&lt;br /&gt;&amp;lt crypt::des_ede3|crypt::des_ede3&gt;&lt;br /&gt;&amp;lt crypt::dh|crypt::dh&gt;&lt;br /&gt;&amp;lt crypt::dsa|crypt::dsa&gt;&lt;br /&gt;&amp;lt crypt::idea|crypt::idea&gt;&lt;br /&gt;&amp;lt crypt::primes|crypt::primes&gt;&lt;br /&gt;&amp;lt crypt::primes|crypt::primes&gt;&lt;br /&gt;&amp;lt crypt::primes|crypt::primes&gt;&lt;br /&gt;&amp;lt crypt::random|crypt::random&gt;&lt;br /&gt;&amp;lt crypt::random|crypt::random&gt;&lt;br /&gt;&amp;lt crypt::random|crypt::random&gt;&lt;br /&gt;&amp;lt crypt::rsa|crypt::rsa&gt;&lt;br /&gt;&amp;lt data::buffer|data::buffer&gt;&lt;br /&gt;&amp;lt dbi|dbi&gt;&lt;br /&gt;&amp;lt digest::bubblebabble|digest::bubblebabble&gt;&lt;br /&gt;&amp;lt digest::hmac|digest::hmac&gt;&lt;br /&gt;&amp;lt digest::md2|digest::md2&gt;&lt;br /&gt;&amp;lt digest::sha1|digest::sha1&gt;&lt;br /&gt;&amp;lt file::homedir|file::homedir&gt;&lt;br /&gt;&amp;lt file::which|file::which&gt;&lt;br /&gt;&amp;lt ipc::run3|ipc::run3&gt;&lt;br /&gt;&amp;lt math::pari|math::pari&gt;&lt;br /&gt;&amp;lt net::ssh::perl|net::ssh::perl&gt;&lt;br /&gt;&amp;lt sort::versions|sort::versions&gt;&lt;br /&gt;&amp;lt string::crc32|string::crc32&gt;&lt;br /&gt;&amp;lt test::script|test::script&gt;&lt;br /&gt;&amp;lt test::simple|test::simple&gt;&lt;br /&gt;&amp;lt tie::encryptedhash|tie::encryptedhash&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OK. Now, it's time to check our handy Net::SSH:Perl module.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;#!/usr/bin/perl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$host = localhost;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$cmd = "uname -n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;print "Trying to ssh into server $host. Please wait...\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;use Net::SSH::Perl;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    my $ssh = Net::SSH::Perl-&gt;new($host);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    $ssh-&gt;login("shan","newyork1");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    $ssh-&gt;shell;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;root@ubuntu:~/perl# perl ssh1.pl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Trying to ssh into server localhost. Please wait...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCalc at /usr/local/share/perl/5.10.0/Crypt/DH.pm line 6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Last login: Thu Mar 25 14:57:18 2010 from localhost&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;shan@ubuntu:~$ uname -a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;uname -a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Linux ubuntu 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;shan@ubuntu:~$ id&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;id&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;uid=1000(shan) gid=1000(shan) groups=4(adm),20(dialout),24(cdrom),46(plugdev),104(lpadmin),115(admin),120(sambashare),1000(shan)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;shan@ubuntu:~$&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;shan@ubuntu:~$ exit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;exit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;logout&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It opens an ssh connection!&lt;br /&gt;&lt;br /&gt;The installation is painful but not completely bad.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7349051906615836893?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7349051906615836893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7349051906615836893'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/03/installing-netsshperl-ssh-module-for.html' title='Installing Net::SSH::Perl  - SSH module for Perl'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3479250740944268220</id><published>2010-01-07T14:44:00.000-08:00</published><updated>2010-01-11T21:18:42.435-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visitor Tracking Report'/><title type='text'>Shan's UNIX Admin Blog Worldwide Visitors Tracking Report</title><content type='html'>Note:&lt;br /&gt;&lt;span style="font-size:78%;"&gt;All visitors private data (such as location, IP address, OS, configuration, referring URL, browsing history, etc.) is protected and won't be released to third party.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Welcome to my blog, happy surfing!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;December 2009 Visitor Tracking Report&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Visitors by Continent (6 Continents including an "&lt;span style="color: rgb(255, 0, 0);"&gt;Unknown Continent&lt;/span&gt;"... Mars?)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0Z6JOM2x3I/AAAAAAAACm4/dFd6cK4LlO4/s1600-h/continent-tracking.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 356px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0Z6JOM2x3I/AAAAAAAACm4/dFd6cK4LlO4/s400/continent-tracking.jpg" alt="" id="BLOGGER_PHOTO_ID_5424157100063770482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;(click image to enlarge)&lt;br /&gt;&lt;br /&gt;Visitors by Country  (21 Countries)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0uFuRxn6dI/AAAAAAAACnA/Kj4DS3ad9y4/s1600-h/country-tracking.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 388px; height: 400px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0uFuRxn6dI/AAAAAAAACnA/Kj4DS3ad9y4/s400/country-tracking.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5425577206189910482" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors by Domain (Last 72 hours data only)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0Z4G3yehPI/AAAAAAAACmw/I8frSrHoEDw/s1600-h/domain-tracking2.jpg"&gt;&lt;img style="cursor: pointer; width: 386px; height: 400px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0Z4G3yehPI/AAAAAAAACmw/I8frSrHoEDw/s400/domain-tracking2.jpg" alt="" id="BLOGGER_PHOTO_ID_5424154860664554738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors by Organization&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0OhtvIreDI/AAAAAAAACko/1Flt9e3n0UI/s1600-h/organization-tracking.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 365px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0OhtvIreDI/AAAAAAAACko/1Flt9e3n0UI/s400/organization-tracking.jpg" alt="" id="BLOGGER_PHOTO_ID_5423356183403264050" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors by Operating System&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0OhFrVTmjI/AAAAAAAACkQ/vmWFVYikJwg/s1600-h/os-tracking.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 356px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0OhFrVTmjI/AAAAAAAACkQ/vmWFVYikJwg/s400/os-tracking.jpg" alt="" id="BLOGGER_PHOTO_ID_5423355495187716658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors by Desktop Resolution (The largest one was 3480 x 1200, what a good video card!)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0OhazUC5AI/AAAAAAAACkY/pXncM8MvmGA/s1600-h/resolution-tracking.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 397px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0OhazUC5AI/AAAAAAAACkY/pXncM8MvmGA/s400/resolution-tracking.jpg" alt="" id="BLOGGER_PHOTO_ID_5423355858107163650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors Site Duration&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0OiD0s7ZbI/AAAAAAAACk4/ZEzNCy_gIBk/s1600-h/daily-duration.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 382px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0OiD0s7ZbI/AAAAAAAACk4/ZEzNCy_gIBk/s400/daily-duration.jpg" alt="" id="BLOGGER_PHOTO_ID_5423356562854602162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Visitors Daily Pageview&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0Oh5voTQFI/AAAAAAAACkw/Psl2HRRVY_Y/s1600-h/pageview.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 381px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0Oh5voTQFI/AAAAAAAACkw/Psl2HRRVY_Y/s400/pageview.jpg" alt="" id="BLOGGER_PHOTO_ID_5423356389694324818" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3479250740944268220?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3479250740944268220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3479250740944268220'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/shans-unix-admin-blog-worldwide.html' title='Shan&apos;s UNIX Admin Blog Worldwide Visitors Tracking Report'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_if8QouXbicI/S0Z6JOM2x3I/AAAAAAAACm4/dFd6cK4LlO4/s72-c/continent-tracking.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8414174101973539204</id><published>2010-01-06T09:07:00.000-08:00</published><updated>2010-04-02T12:50:48.880-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Perl Regular Expression Summary</title><content type='html'>&lt;pre&gt;&lt;br /&gt;Meta Characters&lt;br /&gt;\s   white space [\f\t\n\r ] or form-feed, tab, newline, carriage return, space&lt;br /&gt;\d   any digit [0-9]&lt;br /&gt;\w   word character [A-Za-z0-9_].  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Matches with m//&lt;br /&gt;&lt;br /&gt;m/\w*?/  m(\w*?) m{w*?} or m#http://# ....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Perl's Option Modifiers  /s /i /x or "/six"&lt;br /&gt;&lt;br /&gt;/s : #it searches pattern in multiple lines across newlines '\n'; the "." looks within single line&lt;br /&gt;/i : #case (i)nsensitive&lt;br /&gt;/x : #add white space, useful for adding comments in regular expressions&lt;br /&gt;&lt;br /&gt;You can combine option modifiers&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Word Anchors /\bword\b/ or #\bword\b#&lt;br /&gt;&lt;br /&gt;#\bperl#   matches  "perlscripting"&lt;br /&gt;&lt;br /&gt;#perl\b#   matches  "useperl"&lt;br /&gt;&lt;br /&gt;#\bsearc\B# matches "searches", "searching" but not "search" or "researching"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Binding Operator  =~&lt;br /&gt;&lt;br /&gt;my #anwser = &amp;lt;STDIN&gt; =~ #\byes\b/i;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Match Variables  $1, $2, ..., $` $&amp;amp; $'&lt;br /&gt;&lt;br /&gt;if (#(\S+); (\S+); (\S+)#) {&lt;br /&gt;print "$1    $2     $3 \n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Note: sometimes, you need quote '$1' in print"";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It's always good to save your match in a variable instead of $1 as $1 may be changed by other matches&lt;br /&gt;&lt;br /&gt;if ($statement =~ /(\w+)/) {&lt;br /&gt;my $magicword = $1;&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Parentheses for grouping only - non-capturing parentheses (?:)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 1 #!/usr/bin/perl&lt;br /&gt; 2 use strict;&lt;br /&gt; 3&lt;br /&gt; 4 while (&amp;lt;&gt;) {&lt;br /&gt; 5 if ( m#(?:UNIX).*?(Solaris|AIX|Linux)#i )  {&lt;br /&gt; 6     print "$1\n";&lt;br /&gt; 7 }&lt;br /&gt; 8 }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ cat job.txt&lt;br /&gt;Required skills:&lt;br /&gt;1) 5 to 10 years Perl or Python , shell scripting skills;&lt;br /&gt;2) at least 10 years UNIX e.g. AIX Solaris Linux Administration skills;&lt;br /&gt;3) 5 to 10 years weblogic, tomcat, websphere administration skills;&lt;br /&gt;Preferred skills:&lt;br /&gt;1) UNIX Internal Coding Skills with Python, Perl or C;&lt;br /&gt;2) TCP/IP Internal and Protocols;&lt;br /&gt;3) Understand Java Servlets/JSP/Web Applications;&lt;br /&gt;4) Understand Oracle/Sybase/MySQL;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# $1 is AIX not UNIX because (?:UNIX) is non-capturing.&lt;br /&gt;$ ./98.pl &amp;lt; job.txt&lt;br /&gt;AIX&lt;br /&gt;&lt;br /&gt;shan@InternetPC ~/perl&lt;br /&gt;$&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Named Captures&lt;br /&gt;&lt;br /&gt;In addition to capturing parts of string in $1, $2, $3...&lt;br /&gt;Perl allows you to name captures in hash named %+: the key&lt;br /&gt;is the lable we used and the value is the matched part in regex.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 1 #!/usr/bin/perl&lt;br /&gt; 2 use 5.010;&lt;br /&gt; 3&lt;br /&gt; 4&lt;br /&gt; 5 while (&amp;lt;&gt;) {&lt;br /&gt; 6 if ( m/(?:UNIX)\s*(?&amp;lt;os1&gt;\w+) (?&amp;lt;os2&gt;\w+) (?&amp;lt;os3&gt;\w+) / ) {&lt;br /&gt; 7 say "Required Operating Systems are $+{os1} $+{os2} $+{os3}\n";&lt;br /&gt; 8 }&lt;br /&gt; 9 }&lt;br /&gt;&lt;br /&gt;$ ./912.pl &amp;lt; job.txt&lt;br /&gt;Required Operating Systems are AIX Solaris Linux&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NEED to know vim copy groups between (...), eg copy block of chars inside parentheses&lt;br /&gt;&lt;br /&gt;*****************************&lt;br /&gt;Now that we have a way to label matches, we also need a way to refer to them for back&lt;br /&gt;references. Previously, we used either \1 or \g{1} for this. With a labeled group, we can&lt;br /&gt;use the label in \g{label}:&lt;br /&gt;use 5.010;&lt;br /&gt;my $names = 'Fred Flinstone and Wilma Flinstone';&lt;br /&gt;if( $names =~ m/(?&amp;lt;last_name&gt;\w+) and \w+ \g{last_name}/ ) {&lt;br /&gt;say "I saw $+{last_name}";&lt;br /&gt;}&lt;br /&gt;We can do the same thing with another syntax. Instead of using \g{label}, we use&lt;br /&gt;\k&amp;lt;label&gt;:?&lt;br /&gt;use 5.010;&lt;br /&gt;my $names = 'Fred Flinstone and Wilma Flinstone';&lt;br /&gt;if( $names =~ m/(?&amp;lt;last_name&gt;\w+) and \w+ \k&amp;lt;last_name&gt;/ ) {&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;&lt;br /&gt;General Quantifiers&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Substitutions with S///  : search and replace&lt;br /&gt;&lt;br /&gt;$_ = "green scaly dinosaur";&lt;br /&gt;s/(\w+) (\w+)/$2, $1/; # Now it's "scaly, green dinosaur"&lt;br /&gt;s/^/huge, /; # Now it's "huge, scaly, green dinosaur"&lt;br /&gt;s/,.*een//; # Empty replacement: Now it's "huge dinosaur"&lt;br /&gt;s/green/red/; # Failed match: still "huge dinosaur"&lt;br /&gt;s/\w+$/($`!)$&amp;amp;/; # Now it's "huge (huge !)dinosaur"&lt;br /&gt;s/\s+(!\W+)/$1 /; # Now it's "huge (huge!) dinosaur"&lt;br /&gt;s/huge/gigantic/; # Now it's "gigantic (huge!) dinosaur"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There is a useful Boolean value from s///;&lt;br /&gt;it is true if a substitution was successful;&lt;br /&gt;otherwise, it is false:&lt;br /&gt;&lt;br /&gt;$_ = "fred flintstone";&lt;br /&gt;if (s/fred/wilma/) {&lt;br /&gt;print "Successfully replaced fred with wilma!\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Option Modifiers: /s /i /x  or "six"&lt;br /&gt;&lt;br /&gt;s{ABC}{}s;&lt;br /&gt;&lt;br /&gt;The Binding Operator : =~&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Case Shifting&lt;br /&gt;&lt;br /&gt;\U      ; # \U escape forces what follows to all upper case&lt;br /&gt;\L      ; # \L escape forces lowercase&lt;br /&gt;&lt;br /&gt;$_=" Steve and John are good friends\n";&lt;br /&gt;s/(steve|john)/\U$1/gi        -&gt; STEVE and JOHN ...&lt;br /&gt;s/(steve|john)/|L$1/gi        -&gt; steve and john ...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can even stack them up.&lt;br /&gt;Using \u with \L means ¡°all lowercase, but capitalize the&lt;br /&gt;first letter¡±:*&lt;br /&gt;&lt;br /&gt;s/(fred|barney)/\u\L$1/ig; # $_ is now "I saw Fred with Barney."&lt;br /&gt;&lt;br /&gt;The split and join operators&lt;br /&gt;@fields = split /separator/, $string;&lt;br /&gt;@fields = split /:/, "abc:def::g:h"; # gives ("abc", "def", "", "g", "h")&lt;br /&gt;&lt;br /&gt;my $result = join $glue, @pieces;&lt;br /&gt;my $x = join ":", 4, 6, 8, 10, 12; # $x is "4:6:8:10:12"&lt;br /&gt;&lt;br /&gt;m// in list context&lt;br /&gt;&lt;br /&gt;When a pattern match (m//) is used in a list context, the return value is a list of the&lt;br /&gt;memory variables created in the match, or an empty list if the match failed:&lt;br /&gt;$_ = "Hello there, neighbor!";&lt;br /&gt;my($first, $second, $third) = /(\S+) (\S+), (\S+)/;&lt;br /&gt;print "$second is my $third\n";&lt;br /&gt;&lt;br /&gt;my $text = "Fred dropped a 5 ton granite block on Mr. Slate";&lt;br /&gt;my @words = ($text =~ /([a-z]+)/ig);&lt;br /&gt;print "Result: @words\n";&lt;br /&gt;# Result: Fred dropped a ton granite block on Mr Slate&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Nongreedy Quantifiers "?"   :  *? +?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;curl 'http://www.google.com' | perl -e 'while (&amp;lt;&gt;) { m#&amp;lt;style&gt;(.*?)&amp;lt;/style&gt;#; print "$&amp;amp;\n";}'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Matching Multiple-Line Text  "/m"  m=multiple lines&lt;br /&gt;&lt;br /&gt;This is where Perl beats classic regular expressions. Perl can match multiple lines of text&lt;br /&gt;just as matching single lines.&lt;br /&gt;&lt;br /&gt;13 #9.15&lt;br /&gt;14 $_="The only reason I'm using Perl is because \n it is perfect for processing text files \n with the built-in regular expressions in Perl.\n";&lt;br /&gt;15&lt;br /&gt;16 print "Found 'perl' at start of line\n" if /\bperl\b/im;&lt;br /&gt;17 print "$`:$&amp;amp;:$'\n";&lt;br /&gt;&lt;br /&gt;Found 'perl' at start of line&lt;br /&gt;The only reason I'm using :Perl: is because&lt;br /&gt;it is perfect for processing text files&lt;br /&gt;with the built-in regular expressions in Perl.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;19 #9.16 read entire google.html file into one variable, then add "__HTML__" in front of each line&lt;br /&gt;20 $filename="/home/shan/perl/google.html";&lt;br /&gt;21 open FILE, $filename&lt;br /&gt;22 or die "Can't open '$filename': $!";&lt;br /&gt;23 my $lines = join '', &amp;lt;FILE&gt;;&lt;br /&gt;24 $lines =~ s/^/__HTML__: /gm;&lt;br /&gt;25 print $lines;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Updating Many Files:&lt;br /&gt;&lt;br /&gt; 1 #!/usr/bin/perl -w&lt;br /&gt; 2 # perl script to process many files&lt;br /&gt; 3 #&lt;br /&gt; 4 # usage : prcfile.pl input-file&lt;br /&gt; 5 #&lt;br /&gt; 6 # it will run regex operation inside while on input-file&lt;br /&gt; 7 # and saves the original file in the name input-file.org&lt;br /&gt; 8&lt;br /&gt; 9&lt;br /&gt;10 use strict;&lt;br /&gt;11&lt;br /&gt;12 #name your own file extension for backup copy of the original file&lt;br /&gt;13 $^I = ".org";&lt;br /&gt;14&lt;br /&gt;15 chomp (my $date = `date`);&lt;br /&gt;16 while (&amp;lt;&gt;) {&lt;br /&gt;17&lt;br /&gt;18 #insert your regex operations here:&lt;br /&gt;19 s/^/$date:/;&lt;br /&gt;20 s/$/___END___/;&lt;br /&gt;21&lt;br /&gt;22 #update&lt;br /&gt;23 print;&lt;br /&gt;24 }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$./prcfile 9.pl&lt;br /&gt;&lt;br /&gt;$ more 9.pl&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:#!/usr/bin/perl___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:$_="steve and John are good friends\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:s/(steve|john)/\U$1/gi;        #-&gt; STEVE and JOHN ...___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:print "$_\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:$_="steve and John are good friends\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:s/(steve|john)/\L$1/gi;        #-&gt; steve and john ...___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:print "$_\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:#9.15___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:$_="The only reason I'm using Perl is because \n it is perfect for processing text files \n with the built-in regular expressions in Perl.\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:print "Found 'perl' at start of line\n" if /\bperl\b/im;___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:print "$`:$&amp;amp;:$'\n";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:#9.16___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:$filename="/home/shan/perl/google.html";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:open FILE, $filename___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:or die "Can't open '$filename': $!";___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:my $lines = join '', &amp;lt;FILE&gt;;___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:$lines =~ s/^/__HTML__: /gm;___END___&lt;br /&gt;Mon Dec 14 17:09:45 PST 2009:print $lines;___END___&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or, we can use command line to do the same:&lt;br /&gt;&lt;br /&gt;perl -p -i.org -w -e 'chomp (my $date=`date`);s/^/$date:/g;' 9.pl&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here are the explanations of these command line options,&lt;br /&gt;&lt;br /&gt;1. "perl -p"  :&lt;br /&gt;&lt;br /&gt;while ($_ = &amp;lt;STDIN&gt;) {&lt;br /&gt;print $_;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$_ , = and STDIN are all optional.&lt;br /&gt;&lt;br /&gt;therefore, the above code can be written as:&lt;br /&gt;&lt;br /&gt;while (&amp;lt;&gt;) {&lt;br /&gt;print;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2. "-i.org"  #sets $^I to ".org"&lt;br /&gt;&lt;br /&gt;3. "-w"      #turns on warnings&lt;br /&gt;&lt;br /&gt;4. -e " executable codes "&lt;br /&gt;&lt;br /&gt;5. @ARGV&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8414174101973539204?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8414174101973539204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8414174101973539204'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/perl-regular-expression-summary.html' title='Perl Regular Expression Summary'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-1323811520170004283</id><published>2010-01-05T19:58:00.000-08:00</published><updated>2010-01-08T09:47:15.478-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='* My Blog Pages Ranked Top 10 in Google *'/><title type='text'>Pages in My Blog Ranked as Top 10 Search Results in Google</title><content type='html'>Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;troubleshooting solaris 10 jumpstart&lt;/span&gt;" or "&lt;span style="color: rgb(255, 255, 102);"&gt;solaris jumpstart interrupt&lt;/span&gt;"&lt;br /&gt;Technical area: Solaris Administration&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 0, 0);"&gt;First&lt;/span&gt;  (click image to enlarge)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0OC8RUXVII/AAAAAAAACg8/22HBCe8Uh7s/s1600-h/google-solaris-jumpstart.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0OC8RUXVII/AAAAAAAACg8/22HBCe8Uh7s/s400/google-solaris-jumpstart.jpg" alt="" id="BLOGGER_PHOTO_ID_5423322348236788866" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0OCWT535LI/AAAAAAAACgs/_zt-8EjnBww/s1600-h/google-solaris-jumpstart-interrupt.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0OCWT535LI/AAAAAAAACgs/_zt-8EjnBww/s400/google-solaris-jumpstart-interrupt.jpg" alt="" id="BLOGGER_PHOTO_ID_5423321696095954098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;aix paging space weblogic&lt;/span&gt;"&lt;br /&gt;Technical area: AIX Administration, Weblogic Administration, Performance Tuning&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 0, 0);"&gt;Top 3/First&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0Ul8sxOV4I/AAAAAAAACmY/CAJ7bZoS5L8/s1600-h/google-aix-paging-weblogic.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0Ul8sxOV4I/AAAAAAAACmY/CAJ7bZoS5L8/s400/google-aix-paging-weblogic.jpg" alt="" id="BLOGGER_PHOTO_ID_5423783050977630082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;crashdump + savecore + solaris 10&lt;/span&gt;"&lt;br /&gt;Technical area: Solaris Administration&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 4&lt;/span&gt; (search engine google.ca)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S0YcYMpYotI/AAAAAAAACmo/o_62gc1hZAc/s1600-h/google-crashdump-savecore.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S0YcYMpYotI/AAAAAAAACmo/o_62gc1hZAc/s400/google-crashdump-savecore.jpg" alt="" id="BLOGGER_PHOTO_ID_5424054003251585746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;aix sybase tuning&lt;/span&gt;"&lt;br /&gt;Technical area: AIX administration, sybase performance tuning&lt;br /&gt;Google Rank : &lt;span style="color: rgb(255, 255, 102);"&gt;Top 10&lt;/span&gt; (Engine: google.com.co)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0VeQ5f3TzI/AAAAAAAACmg/BiJzBbVCJqU/s1600-h/google-sybase2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0VeQ5f3TzI/AAAAAAAACmg/BiJzBbVCJqU/s400/google-sybase2.jpg" alt="" id="BLOGGER_PHOTO_ID_5423844970643017522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;aix mirrorvg sync&lt;/span&gt;"&lt;br /&gt;Technical area: AIX Administration&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 3&lt;/span&gt; (January 2010 google korea)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0QITvJ_csI/AAAAAAAAClg/H_-DzABk7uY/s1600-h/google-AIX-mirror-rootvg.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0QITvJ_csI/AAAAAAAAClg/H_-DzABk7uY/s400/google-AIX-mirror-rootvg.jpg" alt="" id="BLOGGER_PHOTO_ID_5423468986429829826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Appearance in a Korean user's google korea search engine&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0QKs-TS3hI/AAAAAAAAClo/VnZDWfYaS8I/s1600-h/google-korea.jpg"&gt;&lt;img style="cursor: pointer; width: 313px; height: 400px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0QKs-TS3hI/AAAAAAAAClo/VnZDWfYaS8I/s400/google-korea.jpg" alt="" id="BLOGGER_PHOTO_ID_5423471619015368210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;maxperm sybase ase&lt;/span&gt;"&lt;br /&gt;Technical area: AIX/Sybase Performance Tuning&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 3&lt;/span&gt;  (December 2009)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0ODStmohgI/AAAAAAAAChE/LWpHkiOnGVg/s1600-h/google-sybase.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0ODStmohgI/AAAAAAAAChE/LWpHkiOnGVg/s400/google-sybase.jpg" alt="" id="BLOGGER_PHOTO_ID_5423322733786727938" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords " &lt;span style="color: rgb(255, 255, 102);"&gt;rpcinfo clnt_create&lt;/span&gt;"&lt;br /&gt;Technical area: UNIX Client/Server RPC&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 3&lt;/span&gt; (December 2009)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S0OErviBy9I/AAAAAAAAChU/4Jgbh4o8sNc/s1600-h/google-rpc.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S0OErviBy9I/AAAAAAAAChU/4Jgbh4o8sNc/s400/google-rpc.jpg" alt="" id="BLOGGER_PHOTO_ID_5423324263312640978" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S0OFrELnwpI/AAAAAAAAChc/OEf5mJx2qnU/s1600-h/google-rpc2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S0OFrELnwpI/AAAAAAAAChc/OEf5mJx2qnU/s400/google-rpc2.jpg" alt="" id="BLOGGER_PHOTO_ID_5423325351187563154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;showmount -e RPC Program Not Registered&lt;/span&gt;"&lt;br /&gt;Technical area: UNIX NFS&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 3&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0PIewZ2tFI/AAAAAAAAClY/aFYhXdjBPeQ/s1600-h/google-showmount.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0PIewZ2tFI/AAAAAAAAClY/aFYhXdjBPeQ/s400/google-showmount.jpg" alt="" id="BLOGGER_PHOTO_ID_5423398806999184466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keyword  "&lt;span style="color: rgb(255, 255, 102);"&gt;vimshell&lt;/span&gt;"&lt;br /&gt;Technical area: UNIX utility&lt;br /&gt;Google Rank : &lt;span style="color: rgb(255, 255, 102);"&gt;Top 10&lt;/span&gt; (December 2009)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0OG_NiyqcI/AAAAAAAAChk/97AB5k4wERc/s1600-h/google-vimshell-kr.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 213px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0OG_NiyqcI/AAAAAAAAChk/97AB5k4wERc/s400/google-vimshell-kr.jpg" alt="" id="BLOGGER_PHOTO_ID_5423326796809677250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;userauth_failure&lt;/span&gt;" or "&lt;span style="color: rgb(255, 255, 102);"&gt;ssh state_expect_newkeys&lt;/span&gt;"&lt;br /&gt;Technical area: SSH troubleshooting&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 10&lt;/span&gt; (December 2009)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0OHvIfEWII/AAAAAAAAChs/B4me1IVWr5g/s1600-h/google-userauth_failure.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0OHvIfEWII/AAAAAAAAChs/B4me1IVWr5g/s400/google-userauth_failure.jpg" alt="" id="BLOGGER_PHOTO_ID_5423327620085602434" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0OH9RKb-wI/AAAAAAAACh0/J-wvspNEtag/s1600-h/google-ssh2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0OH9RKb-wI/AAAAAAAACh0/J-wvspNEtag/s400/google-ssh2.jpg" alt="" id="BLOGGER_PHOTO_ID_5423327862933158658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Keywords "&lt;span style="color: rgb(255, 255, 102);"&gt;fatal accept_ctx died&lt;/span&gt;"&lt;br /&gt;Technical area: ssh/scp/sftp troubleshooting&lt;br /&gt;Google Rank: &lt;span style="color: rgb(255, 255, 102);"&gt;Top 3&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S0QQ2Y9xfhI/AAAAAAAAClw/lwZhbVR6GnE/s1600-h/google-fatal-error.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S0QQ2Y9xfhI/AAAAAAAAClw/lwZhbVR6GnE/s400/google-fatal-error.jpg" alt="" id="BLOGGER_PHOTO_ID_5423478377861447186" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-1323811520170004283?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1323811520170004283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1323811520170004283'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/pages-in-my-blog-ranked-as-top-10_05.html' title='Pages in My Blog Ranked as Top 10 Search Results in Google'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_if8QouXbicI/S0OC8RUXVII/AAAAAAAACg8/22HBCe8Uh7s/s72-c/google-solaris-jumpstart.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-9184424469965717804</id><published>2010-01-05T14:25:00.000-08:00</published><updated>2010-01-05T19:40:39.993-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Admin - Apache Tomcat Weblogic Java'/><title type='text'>Weblogic Setup Quick Guide</title><content type='html'>General Procedures:&lt;br /&gt;&lt;br /&gt;1. Setup Unix environments (user/group ids, filesystems, tools, access - sudo, etc.)&lt;br /&gt;2. Install WebLogic, JDK, Web Application Development Tools (ant, XML editors EditiX)&lt;br /&gt;3. If production requires middle tier High Availability, setup Veritas VCS application agent monitoring java process and filesystems. I posted a Weblogic HA setup procedure in 2002 at &lt;a href="http://mailman.eng.auburn.edu/pipermail/veritas-ha/2002-August/007167.html"&gt;THIS SITE&lt;/a&gt;.&lt;br /&gt;4. Setup Web Application Containers in Weblogic environment&lt;br /&gt;&lt;br /&gt;Weblogic Admin port 7001&lt;br /&gt;&lt;br /&gt;Variables:&lt;br /&gt;export JRE_HOME=/opt/SDK/jdk&lt;br /&gt;export JAVA_HOME=/opt/SDK/jdk&lt;br /&gt;export CLASSPATH=/data/lib/servlet-api.jar&lt;br /&gt;&lt;br /&gt;Sample servlet WAR structure:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;myServletWAR\&lt;br /&gt;  META-INF\&lt;br /&gt;  WEB-INF\&lt;br /&gt;     classes\&lt;br /&gt;        HelloServlet.class&lt;br /&gt;     web.xml&lt;br /&gt;&lt;br /&gt;web.xml deployment descriptor&lt;br /&gt;&lt;br /&gt;&amp;lt;servlet&gt;&lt;br /&gt;web.xml&lt;br /&gt;&lt;br /&gt;&amp;lt;servlet&gt;&lt;br /&gt;   &amp;lt;servlet-name&gt;myHello&amp;lt;/servlet-name&gt;&lt;br /&gt;   &amp;lt;servlet-class&gt;HelloServlet&amp;lt;/servlet-class&gt;&lt;br /&gt;&amp;lt;/servlet&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;servlet-mapping&gt;&lt;br /&gt;   &amp;lt;servlet-name&gt;myHello&amp;lt;/servlet-name&gt;&lt;br /&gt;   &amp;lt;url-pattern&gt;/hello&amp;lt;/url-pattern&gt;&lt;br /&gt;&amp;lt;/servlet-mapping&gt;&lt;br /&gt;   &amp;lt;servlet-name&gt;&amp;lt;/servlet-name&gt;&amp;lt;/servlet&gt;&amp;lt;servlet-mapping&gt;&amp;lt;url-pattern&gt;&amp;lt;/url-pattern&gt;&lt;br /&gt;&amp;lt;/servlet-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Sample Weblogic Installation:&lt;br /&gt;&lt;br /&gt;The following Products and JDKs will be installed:&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;WebLogic Platform 10.3.2.0&lt;br /&gt;|_____WebLogic Server&lt;br /&gt;|    |_____Core Application Server&lt;br /&gt;|    |_____Administration Console&lt;br /&gt;|    |_____Configuration Wizard and Upgrade Framework&lt;br /&gt;|    |_____Web 2.0 HTTP Pub-Sub Server&lt;br /&gt;|    |_____WebLogic SCA&lt;br /&gt;|    |_____WebLogic JDBC Drivers&lt;br /&gt;|    |_____Third Party JDBC Drivers&lt;br /&gt;|    |_____WebLogic Server Clients&lt;br /&gt;|    |_____WebLogic Web Server Plugins&lt;br /&gt;|    |_____UDDI and Xquery Support&lt;br /&gt;|_____Oracle Enterprise Pack for Eclipse&lt;br /&gt;|    |_____Common Files&lt;br /&gt;|_____JDKs&lt;br /&gt;|_____Sun SDK 1.6.0_14&lt;br /&gt;|_____Oracle JRockit 1.6.0_14 SDK&lt;br /&gt;&lt;br /&gt;*Estimated size of installation: 1,251.9 MB&lt;br /&gt;&lt;br /&gt;Production Mode&lt;br /&gt;Sun SDK 1.6&lt;br /&gt;JRocket SDK 1.6&lt;br /&gt;&lt;br /&gt;admin server ipc4.shanjing.com:7001&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Startup of Weblogic&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);font-size:85%;" &gt;&lt;span style="font-family:courier new;"&gt;./wlserver_10.3/samples/domains/wl_server/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;-bash-3.00$ ./startWebLogic.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;JAVA Memory arguments: -Xms512m -Xmx512m&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;WLS Start Mode=Development&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CLASSPATH=/data/weblogic/mw/wlserver_10.3/samples/server/examples/build/serverclasses:/data/weblogic/mw/patch_wls1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/data/weblogic/mw/patch_oepe1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/data/weblogic/mw/jrockit_160_14_R27.6.5-32/lib/tools.jar:/data/weblogic/mw/utils/config/10.3/config-launch.jar:/data/weblogic/mw/wlserver_10.3/server/lib/weblogic_sp.jar:/data/weblogic/mw/wlserver_10.3/server/lib/weblogic.jar:/data/weblogic/mw/modules/features/weblogic.server.modules_10.3.2.0.jar:/data/weblogic/mw/wlserver_10.3/server/lib/webservices.jar:/data/weblogic/mw/modules/org.apache.ant_1.7.0/lib/ant-all.jar:/data/weblogic/mw/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar::/data/weblogic/mw/wlserver_10.3/common/eval/pointbase/lib/pbembedded57.jar:/data/weblogic/mw/wlserver_10.3/common/eval/pointbase/lib/pbclient57.jar:/data/weblogic/mw/wlserver_10.3/server/lib/xqrl.jar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PATH=/data/weblogic/mw/wlserver_10.3/server/bin:/data/weblogic/mw/modules/org.apache.ant_1.7.0/bin:/data/weblogic/mw/jrockit_160_14_R27.6.5-32/jre/bin:/data/weblogic/mw/jrockit_160_14_R27.6.5-32/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;***************************************************&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;*  To start WebLogic Server, use a username and   *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;*  password assigned to an admin-level user.  For *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;*  server administration, use the WebLogic Server *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;*  console at http://hostname:port/console        *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;***************************************************&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;starting weblogic with Java version:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;java version "1.6.0_14"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Java(TM) SE Runtime Environment (build 1.6.0_14-b08)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;BEA JRockit(R) (build R27.6.5-32_o-121899-1.6.0_14-20091001-2113-linux-ia32, compiled mode)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Starting WLS with line:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/data/weblogic/mw/jrockit_160_14_R27.6.5-32/bin/java -jrockit   -Xms512m -Xmx512m -Dweblogic.Name=examplesServer -Djava.security.policy=/data/weblogic/mw/wlserver_10.3/server/lib/weblogic.policy  -Xverify:none  -da -Dplatform.home=/data/weblogic/mw/wlserver_10.3 -Dwls.home=/data/weblogic/mw/wlserver_10.3/server -Dweblogic.home=/data/weblogic/mw/wlserver_10.3/server   -Dweblogic.management.discover=true  -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/data/weblogic/mw/patch_wls1032/profiles/default/sysext_manifest_classpath:/data/weblogic/mw/patch_oepe1032/profiles/default/sysext_manifest_classpath  weblogic.Server&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:41:58 PM PST&gt; &amp;lt;Info&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000377&gt; &amp;lt;Starting WebLogic Server with BEA JRockit(R) Version R27.6.5-32_o-121899-1.6.0_14-20091001-2113-linux-ia32 from BEA Systems, Inc.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:41:59 PM PST&gt; &amp;lt;Info&gt; &amp;lt;Management&gt; &amp;lt;BEA-141107&gt; &amp;lt;Version: WebLogic Server 10.3.2.0  Tue Oct 20 12:16:15 PDT 2009 1267925 &gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:04 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to STARTING&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:04 PM PST&gt; &amp;lt;Info&gt; &amp;lt;WorkManager&gt; &amp;lt;BEA-002900&gt; &amp;lt;Initializing self-tuning thread pool&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:05 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Log Management&gt; &amp;lt;BEA-170019&gt; &amp;lt;The server log file /data/weblogic/mw/wlserver_10.3/samples/domains/wl_server/servers/examplesServer/logs/examplesServer.log is opened. All server side log events will be written to this file.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:13 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090082&gt; &amp;lt;Security initializing using security realm myrealm.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:27 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to STANDBY&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:27 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to STARTING&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:42:52 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Store&gt; &amp;lt;BEA-280067&gt; &amp;lt;JDBC store "exampleJDBCStore" did not find a database table at "examplesWLStore", so it created one using the commands in file "/weblogic/store/io/jdbc/ddl/pointbase.ddl".&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:43:25 PM PST&gt; &amp;lt;Warning&gt; &amp;lt;EJB&gt; &amp;lt;BEA-010202&gt; &amp;lt;Call-by-reference is not enabled for the EJB 'ReviewListenerBean'. The server will have better performance if it is enabled. To enable call-by-reference, set the enable-call-by-reference element to True in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:43:25 PM PST&gt; &amp;lt;Warning&gt; &amp;lt;EJB&gt; &amp;lt;BEA-010202&gt; &amp;lt;Call-by-reference is not enabled for the EJB 'ReviewManagerBean'. The server will have better performance if it is enabled. To enable call-by-reference, set the enable-call-by-reference element to True in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;129  reviewService  INFO   [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] openjpa.Runtime - Starting BEA Kodo 4.2.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;131  reviewService  INFO   [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.PointbaseDictionary".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;WARN: Creating new records from /META-INF/data.properties&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;After the server has booted, your browser should&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;automatically launch and point to the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Oracle WebLogic Server Samples Introduction Page&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;running on this server. If your browser fails to launch,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;point your browser to the following URL:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;"http://192.168.1.104:7001/examplesWebApp/index.jsp"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[LoginFilter]: LoginFilter constructed ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:38 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Log Management&gt; &amp;lt;BEA-170027&gt; &amp;lt;The Server has established connection with the Domain level Diagnostic Service successfully.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:41 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to ADMIN&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:41 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to RESUMING&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:44 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090171&gt; &amp;lt;Loading the identity certificate and private key stored under the alias DemoIdentity from the jks keystore file /data/weblogic/mw/wlserver_10.3/server/lib/DemoIdentity.jks.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:45 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090169&gt; &amp;lt;Loading trusted certificates from the jks keystore file /data/weblogic/mw/wlserver_10.3/server/lib/DemoTrust.jks.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:45 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090169&gt; &amp;lt;Loading trusted certificates from the jks keystore file /data/weblogic/mw/jrockit_160_14_R27.6.5-32/jre/lib/security/cacerts.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:46 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090898&gt; &amp;lt;Ignoring the trusted CA certificate "CN=KEYNECTIS ROOT CA,OU=ROOT,O=KEYNECTIS,C=FR". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:46 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090898&gt; &amp;lt;Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 3,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:46 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Security&gt; &amp;lt;BEA-090898&gt; &amp;lt;Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 2,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "DefaultSecure[3]" is now listening on 127.0.0.1:7002 for protocols iiops, t3s, ldaps, https.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "DefaultSecure[2]" is now listening on 0:0:0:0:0:0:0:1:7002 for protocols iiops, t3s, ldaps, https.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "Default[1]" is now listening on fe80:0:0:0:20c:29ff:fe07:b3ab:7001 for protocols iiop, t3, ldap, snmp, http.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "Default" is now listening on 192.168.1.104:7001 for protocols iiop, t3, ldap, snmp, http.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "Default[3]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1:7001 for protocols iiop, t3, ldap, snmp, http.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "DefaultSecure" is now listening on 192.168.1.104:7002 for protocols iiops, t3s, ldaps, https.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;Server&gt; &amp;lt;BEA-002613&gt; &amp;lt;Channel "DefaultSecure[1]" is now listening on fe80:0:0:0:20c:29ff:fe07:b3ab:7002 for protocols iiops, t3s, ldaps, https.&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:48 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000331&gt; &amp;lt;Started WebLogic Admin Server "examplesServer" for domain "wl_server" running in Development Mode&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Exception in thread "Thread-14" java.lang.InternalError: Can't connect to X11 window server using '192.168.1.71:0.0' as the value of the DISPLAY variable.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at sun.awt.X11GraphicsEnvironment.&amp;lt;clinit&gt;(X11GraphicsEnvironment.java:131)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.lang.Class.forName0(Native Method)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.lang.Class.forName(Class.java:169)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at sun.awt.X11.XToolkit.&amp;lt;clinit&gt;(XToolkit.java:89)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.lang.Class.forName0(Native Method)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.lang.Class.forName(Class.java:169)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.awt.Toolkit$2.run(Toolkit.java:834)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.awt.Desktop.isDesktopSupported(Desktop.java:151)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.awt.Desktop.getDesktop(Desktop.java:125)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at examples.webapp.lifecycle.OpenBrowserServletContextListener.openBrowser(Unknown Source)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at examples.webapp.lifecycle.OpenBrowserServletContextListener.run(Unknown Source)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        at java.lang.Thread.run(Thread.java:619)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:55 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000365&gt; &amp;lt;Server state changed to RUNNING&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;Dec 1, 2009 7:46:55 PM PST&gt; &amp;lt;Notice&gt; &amp;lt;WebLogicServer&gt; &amp;lt;BEA-000360&gt; &amp;lt;Server started in RUNNING mode&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Terms:&lt;br /&gt;&lt;br /&gt;Web Application Container normally in a WAR file - contains an application's resources such as:&lt;br /&gt;a. servlets (java class)&lt;br /&gt;b. JavaServer Pages (JSPs)&lt;br /&gt;c. JSP tag libraries&lt;br /&gt;d. any static resources such as html pages, image files etc.&lt;br /&gt;&lt;br /&gt;Servlets - java class, HTTP Servlet - html inside Java&lt;br /&gt;JSP - JavaServer Pages - java inside html&lt;br /&gt;Weblogic provides J2EE (Java Enterprise Environment) environment and services/APIs to web application containers, this services include EJBs,&lt;br /&gt;database connections (JDBC), Java Messaging Sevice (JMS), XML and more.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0O9u1bfZ9I/AAAAAAAAClQ/tdlUkg51qpk/s1600-h/http-servlet.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 226px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0O9u1bfZ9I/AAAAAAAAClQ/tdlUkg51qpk/s400/http-servlet.jpg" alt="" id="BLOGGER_PHOTO_ID_5423386988598224850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Servlets&lt;br /&gt;A servlet is a Java class that runs in a Java-enabled server. An HTTP servlet is a special type of servlet that handles an HTTP request and provides an HTTP response, usually in the form of an HTML page. The most common use of WebLogic HTTP Servlets is to create interactive applications using standard Web browsers for the client-side presentation while WebLogic Server handles the business logic as a server-side process. WebLogic HTTP servlets can access databases, Enterprise JavaBeans, messaging APIs, HTTP sessions, and other facilities of WebLogic Server.&lt;br /&gt;&lt;br /&gt;WAR files&lt;br /&gt;Web Archive Files - A WAR file contains&lt;br /&gt;a. one servlet/one JSP along with helper classes,&lt;br /&gt;b. a weblogic.xml deployment descriptor, an XML document containing Weblogic Server specific elements for web applcations&lt;br /&gt;c. optional web.xml deployment descriptor, XML file describes the contents of the war file&lt;br /&gt;d. any static html pages/image files&lt;br /&gt;&lt;br /&gt;The WAR file can be deployed alone or packaged in an Enterprise application archive (EAR file) with other application components. If deployed alone,&lt;br /&gt;the archive must end with a .war extension. If deployed in an EAR file, the archive must end with an .ear extension.&lt;br /&gt;&lt;br /&gt;Oracle recommends that you package and deploy your stand-alone Web applications as part of an Enterprise application. This is an Oracle best practice,&lt;br /&gt;which allows for easier application migration, additions, and changes. Also, packaging your applications as part of an Enterprise application allows&lt;br /&gt;you to take advantage of the split development directory structure, which provides a number of benefits over the traditional single directory structure.&lt;br /&gt;&lt;br /&gt;EAR file (Enterprise Application Archive)  .ear file, the .WAR file can be deployed alone or packaged in an EAR file.&lt;br /&gt;JSPs and HTTP servlets can access all services and APIs available in WebLogic Server. These services include EJBs, database connections by way of&lt;br /&gt;Java Database Connectivity (JDBC), Java Messaging Service (JMS), XML, and more.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-9184424469965717804?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/9184424469965717804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/9184424469965717804'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/weblogic-setup-quick-guide.html' title='Weblogic Setup Quick Guide'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_if8QouXbicI/S0O9u1bfZ9I/AAAAAAAAClQ/tdlUkg51qpk/s72-c/http-servlet.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-1194815376636592260</id><published>2010-01-05T14:15:00.000-08:00</published><updated>2010-02-10T17:11:23.233-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Admin - Apache Tomcat Weblogic Java'/><title type='text'>Installing mod_jk in 1 Minute!</title><content type='html'>Apache mod_jk Installation Quick Guide&lt;br /&gt;&lt;br /&gt;mod_jk is AJP connector connecting Apache with tomcat. It enables users access tomcat/JSP thru Apache.&lt;br /&gt;&lt;br /&gt;Key Components&lt;br /&gt;1. httpd.conf  LoadModule&lt;br /&gt;2. workers.properties&lt;br /&gt;3. modules/mod_jk.so&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Two ways of installing modules in apache, Static or DSO (Dynamic Shared Object):&lt;br /&gt;&lt;br /&gt;Static - compiled with apache   ./configure --with-mod_jk&lt;br /&gt;DSO - must have mod_so compiled with apache, use apxs (apache extensons) to add.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"httpd -l" to see static modules compiled with apache, mod_so.c must be on the list to use DSO.&lt;br /&gt;&lt;br /&gt;"httpd -M" to see list of all modules both static and dynamic&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-bash-3.00$ /usr/local/apache2/bin/httpd -M&lt;br /&gt;Loaded Modules:&lt;br /&gt;core_module (static)&lt;br /&gt;authn_file_module (static)&lt;br /&gt;authn_default_module (static)&lt;br /&gt;authz_host_module (static)&lt;br /&gt;authz_groupfile_module (static)&lt;br /&gt;authz_user_module (static)&lt;br /&gt;authz_default_module (static)&lt;br /&gt;auth_basic_module (static)&lt;br /&gt;auth_digest_module (static)&lt;br /&gt;include_module (static)&lt;br /&gt;filter_module (static)&lt;br /&gt;deflate_module (static)&lt;br /&gt;log_config_module (static)&lt;br /&gt;env_module (static)&lt;br /&gt;headers_module (static)&lt;br /&gt;setenvif_module (static)&lt;br /&gt;version_module (static)&lt;br /&gt;ssl_module (static)&lt;br /&gt;mpm_prefork_module (static)&lt;br /&gt;http_module (static)&lt;br /&gt;mime_module (static)&lt;br /&gt;status_module (static)&lt;br /&gt;autoindex_module (static)&lt;br /&gt;asis_module (static)&lt;br /&gt;cgi_module (static)&lt;br /&gt;negotiation_module (static)&lt;br /&gt;dir_module (static)&lt;br /&gt;actions_module (static)&lt;br /&gt;userdir_module (static)&lt;br /&gt;alias_module (static)&lt;br /&gt;rewrite_module (static)&lt;br /&gt;so_module (static)&lt;br /&gt;jk_module (shared)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To install via DSO:&lt;br /&gt;&lt;br /&gt;Building mod_ jk on Linux/*nix&lt;br /&gt;&lt;br /&gt;You need to make sure you have the required gcc compiler and libc versions on your Linux system to&lt;br /&gt;compile the Apache Web server and mod_jk . The specific version required is dependent on the Apache&lt;br /&gt;Web server that you will be using. In addition, the script used by mod_jk installation requires installation&lt;br /&gt;of libtool 1.5.2 or higher, and at least autoconf 2.59 .&lt;br /&gt;&lt;br /&gt;1. Download the source of the Apache Web server, corresponding to the version of the server you&lt;br /&gt;are using, from http://httpd.apache.org/download.cgi .&lt;br /&gt;&lt;br /&gt;2. Unpack the distribution into any convenient directory, such as /home/dev/httpd-2.2.3 .&lt;br /&gt;&lt;br /&gt;3. Download the latest Connector source from http://tomcat.apache.org/downloadconnectors.cgi&lt;br /&gt;&lt;br /&gt;4. Unpack it to a convenient directory, such as /home/dev/tomcat-connects-1.2.19-src .&lt;br /&gt;&lt;br /&gt;5. Compile and install the Apache server. You should follow the detailed instructions in the install&lt;br /&gt;file of your Apache server source directory. With the 2.2.3 server, you need to issue the command&lt;br /&gt;./configure --prefix=/installdir where you can specify the location ( installdir ) where&lt;br /&gt;you want the server to be installed. After configuration finishes, type the make command to compile&lt;br /&gt;the source. Finally, type the make install command to install the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. This step compiles the mod_jk module as a dynamically loadable module. Change into the&lt;br /&gt;native subdirectory. Then enter the command ./configure --with-apxs=/installdir/bin/apxs .&lt;br /&gt;The installdir must be the same as the installation directory of your Web server in step 5;&lt;br /&gt;be aware that this is not the same as the source code directory for the Web server. This creates&lt;br /&gt;a makefile. You can then type make to compile the mod_jk module. You can then find the&lt;br /&gt;mod_jk.so module in the apache-2.0 subdirectory.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Basic Terms:&lt;br /&gt;&lt;br /&gt;Servlets&lt;br /&gt;&lt;br /&gt;A servlet is a Java class that runs in a Java-enabled server. An HTTP servlet is a special type of servlet that handles an HTTP request and provides an HTTP response, usually in the form of an HTML page. The most common use of WebLogic HTTP Servlets is to create interactive applications using standard Web browsers for the client-side presentation while WebLogic Server handles the business logic as a server-side process. WebLogic HTTP servlets can access databases, Enterprise JavaBeans, messaging APIs, HTTP sessions, and other facilities of WebLogic Server.&lt;br /&gt;&lt;br /&gt;Servlets and Java EE&lt;br /&gt;&lt;br /&gt;WebLogic Server fully supports HTTP servlets as defined in the Servlet 2.5 specification from Sun Microsystems.&lt;br /&gt;&lt;br /&gt;The Servlet 2.5 specification defines the implementation of the servlet API and the method by which servlets are deployed in enterprise applications. Deploying servlets on a Java EE-compliant server, such as WebLogic Server, is accomplished by packaging the servlets and other resources that make up an enterprise application into a single unit, the Web application. A Web application utilizes a specific directory structure to contain its resources and a deployment descriptor that defines how these resources interact and how the application is accessed by a client. See The Web Applications Container.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What You Can Do with Servlets&lt;br /&gt;&lt;br /&gt;* Create dynamic Web pages that use HTML forms to get end-user input and provide HTML pages that respond to that input. Examples of this utilization include online shopping carts, financial services, and personalized content.&lt;br /&gt;&lt;br /&gt;* Create collaborative systems such as online conferencing.&lt;br /&gt;&lt;br /&gt;* Easily deploy servlets written for any Java EE-compliant servlet engine to WebLogic Server.&lt;br /&gt;&lt;br /&gt;* Have access to a variety of APIs and features by using servlets running in WebLogic Server. For example:&lt;br /&gt;1) Session tracking—Allows a Web site to track a user’s progress across multiple Web pages. This functionality supports Web sites such as e-commerce sites that use shopping carts. WebLogic Server supports session persistence to a database, providing fail-over between server down time and session sharing between clustered servers. For more information see Session Tracking from a Servlet.&lt;br /&gt;      2) JDBC drivers (including Oracle)—JDBC drivers provide basic database access. With WebLogic Server’s multi-tier JDBC implementations, you can take advantage of connection pools, server-side data caching, and transactions. For more information see Accessing Databases.&lt;br /&gt;      3) Enterprise JavaBeans—Servlets can use Enterprise JavaBeans (EJB) to encapsulate sessions, data from databases, and other functionality. See Referencing External EJBs, More about the ejb-ref* Elements, and Referencing Application-Scoped EJBs.&lt;br /&gt;      4) Java Messaging Service (JMS)—JMS allows your servlets to exchange messages with other servlets and Java programs. See Programming WebLogic JMS.&lt;br /&gt;      5) Java JDK APIs—Servlets can use the standard Java JDK APIs.&lt;br /&gt;      6) Forwarding requests—Servlets can forward a request to another servlet or other resource. Forwarding a Request.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;WAR files&lt;br /&gt;Web Application Development Key Points&lt;br /&gt;&lt;br /&gt;JSPs and HTTP servlets can access all services and APIs available in WebLogic Server. These services include EJBs, database connections by way of&lt;br /&gt;Java Database Connectivity (JDBC), Java Messaging Service (JMS), XML, and more.&lt;br /&gt;&lt;br /&gt;A Web archive (WAR file) contains:&lt;br /&gt;&lt;br /&gt;* One servlet or Java Server Page (JSP), along with any helper classes.&lt;br /&gt;* A weblogic.xml deployment descriptor, which is an XML document containing WebLogic Server-specific elements for Web applications.&lt;br /&gt;* An optional web.xml deployment descriptor, which is a Java EE standard XML document that describes the contents of a WAR file.&lt;br /&gt;* A WAR file can also include HTML or XML pages and supporting files such as image and multimedia files.&lt;br /&gt;&lt;br /&gt;The WAR file can be deployed alone or packaged in an Enterprise application archive (EAR file) with other application components. If deployed alone, the&lt;br /&gt;archive must end with a .war extension. If deployed in an EAR file, the archive must end with an .ear extension.&lt;br /&gt;&lt;br /&gt;Oracle recommends that you package and deploy your stand-alone Web applications as part of an Enterprise application. This is an Oracle best practice,&lt;br /&gt;which allows for easier application migration, additions, and changes. Also, packaging your applications as part of an Enterprise application allows&lt;br /&gt;you to take advantage of the split development directory structure, which provides a number of benefits over the traditional single directory structure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-1194815376636592260?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1194815376636592260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1194815376636592260'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/installing-modjk-in-1-minute.html' title='Installing mod_jk in 1 Minute!'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-2971100427165705938</id><published>2010-01-05T14:01:00.000-08:00</published><updated>2010-11-01T09:02:11.914-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Admin - Apache Tomcat Weblogic Java'/><title type='text'>Generate SSL Certificate for Apache Web Server</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/S0O28DzETfI/AAAAAAAAClI/jOhg6YMnoPo/s1600-h/open-ssl-certificate.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/S0O28DzETfI/AAAAAAAAClI/jOhg6YMnoPo/s400/open-ssl-certificate.jpg" alt="" id="BLOGGER_PHOTO_ID_5423379519212113394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;(A self-signed certificate in my testing web server)&lt;br /&gt;&lt;br /&gt;1. Create a directory, for example, under apache2/conf/&lt;br /&gt;# mkdir certworks&lt;br /&gt;# cd certworks&lt;br /&gt;&lt;br /&gt;2. Create a configuration file for generating a certificate&lt;br /&gt;# cat myconfig.file&lt;br /&gt;RANDFILE        =./random.txt&lt;br /&gt;[req]&lt;br /&gt;default_bits    = 1024&lt;br /&gt;default_keyfile = keyfile.pem&lt;br /&gt;attributes      = req_attributes&lt;br /&gt;distinguished_name = ShanJing&lt;br /&gt;prompt          = no&lt;br /&gt;output_password = mypassword&lt;br /&gt;[ShanJing]&lt;br /&gt;C               = US&lt;br /&gt;ST              = CA&lt;br /&gt;L               = Arcadia&lt;br /&gt;O               = ShanJing&lt;br /&gt;OU              = Shan's IT&lt;br /&gt;CN              = 192.168.1.104&lt;br /&gt;emailAddress    = mail@shanjing.com&lt;br /&gt;[req_attributes]&lt;br /&gt;challengePassword = mypassword&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Create a private key and a Certificate Signing Request&lt;br /&gt;# openssl req -new -out server.csr -config myconfig.file&lt;br /&gt;&lt;br /&gt;Generating a 1024 bit RSA private key&lt;br /&gt;.......++++++&lt;br /&gt;...........++++++&lt;br /&gt;writing new private key to 'keyfile.pem'&lt;br /&gt;-----&lt;br /&gt;&lt;br /&gt;# ls -al&lt;br /&gt;total 48&lt;br /&gt;drwxr-xr-x  2 root root 4096 Dec  5 11:35 .&lt;br /&gt;drwxr-xr-x  5 root root 4096 Dec  5 11:29 ..&lt;br /&gt;-rw-r--r--  1 root root  963 Dec  5 11:35 keyfile.pem&lt;br /&gt;-rw-r--r--  1 root root  351 Dec  5 11:33 myconfig.file&lt;br /&gt;-rw-------  1 root root 1024 Dec  5 11:35 random.txt&lt;br /&gt;-rw-r--r--  1 root root  737 Dec  5 11:35 server.csr&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Remove the Passphrase from the private key so that when apache starts, it won't ask for key's Passphrase&lt;br /&gt;# openssl rsa -in keyfile.pem -out server.key&lt;br /&gt;Enter pass phrase for keyfile.pem:&lt;br /&gt;writing RSA key&lt;br /&gt;&lt;br /&gt;5. For test, we just generate a self-signed certificate.&lt;br /&gt;# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365&lt;br /&gt;&lt;br /&gt;Signature ok&lt;br /&gt;subject=/C=US/ST=CA/L=Arcadia/O=ShanJing/OU=Shans IT/CN=192.168.1.104/emailAddress=mail@shanjing.com&lt;br /&gt;Getting Private key&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. Setup mod-ssl in Apache:&lt;br /&gt;&lt;br /&gt;Modify the following in conf/extra/httpd-ssl.conf file:&lt;br /&gt;&lt;br /&gt;SSLCertificateFile "/usr/local/apache2/conf/certworks/server.crt"&lt;br /&gt;&lt;br /&gt;SSLCertificateKeyFile "/usr/local/apache2/conf/certworks/server.key"&lt;br /&gt;&lt;br /&gt;Modify httpd.conf and enable/uncomment&lt;br /&gt;&lt;br /&gt;Include conf/extra/httpd-ssl.conf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(Note, if mod_ssl is compiled with apache as built-in module, you don't need to put the following line in httpd.conf file:&lt;br /&gt;LoadModule ssl-module modules/mod_ssl.so&lt;br /&gt;&lt;br /&gt;To find out if mod_ssl is compiled with apache,&lt;br /&gt;&lt;br /&gt;# /usr/local/apache2/bin/apachectl -l | grep mod_ssl&lt;br /&gt;mod_ssl.c&lt;br /&gt;&lt;br /&gt;To see currently loaded modules:&lt;br /&gt;[root@ipc4 extra]# /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES&lt;br /&gt;Loaded Modules:&lt;br /&gt;core_module (static)&lt;br /&gt;authn_file_module (static)&lt;br /&gt;authn_default_module (static)&lt;br /&gt;authz_host_module (static)&lt;br /&gt;authz_groupfile_module (static)&lt;br /&gt;authz_user_module (static)&lt;br /&gt;authz_default_module (static)&lt;br /&gt;auth_basic_module (static)&lt;br /&gt;auth_digest_module (static)&lt;br /&gt;include_module (static)&lt;br /&gt;filter_module (static)&lt;br /&gt;deflate_module (static)&lt;br /&gt;log_config_module (static)&lt;br /&gt;env_module (static)&lt;br /&gt;headers_module (static)&lt;br /&gt;setenvif_module (static)&lt;br /&gt;version_module (static)&lt;br /&gt;ssl_module (static)&lt;br /&gt;mpm_prefork_module (static)&lt;br /&gt;http_module (static)&lt;br /&gt;mime_module (static)&lt;br /&gt;status_module (static)&lt;br /&gt;autoindex_module (static)&lt;br /&gt;asis_module (static)&lt;br /&gt;cgi_module (static)&lt;br /&gt;negotiation_module (static)&lt;br /&gt;dir_module (static)&lt;br /&gt;actions_module (static)&lt;br /&gt;userdir_module (static)&lt;br /&gt;alias_module (static)&lt;br /&gt;rewrite_module (static)&lt;br /&gt;so_module (static)&lt;br /&gt;jk_module (shared)&lt;br /&gt;Syntax OK&lt;br /&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Reference: &lt;a href="http://www.verisign.com/ssl/ssl-information-center/how-ssl-security-works/index.html"&gt;How SSL security works?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-2971100427165705938?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/2971100427165705938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/2971100427165705938'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/generate-ssl-certificate-for-apache-web.html' title='Generate SSL Certificate for Apache Web Server'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_if8QouXbicI/S0O28DzETfI/AAAAAAAAClI/jOhg6YMnoPo/s72-c/open-ssl-certificate.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3406653071281602891</id><published>2010-01-05T13:58:00.000-08:00</published><updated>2010-02-10T17:10:19.619-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix Power Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Understands Openssl and Public Key Crytopgraphy in 1 Minute!</title><content type='html'>##########&lt;br /&gt;Public Key Crytopgraphy&lt;br /&gt;##########&lt;br /&gt;&lt;br /&gt;1. Diffie-Hellman (DH)&lt;br /&gt;2. Digital Signature Algorithm (DSA)&lt;br /&gt;3. RSA (Riverst,Shamir,Adleman)&lt;br /&gt;4. S/MIME&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Diffie-Hellman&lt;br /&gt;#openssl dhparam -out dhparam.pem -2 1024&lt;br /&gt;#openssl dhparam -in dhparam.pem -noout -C&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. DSA&lt;br /&gt;#openssl dsaparam -out dsaparam.pem 1024&lt;br /&gt;#openssl gendsa -out dsaprivatekey.pem -des3 desparam.pem&lt;br /&gt;#openssl dsa -in dsaprivatekey.pem -pbout -out dsapublickey.pem&lt;br /&gt;#openssl dsa -in dsaprivatekey.pem -out dsaprivatekey.pem -des3 \&lt;br /&gt;-passin pass:oldpasswd -passout pass:newpasswd&lt;br /&gt;&lt;br /&gt;3. RSA&lt;br /&gt;#openssl genrsa -out rsaprivatekey.pem -passout pass:open123 -des3 1024&lt;br /&gt;#openssl rsa -in rsaprivatekey.pem -passin pass:open123 -pubout \&lt;br /&gt;-out rsapublickey.pem&lt;br /&gt;#openssl rsautl -encrypt -pubin -inkey rsapublickey.pem -in plaintxt \&lt;br /&gt;-out cipher.txt&lt;br /&gt;#openssl reautl -decrypt -inkey rsaprivatkey.pem -in cipher.txt -out plaintxt&lt;br /&gt;#openssl rsautl -sign -inkey rsaprivatekey.pem -in plain.txt \&lt;br /&gt;-out signature.bin&lt;br /&gt;#openssl rsautl -verify -publin -inkey rsapublickey.pem -in \&lt;br /&gt;signature.bin -out plain.txt&lt;br /&gt;&lt;br /&gt;4. S/MIME&lt;br /&gt;#openssl smine -encrypt -in mail.txt -des3 -out mail.enccert.pem&lt;br /&gt;#openssl smine -decrypt -in mail.enc -recip cert.pem -inkey key.pem \&lt;br /&gt;-out mail.sgn&lt;br /&gt;#openssl smine -sign -in mail.txt -signer cert.pem -inkey key.pem \&lt;br /&gt;-out mail.sgn&lt;br /&gt;#openssl smine -verify -in mail.sgn -out mail.txt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#openssl dhparam -out dhparam.pem -2 1024&lt;br /&gt;[shan@ipc4 openssl]$ more dhparam.pem&lt;br /&gt;-----BEGIN DH PARAMETERS-----&lt;br /&gt;MIGHAoGBAM34BWAn2CV8+utL5S9EOew5RYScXu5FjvyisMs/Eyn698FKgu20tonA&lt;br /&gt;O9q9462n3lT6bzsMIOkfn2VnKWO8oqk9gOAkTICgVATiS59NFvN21t8okNHXR4TJ&lt;br /&gt;2rWmhBRcBhZQgGZw0jPlHDE6FEfjqrAoHuu5SvJXZu4L6KV1n7H7AgEC&lt;br /&gt;-----END DH PARAMETERS-----&lt;br /&gt;&lt;br /&gt;Reads a set of Diffie-Hellman paramenters from the file dhparam.pem and writes&lt;br /&gt;a C code respresentation of the parameters to stout.&lt;br /&gt;&lt;br /&gt;[shan@ipc4 openssl]$ openssl dhparam -in dhparam.pem -noout -C&lt;br /&gt;#ifndef HEADER_DH_H&lt;br /&gt;#include &lt;openssl h=""&gt;&lt;br /&gt;#endif&lt;br /&gt;DH *get_dh1024()&lt;br /&gt;       {&lt;br /&gt;       static unsigned char dh1024_p[]={&lt;br /&gt;               0xCD,0xF8,0x05,0x60,0x27,0xD8,0x25,0x7C,0xFA,0xEB,0x4B,0xE5,&lt;br /&gt;               0x2F,0x44,0x39,0xEC,0x39,0x45,0x84,0x9C,0x5E,0xEE,0x45,0x8E,&lt;br /&gt;               0xFC,0xA2,0xB0,0xCB,0x3F,0x13,0x29,0xFA,0xF7,0xC1,0x4A,0x82,&lt;br /&gt;               0xED,0xB4,0xB6,0x89,0xC0,0x3B,0xDA,0xBD,0xE3,0xAD,0xA7,0xDE,&lt;br /&gt;               0x54,0xFA,0x6F,0x3B,0x0C,0x20,0xE9,0x1F,0x9F,0x65,0x67,0x29,&lt;br /&gt;               0x63,0xBC,0xA2,0xA9,0x3D,0x80,0xE0,0x24,0x4C,0x80,0xA0,0x54,&lt;br /&gt;               0x04,0xE2,0x4B,0x9F,0x4D,0x16,0xF3,0x76,0xD6,0xDF,0x28,0x90,&lt;br /&gt;               0xD1,0xD7,0x47,0x84,0xC9,0xDA,0xB5,0xA6,0x84,0x14,0x5C,0x06,&lt;br /&gt;               0x16,0x50,0x80,0x66,0x70,0xD2,0x33,0xE5,0x1C,0x31,0x3A,0x14,&lt;br /&gt;               0x47,0xE3,0xAA,0xB0,0x28,0x1E,0xEB,0xB9,0x4A,0xF2,0x57,0x66,&lt;br /&gt;               0xEE,0x0B,0xE8,0xA5,0x75,0x9F,0xB1,0xFB,&lt;br /&gt;               };&lt;br /&gt;       static unsigned char dh1024_g[]={&lt;br /&gt;               0x02,&lt;br /&gt;               };&lt;br /&gt;       DH *dh;&lt;br /&gt;&lt;br /&gt;       if ((dh=DH_new()) == NULL) return(NULL);&lt;br /&gt;       dh-&gt;p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL);&lt;br /&gt;       dh-&gt;g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL);&lt;br /&gt;       if ((dh-&gt;p == NULL) || (dh-&gt;g == NULL))&lt;br /&gt;               { DH_free(dh); return(NULL); }&lt;br /&gt;       return(dh);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;DSA&lt;br /&gt;[shan@ipc4 openssl]$ openssl dsaparam -out dsaparam.pem 1024&lt;br /&gt;Generating DSA parameters, 1024 bit long prime&lt;br /&gt;This could take some time&lt;br /&gt;....+.......+++++++++++++++++++++++++++++++++++++++++++++++++++*&lt;br /&gt;.+...+..+....+.+.................................+......+.......+.....+.....+...&lt;br /&gt;...+.+..................+..............................+....++++++++++++++++++++&lt;br /&gt;+++++++++++++++++++++++++++++++*&lt;br /&gt;[shan@ipc4 openssl]$ openssl gendsa -out dsaprivatekey.pem -des3 dsaparam.pem&lt;br /&gt;Generating DSA key, 1024 bits&lt;br /&gt;Enter PEM pass phrase:&lt;br /&gt;Verifying - Enter PEM pass phrase:&lt;br /&gt;[shan@ipc4 openssl]$&lt;br /&gt;[shan@ipc4 openssl]$ openssl dsa -in dsaprivatekey.pem -pubout -out&lt;br /&gt;dsapublickey.pem&lt;br /&gt;read DSA key&lt;br /&gt;Enter PEM pass phrase:&lt;br /&gt;writing DSA key&lt;br /&gt;[shan@ipc4 openssl]$ ls&lt;br /&gt;dhparam.pem  dsaparam.pem  dsaprivatekey.pem  dsapublickey.pem  openssl.txt&lt;br /&gt;[shan@ipc4 openssl]$ cat dsa*pem&lt;br /&gt;-----BEGIN DSA PARAMETERS-----&lt;br /&gt;MIIBHgKBgQC5Xhv0mFXaAYPwHVU/NKuYwkwd13cYttAoKlqoong7AB9wyCY1f4v5&lt;br /&gt;g7OFoiKSZwZbnZdF6E5yId5VF8VR6usU0jNkef96X9tnwHM4SBjd7sZJsrgB4VFb&lt;br /&gt;cK+BinOhRiplnA2j3iPwK0+UpS9lqwflVPBtZp77qdhr+sCqH40OHQIVAIHQo2SJ&lt;br /&gt;3cyL99bjvxgHuV4yYNJdAoGAYi3X8zyjO5kb23TZEO365NLNd76gxgPjftwCleHk&lt;br /&gt;VileZ5oRr7Ysfd13icvrAHp/STyszTUezWhDSoi5c/sZqK5CkYTyWGxBA2Q4pJzr&lt;br /&gt;o96NAuDx+HY/mzDPiYxW8+vgcFKjK8ZtRPVdYm7/pzOPAsK7uTYl7dsvczAzq4sy&lt;br /&gt;xOQ=&lt;br /&gt;-----END DSA PARAMETERS-----&lt;br /&gt;-----BEGIN DSA PRIVATE KEY-----&lt;br /&gt;Proc-Type: 4,ENCRYPTED&lt;br /&gt;DEK-Info: DES-EDE3-CBC,90B967D1B13289CA&lt;br /&gt;&lt;br /&gt;jVh7gsM6R6HRSu8yRKP10UOQ5fJGBZTFMc1BbVZqAcT8GRYBuMhJ3MsL35g2chuT&lt;br /&gt;+W3n0KxhGmU9RH+hSMyrPrVWy82FAXdWUjipDyCm/3nfrrvTunE2RCy242axBH9n&lt;br /&gt;JqxFRLDnTgfcgMw3fxK9QGfbKn2+IxG4kQmxJaWbzH9ooCJPuNIllztyRHCGNNyr&lt;br /&gt;9ognjrdFiVh506Yz7xOjPtvnzMry0rZ6B97LjqH0MixMS4HFGUgBeuv06fulBgte&lt;br /&gt;GDIdSYqqYmfhweOFEVpW4WJqV7heJVDDSkjYcVFv0ITfUa3LIZl8HUIf06sog91m&lt;br /&gt;ENWqKfoky5fFRVN3urmcGmOgXs3UdAiIdHop6tWXFskTQ8+FlI5BSDLM8wwqNsAN&lt;br /&gt;hVENfZeSqHL5Qbiq0J1TyjTHO4NcOrrub57wm3tfIXofEIdWbR0Qp+hoGUOZZZ0g&lt;br /&gt;2ODcE6Y/oSTOhTNYVPBSL9MKZO8NmO2kjgllEJdMiJRFr1eGvlMBq3OP+9E+Oadk&lt;br /&gt;tnqjW7ITfjSByGe7V33JR6iuogBCGBFsNB9DhGGshw7KJjy4Swlf119Ba9W1v6Wl&lt;br /&gt;YhwpIyw1YHhY6IVjqtoFmQ==&lt;br /&gt;-----END DSA PRIVATE KEY-----&lt;br /&gt;-----BEGIN PUBLIC KEY-----&lt;br /&gt;MIIBtzCCASsGByqGSM44BAEwggEeAoGBALleG/SYVdoBg/AdVT80q5jCTB3Xdxi2&lt;br /&gt;0CgqWqiieDsAH3DIJjV/i/mDs4WiIpJnBludl0XoTnIh3lUXxVHq6xTSM2R5/3pf&lt;br /&gt;22fAczhIGN3uxkmyuAHhUVtwr4GKc6FGKmWcDaPeI/ArT5SlL2WrB+VU8G1mnvup&lt;br /&gt;2Gv6wKofjQ4dAhUAgdCjZIndzIv31uO/GAe5XjJg0l0CgYBiLdfzPKM7mRvbdNkQ&lt;br /&gt;7frk0s13vqDGA+N+3AKV4eRWKV5nmhGvtix93XeJy+sAen9JPKzNNR7NaENKiLlz&lt;br /&gt;+xmorkKRhPJYbEEDZDiknOuj3o0C4PH4dj+bMM+JjFbz6+BwUqMrxm1E9V1ibv+n&lt;br /&gt;M48Cwru5NiXt2y9zMDOrizLE5AOBhQACgYEAhSOzZHU0XD3InVY1GzMsrmCcR0SC&lt;br /&gt;PYFRtdchZqXpT/D30aul/9k4I57g6Bo4wo0pDcaNcZmaqQCzW8x5jvIeQ3jtXBsb&lt;br /&gt;Dl8oLkl+XubhitHsZSJLblf8/g/+bB19iTOj1EMf3g449o/gn+p52HNhc8NszaxQ&lt;br /&gt;yOkeP1KaA7kKDkU=&lt;br /&gt;-----END PUBLIC KEY-----&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[:wopenssl dsa -in dsaprivatekey.com -out dsaprivatekey.pem -des3&lt;br /&gt;-passin pass:letmein -passout pass:letmein01&lt;br /&gt;726      openssl dsa -in dsaprivatekey.pem -out dsaprivatekey.pem -des3&lt;br /&gt;-passin pass:letmein -passout pass:letmein01&lt;br /&gt;727      ls&lt;br /&gt;728      openssl genrsa -out rsaprivatekey.pem -passout pass:letmein -des3&lt;br /&gt;1024&lt;br /&gt;729      openssl rsa -in rsaprivatekey.pem -passin pass:letmein -pubout -out&lt;br /&gt;rsapublickey.pem&lt;br /&gt;730      openssl rsautl -encrypt -pubin -inkey rsapublickey.pem -in&lt;br /&gt;openssl.txt -out openssl.txt.cip&lt;/openssl&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3406653071281602891?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3406653071281602891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3406653071281602891'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/understands-openssl-and-public-key.html' title='Understands Openssl and Public Key Crytopgraphy in 1 Minute!'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-455334419207308834</id><published>2010-01-05T13:45:00.000-08:00</published><updated>2010-02-10T17:12:34.371-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix Power Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Understand ssh agent forwarding in 1 minute!</title><content type='html'>ssh agent forwarding&lt;br /&gt;&lt;br /&gt;Key Concepts:&lt;br /&gt;1. understand what is a key challenge&lt;br /&gt;2. agent constructs response to remote server's key challenge without revealing the private key;&lt;br /&gt;3. the "middleman" server's sshd daemon acts as agent and relays ssh authentication traffic between the client and destination hosts;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The difference between basic ssh connection and agent based ssh connection:&lt;br /&gt;&lt;br /&gt;The very basic ssh connection is ssh client (instead of agent) uses private key to construct response for remote server's key challenge.&lt;br /&gt;&lt;br /&gt;ssh agent forwarding means agent can verify a user's identity without revealing the private key to the remote host.&lt;br /&gt;With agent, the ssh client passes the remote key challenge to the agent. The agent uses the private key to construct&lt;br /&gt;a response key-challenge and sends it back to ssh process which sends it off to the remote sshd.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;(assume ssh port 22 or whatever is opened on all servers)&lt;br /&gt;&lt;br /&gt;A user shan on ipc4 has established ssh connection with server1 via agent.&lt;br /&gt;&lt;br /&gt;with agent-forwarding, user shan@ipc4 has established ssh access to server1 with agent, now shan@ipc4 needs to access server2 which has his account's public key.&lt;br /&gt;&lt;br /&gt;shan@ipc4 issues ssh connection request via agent-forwarding to server2 thru server1; the ssh client on server1 receives the key challenge from server2, it forwards that challenge to the&lt;br /&gt;sshd daemon on the same machine acting as a key agent, server1's sshd relays the key challenge to the ipc4's ssh client&lt;br /&gt;who sends the challenge to the agent on ipc4.  ipc4's agent contructs the key response using the private key and sends back to&lt;br /&gt;server1's sshd which acts as agent then sends back to server2.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What's key challenge&lt;br /&gt;&lt;br /&gt;server:&lt;br /&gt;encrypt (random number + public key) =&gt; key challenge  --------&gt;     client&lt;br /&gt;&lt;br /&gt;client:&lt;br /&gt;decrypt (key challenge + private key) = challenge.txt, key response = MD5 hash ( challenge txt + session ID )  ----- server&lt;br /&gt;&lt;br /&gt;server encrypts a large random number with the user's public key to create a key challenge then sends back to client.&lt;br /&gt;the client must use user's private key to decrypt the key challenge.&lt;br /&gt;&lt;br /&gt;Key response&lt;br /&gt;When the agent receives the challenge, it decrypts it with the private key. If this key is the "other half" of the public key&lt;br /&gt;on the server, the decryption will be successful, revealing the original random number generated by the server. Only the holder&lt;br /&gt;of the private key could ever extract this random number, so this constitutes proof that the user is the holder of the private key.&lt;br /&gt;&lt;br /&gt;The agent takes this random number, appends the SSH session ID (which varies from connection to connection), and creates an MD5&lt;br /&gt;hash value of the resultant string: this result is sent back to the server as the key response.&lt;br /&gt;&lt;br /&gt;The server computes the same MD5 hash (random number + session ID) and compares it with the key response from the agent: if they&lt;br /&gt;match, the user must have been in possession of the private key, and access is granted. If not, the next key in the list (of any)&lt;br /&gt;is tried in succession until a valid key is found, or no more authorized keys are available. At that point, access is denied.&lt;br /&gt;&lt;br /&gt;Curiously, the actual random number is never exposed in the client/agent exchange - it's sent encrypted to the agent, and&lt;br /&gt;included in an MD5 hash from the agent. It's likely that this is a security precaution designed to make it harder to characterize&lt;br /&gt;the properties of the random number generator on the server by looking at the the client/agent exchange.&lt;br /&gt;&lt;br /&gt;Reference: &lt;a href="http://books.google.com/books?id=NZJsza5q4JQC&amp;amp;printsec=frontcover&amp;amp;dq=ssh+the+definitive+guide&amp;amp;ei=6LNDS8fcG5PIlATcqbzvBw&amp;amp;cd=1#v=onepage&amp;amp;q=&amp;amp;f=false"&gt;SSH The Definitive Guide (Chapter 6 - Key Management and Agents)&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-455334419207308834?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/455334419207308834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/455334419207308834'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2010/01/understand-ssh-agent-forwarding-in-1.html' title='Understand ssh agent forwarding in 1 minute!'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-770764505560418821</id><published>2009-12-26T11:20:00.000-08:00</published><updated>2010-02-09T08:46:20.283-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><category scheme='http://www.blogger.com/atom/ns#' term='Desktop - vim cygwin mintty firefox etc'/><title type='text'>Installing Ubuntu 9.10 on Vmware Hosts and Configure Ubuntu Server</title><content type='html'>&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/lYgWE6Svpag&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/lYgWE6Svpag&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;It said "Install Windows 7 or better",  so I installed Ubuntu.....&lt;/span&gt;&lt;br /&gt;Redhat is supposed to be the leader in open source community; however, with long releasing cycle and sort of "closed" packing practices, Redhat is gradually losing the leadership.  Issues like the painful process of upgrading Python in Redhat Linux distribution has bothered the open source community.  It's time to look for a better open source Linux distribution - &lt;a style="font-weight: bold;" href="http://www.ubuntu.com/"&gt;Ubuntu&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The installation is very easy - download the iso image of ubuntu from its website, create a new vmware host with 8GB virtual disk and 1GB RAM (my laptop has total 4GB RAM), choose "ubuntu" as operating system (these technology leaders really know how to cooperate with each other!), setup NAT network for the new host and pick the iso image as boot image (With vmware's virtual CDROM, I didn't even need to burn the iso file to CD); finally fire up the vmware host then take a break practicing DJHero Daft Punk Megamix. 20 minutes later, my Toshiba laptop powered by Intel Core 2 Duo Processor, 4GB RAM is welcoming a new vmware host member - ubuntu.&lt;br /&gt;&lt;br /&gt;(Ubuntu 9.10 Desktop Screenshots)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/SywRofMSXzI/AAAAAAAACbw/BlaKEHRKKfM/s1600-h/ubuntu-desktop1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/SywRofMSXzI/AAAAAAAACbw/BlaKEHRKKfM/s400/ubuntu-desktop1.jpg" alt="" id="BLOGGER_PHOTO_ID_5416723839085338418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Bash is installed as default shell, most popular open source tools are installed. There are two distributions - Desktop and Server. Desktop has the GUI environment and most UNIX end-user tools installed, Python 2.6 and gcc along with other development tools are installed; however, server products like apache, tomcat, are not. yum is also not installed.  For Sys Admins, you may have to choose to install the desktop or server edition. I actually have  a very good solution - install both and convert the desktop edition to server by reinstalling server's extra packages (the actually upgrade process is at the end of this blog).  &lt;br /&gt;&lt;br /&gt;Using ubuntu is just as easy as installing it. One of the nice features for ubuntu is the ability to update packages automatically. The system silently checks for the latest packages, releases. When a cluster of new packages is available, it will pop up a menu and suggest users to update... Making it short, I really don't want to look back once I start to use ubuntu.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With 3 major UNIX  OSs in one laptop (Solaris, RHEL, Ubuntu), the fun just begins... Very soon, I probably need a new laptop with Quad Core CPU and 8GB - 16GB RAM.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/SywXGlPnwPI/AAAAAAAACb4/X1IzgIE6sos/s1600-h/ubuntu-bug.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_if8QouXbicI/SywXGlPnwPI/AAAAAAAACb4/X1IzgIE6sos/s400/ubuntu-bug.jpg" alt="" id="BLOGGER_PHOTO_ID_5416729853664149746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Is the terminal's transparent mode correct?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ubuntu Server Configuration:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Server installation doesn't come with GUI. For most Intel Duo Core CPU laptops/PCs, installing 64-bit server may create problems.  Someone has re-compiled ubuntu kernel on these CPUs, if you need to borrow the compiled kernels, google "ubuntu 64 bit kernel for Intel Duo Core".  If you don't care about performance and ubuntu's 3-D desktop features (actually I do!) 32 bit kernel is an easy option for most Laptops/PCs.&lt;br /&gt;&lt;br /&gt;The standard server installation doesn't have all the packages by default.  But the installation is fairly simple and straight.&lt;br /&gt;&lt;br /&gt;Command execution is very very fast!&lt;br /&gt;&lt;br /&gt;To install yum, sshd, apache and other packages:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;sudo apt-get install yum&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;sudo apt-get install openssh-server&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;sudo apt-get install gcc&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;sudo apt-get install apache2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To get a list of selections:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;root@ubuntu:~# dpkg --get-selections | awk '{rpint $1}' &gt; pkglist&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To install all perl packages:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;root@ubuntu:~# for i in $(dpkg --get-selections | grep perl | awk '{print $1}'); do echo $i; apt-get -y  install $i; done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To find out what packages are installed:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;root@ubuntu:~#&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;dpkg --list&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To find out files owned by a package:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;root@ubuntu:~# dpkg -L openjdk-6-jre&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre/bin&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre/bin/javaws&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre/bin/pluginappletviewer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre/bin/policytool&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;/usr/lib/jvm/java-6-openjdk/jre/bin/javaws.real&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Ubuntu 9.10 Server, DJHero Daft Punk Megamix, PacMan)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/SyyPBma5etI/AAAAAAAACcQ/jkV_NswWZjY/s1600-h/ubuntu_server.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/SyyPBma5etI/AAAAAAAACcQ/jkV_NswWZjY/s400/ubuntu_server.jpg" alt="" id="BLOGGER_PHOTO_ID_5416861709475871442" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(auto) Install server packages on ubuntu desktop host: (this will give you GUI and all the packages on the server)&lt;br /&gt;&lt;br /&gt;create a list of installed packages on both desktop and server, e.g.&lt;br /&gt;&lt;br /&gt;On the desktop:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;#dpkg --get-selections* | awk '{print $1}' &gt; pkglist.desktop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the server:&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;#dpgk --get-selections* | awk '{print $1}' &gt; pkglist.server&lt;/span&gt;&lt;br /&gt;scp server's pkglist to the host running desktop edition.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;On the desktop host, install the server's additional packages:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;for i in $(diff pkglist pkglist2 | grep '&lt;' | cut -d' ' -f2); do echo $i; apt-get -y install $i; done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next, install tomcat and verify apache2 mod_jk and mod_proxy modules. Create and import a test database into mysql. Perl's base packages  are installed, I cpan a few Perl modules for database and web scripting.  For additional packages, apt-get and yum are our best friends.&lt;br /&gt;&lt;br /&gt;Because my laptop's video card, I am not able to play with Ubuntu's 3D desktop. I'll leave that to my desktop computer.&lt;br /&gt;&lt;br /&gt;That's it! In less than an hour, starting from scratch, we build  a fully loaded standalone Linux server with beautiful desktop and faster, smoother performance!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-770764505560418821?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/770764505560418821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/770764505560418821'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/installing-ubuntu-910-on-vmware-hosts_26.html' title='Installing Ubuntu 9.10 on Vmware Hosts and Configure Ubuntu Server'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_if8QouXbicI/SywRofMSXzI/AAAAAAAACbw/BlaKEHRKKfM/s72-c/ubuntu-desktop1.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4362895662876056329</id><published>2009-12-26T11:07:00.000-08:00</published><updated>2010-05-17T15:18:53.849-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Solaris 10 Administration'/><title type='text'>Solaris 10 Administration</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/SyxvMwn_wpI/AAAAAAAACcI/Xw1gXKkFl-M/s1600-h/sun-e10k.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5416826716821635730" style="WIDTH: 400px; CURSOR: pointer; HEIGHT: 268px" alt="" src="http://1.bp.blogspot.com/_if8QouXbicI/SyxvMwn_wpI/AAAAAAAACcI/Xw1gXKkFl-M/s400/sun-e10k.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;(Sun E10000, 64 CPUs and 64 GB RAM, 16 SBs, up to 16 domains)&lt;br /&gt;&lt;ul&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/solaris-svm-quick-reference.html"&gt;Solaris Volume Manager Quick Reference&lt;/a&gt; &lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/10/fix-solaris-10-smf-related-errors-in-1.html"&gt;Fix Solaris 10 SMF Errors in 1 Minute!&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-managing-network-service-via.html"&gt;Solaris 10 SMF for Network Services&lt;/a&gt; &lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/implement.html"&gt;Implement a Basic Solaris Jumpstart Server&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-jumpstart-1.html"&gt;Solaris Jumpstart Client Boot Sequence&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/08/troubleshoot-solaris-jumpstart.html"&gt;Troubleshoot Solaris Jumpstart&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/solaris-nfs.html"&gt;Solaris NFS Server &lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/04/nfs-quick-setup.html"&gt;Solaris NFS Client&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-syslog.html"&gt;Solaris Syslog&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-swap.html"&gt;Solaris Swap Configuration&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-nscd.html"&gt;Solaris NSCD&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-crashdumps.html"&gt;Solaris Crash Dump Administration&lt;/a&gt;&lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2009/03/solaris-10-autofs.html"&gt;Solaris AutoFS&lt;/a&gt; &lt;/li&gt;&lt;li style="FONT-WEIGHT: bold"&gt;&lt;a href="http://shanit.blogspot.com/2010/05/solaris-10-performance-tuning-cpu_17.html"&gt;Solaris 10 Performance Tuning - CPU Analysis&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a style="FONT-WEIGHT: bold" href="http://shanit.blogspot.com/2009/03/solaris-10-rpcnetwork-ports.html"&gt;Solaris Remote Procedure Call&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a style="COLOR: rgb(255,0,0)" href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Test Your Solaris Administration Skills Here&lt;/a&gt;&lt;span style="COLOR: rgb(255,0,0)"&gt; (NEW!)&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Solaris Volume Manager&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Metastate Database&lt;br /&gt;The state database stores information on disk about the state of VM config.&lt;br /&gt;Multiple copies of the database, called replicas, provide redundancy and&lt;br /&gt;protect against data loss if a copy of the database is corrupted.&lt;br /&gt;&lt;br /&gt;1 Disk - min 3 replicas&lt;br /&gt;2-4 Disks - 2 replicas each disk&lt;br /&gt;5 or more disks - 1 replica on each disk&lt;br /&gt;&lt;br /&gt;Majority Consensus Alogrithm&lt;br /&gt;- at least half of the replicas are available&lt;br /&gt;- causes the system to panic if fewer than half of the replicas available&lt;br /&gt;- won't start VM unless majority replicas are available&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#metadb -a [-f] [-c n] [-l nn] disk_slice&lt;br /&gt;&lt;br /&gt;-a adds a state database replica&lt;br /&gt;-f forces the operation&lt;br /&gt;-c n specifies the number of the replicas to add to the slice&lt;br /&gt;-l nnn specifies the size of the new replicas, in blocks&lt;br /&gt;disk_slice specifies the disk_slice will hold the replica&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#metadb -a -f c0t0d0s4 c0t0d0s5 c1t0d0s1&lt;br /&gt;#metadb -a -f -c 2 c3t2d0s7 c3t3d0s7&lt;br /&gt;&lt;br /&gt;#metadb&lt;br /&gt;&lt;br /&gt;#metainit -f name numstripes width component...&lt;br /&gt;&lt;br /&gt;#metainit -f d0 2 1 c0t0d0s7 c3t2d0s0&lt;br /&gt;&lt;br /&gt;#metastat&lt;br /&gt;&lt;br /&gt;#ls -iL /dev/md/dsk&lt;br /&gt;&lt;br /&gt;#ls -il /dev/md/rdsk&lt;br /&gt;&lt;br /&gt;#growfs -M /export/home /dev/md/rdsk/d0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SVM Operation Examples:&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;vfstab&lt;br /&gt;&lt;br /&gt;#device device mount FS fsck mount mount&lt;br /&gt;#to mount to fsck point type pass at boot options&lt;br /&gt;#&lt;br /&gt;fd - /dev/fd fd - no -&lt;br /&gt;/proc - /proc proc - no -&lt;br /&gt;/dev/md/dsk/d1 - - swap - no -&lt;br /&gt;/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no logging&lt;br /&gt;/dev/md/dsk/d6 /dev/md/rdsk/d6 /zones ufs 2 yes -&lt;br /&gt;/devices - /devices devfs - no -&lt;br /&gt;ctfs - /system/contract ctfs - no -&lt;br /&gt;objfs - /system/object objfs - no -&lt;br /&gt;swap - /tmp tmpfs - yes -&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # metadb&lt;br /&gt;flags first blk block count&lt;br /&gt;a m p luo 16 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;a p luo 8208 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;a p luo 16400 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;&lt;br /&gt;a = active&lt;br /&gt;size = 8192blk = 4MB&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;layout of the disk&lt;br /&gt;&lt;br /&gt;Part Tag Flag Cylinders Size Blocks&lt;br /&gt;0 root wm 2241 - 4481 8.00GB (2241/0/0) 16780608&lt;br /&gt;1 swap wu 0 - 2240 8.00GB (2241/0/0) 16780608&lt;br /&gt;2 backup wm 0 - 38342 136.91GB (38343/0/0) 287112384&lt;br /&gt;3 unassigned wm 0 0 (0/0/0) 0&lt;br /&gt;4 unassigned wm 0 0 (0/0/0) 0&lt;br /&gt;5 unassigned wm 0 0 (0/0/0) 0&lt;br /&gt;6 unassigned wm 4482 - 6722 8.00GB (2241/0/0) 16780608&lt;br /&gt;7 unassigned wm 6723 - 6731 32.91MB (9/0/0) 67392&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;metadb - creates state db replicas&lt;br /&gt;&lt;br /&gt;metadb -a -f c0t0d0s4 c0t0d0s5 c1t0d0s0 c1t0d0s1&lt;br /&gt;metadb -a -f -c n -l nnn disk_slice&lt;br /&gt;-f force operation&lt;br /&gt;-c n specifies the number of replicas to add to the slice&lt;br /&gt;-l nnn specifies the size of the new replica in blocks&lt;br /&gt;disk_slice specifies the slice will hold the replica&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;metainit - creates the metadevices.&lt;br /&gt;&lt;br /&gt;metainit -f concat/stripe numstripes witdth component&lt;br /&gt;&lt;br /&gt;metainit -f d0 2 1 c0t0d0s7 1 c3t2d0s0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;metastat - checks the metadevice configuration&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # metastat&lt;br /&gt;d6: Mirror&lt;br /&gt;Submirror 0: d16&lt;br /&gt;State: Okay&lt;br /&gt;Pass: 1&lt;br /&gt;Read option: roundrobin (default)&lt;br /&gt;Write option: parallel (default)&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;&lt;br /&gt;d16: Submirror of d6&lt;br /&gt;State: Okay&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c0t0d0s6 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;d1: Mirror&lt;br /&gt;Submirror 0: d11&lt;br /&gt;State: Okay&lt;br /&gt;Pass: 1&lt;br /&gt;Read option: roundrobin (default)&lt;br /&gt;Write option: parallel (default)&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;&lt;br /&gt;d11: Submirror of d1&lt;br /&gt;State: Okay&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c0t0d0s1 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;d0: Mirror&lt;br /&gt;Submirror 0: d10&lt;br /&gt;State: Okay&lt;br /&gt;Pass: 1&lt;br /&gt;Read option: roundrobin (default)&lt;br /&gt;Write option: parallel (default)&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;&lt;br /&gt;d10: Submirror of d0&lt;br /&gt;State: Okay&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c0t0d0s0 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Device Relocation Information:&lt;br /&gt;Device Reloc Device ID&lt;br /&gt;c0t0d0 Yes id1,sd@SFUJITSU_MAW3147NC_______DAF4P7400LPR&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # ls -lL /dev/md/dsk&lt;br /&gt;total 0&lt;br /&gt;brw-r----- 1 root sys 85, 0 Jul 19 16:39 d0&lt;br /&gt;brw-r----- 1 root sys 85, 1 Jul 20 06:12 d1&lt;br /&gt;brw-r----- 1 root sys 85, 10 Jul 20 06:12 d10&lt;br /&gt;brw-r----- 1 root sys 85, 11 Jul 20 06:12 d11&lt;br /&gt;brw-r----- 1 root sys 85, 16 Jul 20 06:12 d16&lt;br /&gt;brw-r----- 1 root sys 85, 6 Jul 19 16:40 d6&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Create a swap and a dump fs:&lt;br /&gt;&lt;br /&gt;1. create partition 3 and 4: (using the number and lable command in format)&lt;br /&gt;partition&gt; p&lt;br /&gt;Current partition table (unnamed):&lt;br /&gt;Total disk cylinders available: 38343 + 2 (reserved cylinders)&lt;br /&gt;&lt;br /&gt;Part Tag Flag Cylinders Size Blocks&lt;br /&gt;0 root wm 2241 - 4481 8.00GB (2241/0/0) 16780608&lt;br /&gt;1 swap wu 0 - 2240 8.00GB (2241/0/0) 16780608&lt;br /&gt;2 backup wm 0 - 38342 136.91GB (38343/0/0) 287112384&lt;br /&gt;3 unassigned wm 6732 - 22415 56.00GB (15684/0/0) 117441792&lt;br /&gt;4 unassigned wm 22416 - 26897 16.00GB (4482/0/0) 33561216&lt;br /&gt;5 unassigned wm 0 0 (0/0/0) 0&lt;br /&gt;6 unassigned wm 4482 - 6722 8.00GB (2241/0/0) 16780608&lt;br /&gt;7 unassigned wm 6723 - 6731 32.91MB (9/0/0) 67392&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Create the meta device d3 and d4&lt;br /&gt;&lt;br /&gt;/usr/sbin/metainit -f d3 1 1 c0t0d0s3&lt;br /&gt;&lt;br /&gt;/usr/sbin/metainit -f d4 1 1 c0t0d0s4&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. check:&lt;br /&gt;&lt;br /&gt;metastat&lt;br /&gt;&lt;br /&gt;d4: Concat/Stripe&lt;br /&gt;Size: 33561216 blocks (16 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase Reloc&lt;br /&gt;c0t0d0s4 0 No Yes&lt;br /&gt;&lt;br /&gt;d3: Concat/Stripe&lt;br /&gt;Size: 117441792 blocks (56 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase Reloc&lt;br /&gt;c0t0d0s3 0 No Yes&lt;br /&gt;&lt;br /&gt;Device Relocation Information:&lt;br /&gt;Device Reloc Device ID&lt;br /&gt;c0t0d0 Yes id1,sd@SFUJITSU_MAW3147NC_______DAF4P7400LPR&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;ROOT@server1:/root # newfs -N -v /dev/md/rdsk/d4&lt;br /&gt;mkfs -F ufs -o N /dev/md/rdsk/d4 33561216 -1 -1 8192 1024 155 1 167 8192 t 0 -1 8 16 n&lt;br /&gt;Warning: 3456 sector(s) in last cylinder unallocated&lt;br /&gt;/dev/md/rdsk/d4: 33561216 sectors in 5463 cylinders of 48 tracks, 128 sectors&lt;br /&gt;16387.3MB in 342 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)&lt;br /&gt;Warning: 0 sector(s) in last cylinder unallocated&lt;br /&gt;/dev/md/rdsk/d4: 33561216 sectors in 4482 cylinders of 8 tracks, 936 sectors&lt;br /&gt;16387.3MB in 321 cyl groups (14 c/g, 51.19MB/g, 6208 i/g)&lt;br /&gt;Error determining alternate superblock locations&lt;br /&gt;-------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # newfs -v /dev/md/rdsk/d4&lt;br /&gt;newfs: construct a new file system /dev/md/rdsk/d4: (y/n)? y&lt;br /&gt;mkfs -F ufs /dev/md/rdsk/d4 33561216 -1 -1 8192 1024 155 1 167 8192 t 0 -1 8 16 n&lt;br /&gt;Warning: 3456 sector(s) in last cylinder unallocated&lt;br /&gt;/dev/md/rdsk/d4: 33561216 sectors in 5463 cylinders of 48 tracks, 128 sectors&lt;br /&gt;16387.3MB in 342 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)&lt;br /&gt;super-block backups (for fsck -F ufs -o b=#) at:&lt;br /&gt;32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,&lt;br /&gt;Initializing cylinder groups:&lt;br /&gt;......&lt;br /&gt;super-block backups for last 10 cylinder groups at:&lt;br /&gt;32638496, 32736928, 32835360, 32933792, 33032224, 33130656, 33229088,&lt;br /&gt;33327520, 33425952, 33524384&lt;br /&gt;&lt;br /&gt;copy rootdisk's vtoc to second disk&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # prtvtoc -h /dev/dsk/c0t0d0s2  fmthard -s - /dev/rdsk/c2t0d0s2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;create the replica of metadb c2t0d0 disk on slice 7&lt;br /&gt;ROOT@server1:/root # metadb -a -c 3 c2t0d0s7&lt;br /&gt;ROOT@server1:/root # metadb&lt;br /&gt;flags first blk block count&lt;br /&gt;a m p luo 16 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;a p luo 8208 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;a p luo 16400 8192 /dev/dsk/c0t0d0s7&lt;br /&gt;a u 16 8192 /dev/dsk/c2t0d0s7&lt;br /&gt;a u 8208 8192 /dev/dsk/c2t0d0s7&lt;br /&gt;a u 16400 8192 /dev/dsk/c2t0d0s7&lt;br /&gt;&lt;br /&gt;2. Mirror existing meta devices:&lt;br /&gt;&lt;br /&gt;a. create submirror meta devices&lt;br /&gt;metainit -f d26 1 1 c2t0d0s6&lt;br /&gt;metainit -f d21 1 1 c2t0d0s1&lt;br /&gt;metainit -f d20 1 1 c2t0d0s0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;b. metastat shows current meta device d1 has only one submirror md d11 -&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # metastat d1&lt;br /&gt;d1: Mirror&lt;br /&gt;Submirror 0: d11&lt;br /&gt;State: Okay&lt;br /&gt;Pass: 1&lt;br /&gt;Read option: roundrobin (default)&lt;br /&gt;Write option: parallel (default)&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;&lt;br /&gt;d11: Submirror of d1&lt;br /&gt;State: Okay&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c0t0d0s1 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Device Relocation Information:&lt;br /&gt;Device Reloc Device ID&lt;br /&gt;c0t0d0 Yes id1,sd@SFUJITSU_MAW3147NC_______DAF4P7400LPR&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;c. attach one submirror md - d21&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # metattach d1 d21&lt;br /&gt;d1: submirror d21 is attached&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;d. metastat shows d21 is attached to d1 as a submirror.&lt;br /&gt;now, d1 has two submirror mds d11 and 21&lt;br /&gt;&lt;br /&gt;ROOT@server1:/root # metastat d1&lt;br /&gt;d1: Mirror&lt;br /&gt;Submirror 0: d11&lt;br /&gt;State: Okay&lt;br /&gt;Submirror 1: d21&lt;br /&gt;State: Resyncing&lt;br /&gt;Resync in progress: 0 % done&lt;br /&gt;Pass: 1&lt;br /&gt;Read option: roundrobin (default)&lt;br /&gt;Write option: parallel (default)&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;&lt;br /&gt;d11: Submirror of d1&lt;br /&gt;State: Okay&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c0t0d0s1 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;d21: Submirror of d1&lt;br /&gt;State: Resyncing&lt;br /&gt;Size: 16780608 blocks (8.0 GB)&lt;br /&gt;Stripe 0:&lt;br /&gt;Device Start Block Dbase State Reloc Hot Spare&lt;br /&gt;c2t0d0s1 0 No Okay Yes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Device Relocation Information:&lt;br /&gt;Device Reloc Device ID&lt;br /&gt;c0t0d0 Yes id1,sd@SFUJITSU_MAW3147NC_______DAF4P7400LPR&lt;br /&gt;c2t0d0 Yes id1,sd@SFUJITSU_MAW3147NC_______DAF4P7400M19&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Create a md mirror from slice - d13 and d23 are submirrors of d3&lt;br /&gt;&lt;br /&gt;a. create md from slices&lt;br /&gt;metainit -f d13 1 1 c0t0d0s3&lt;br /&gt;metainit -f d23 1 1 c0t1d0s3&lt;br /&gt;&lt;br /&gt;b. link d13 as the first submirror of d3&lt;br /&gt;metainit d3 -m d13&lt;br /&gt;&lt;br /&gt;c. link d23 as submirror of d3&lt;br /&gt;metattach d3 d23&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4362895662876056329?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4362895662876056329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4362895662876056329'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/solaris-svm-quick-reference.html' title='Solaris 10 Administration'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_if8QouXbicI/SyxvMwn_wpI/AAAAAAAACcI/Xw1gXKkFl-M/s72-c/sun-e10k.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-8146763910444321786</id><published>2009-12-20T14:25:00.000-08:00</published><updated>2010-04-02T13:47:17.767-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>AIX Administration</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/S0OyTDIqn9I/AAAAAAAAClA/zBROfqiqAAc/s1600-h/IBM-LPAR.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_if8QouXbicI/S0OyTDIqn9I/AAAAAAAAClA/zBROfqiqAAc/s400/IBM-LPAR.jpg" alt="" id="BLOGGER_PHOTO_ID_5423374416613122002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(IBM 9117-570 8-Way LPAR managed by Dual HMCs. EMC DMX Frame 2TB, Sepaton Tape Library. OS: AIX, Applications: Sybase ASE 12.5, Veritas VCS. Function: Backend data warehouse)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-adjust-vritual-memory-paging.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Adjust Vritual Memory Paging Settings for Optimal ASE Performance&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-checkpoints.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX  Checkpoints&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-breaking-root-disk-mirrors-for-os.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Breaking Root Disk Mirrors for OS Upgrade&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-boot-related-administration-notes_18.html"&gt;&lt;span style="font-weight: bold;"&gt;AIX Boot Related Administration Notes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-mirrorring-rootdisk.html"&gt;AIX Mirrorring Rootdisk&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://shanit.blogspot.com/2009/12/aix-paging-space-management.html"&gt;AIX Paging Space Management&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://shanit.blogspot.com/2010/04/gauge-unix-skill-level_02.html"&gt;Test Your AIX Administration Skills&lt;/a&gt; (New !)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;AIX Paging Space Management&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An very good guide for AIX memory usage is at &lt;a href="http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.60/html/aix_memory.html"&gt;HERE&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;; See real memory size&lt;br /&gt;lsattr -El sys0 | grep realmem&lt;br /&gt;&lt;br /&gt;bootinfo -r&lt;br /&gt;&lt;br /&gt;svmon -G&lt;br /&gt;&lt;br /&gt;; Create Paging&lt;br /&gt;mkps -a -n -s8 rootvg hdisk1&lt;br /&gt;mkps -a -n -s4 rootvg hdisk3&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#swapon /dev/paging01&lt;br /&gt;&lt;br /&gt;#lsps -a&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Display paging:&lt;br /&gt;&lt;br /&gt;#lsps -a&lt;br /&gt;Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type&lt;br /&gt;hd6             hdisk0            rootvg         512MB     1     yes   yes    lv&lt;br /&gt;paging00        hdisk0            rootvg        2560MB     1     yes   yes    lv&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Shrink paging space on the fly:&lt;br /&gt;&lt;br /&gt;chps -d decrement_LVs -a y|n paging00&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Shrink paging00 by 4 LPs and activate the paging on each subsequent reboot&lt;br /&gt;&lt;br /&gt;#chps -d 4 -a y paging00 ; reduce swap space&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#swapoff /dev/paging00  ; offline swap space&lt;br /&gt;&lt;br /&gt;#rmps paging00   ; to remove paging&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;;all paging space are defined in /etc/swapspaces file&lt;br /&gt;&lt;br /&gt;;to activate all paging space at once&lt;br /&gt;swapon -a&lt;br /&gt;&lt;br /&gt;;to deactivate paging03 and remove&lt;br /&gt;swapoff /dev/paging03&lt;br /&gt;rmps paging03&lt;br /&gt;&lt;br /&gt;;to reduce the size of paging by two LPs&lt;br /&gt;chps -d2 paging03&lt;br /&gt;&lt;br /&gt;;paging summary&lt;br /&gt;mkps&lt;br /&gt;rmps&lt;br /&gt;chps&lt;br /&gt;lsps&lt;br /&gt;swapoff&lt;br /&gt;swapon&lt;br /&gt;chps -s&lt;br /&gt;chps -d&lt;br /&gt;shrinkps&lt;br /&gt;svmon&lt;br /&gt;topas&lt;br /&gt;vmstat&lt;br /&gt;sar&lt;br /&gt;istat&lt;br /&gt;slibclean&lt;br /&gt;ps&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-8146763910444321786?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8146763910444321786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/8146763910444321786'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-paging-space-management.html' title='AIX Administration'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_if8QouXbicI/S0OyTDIqn9I/AAAAAAAAClA/zBROfqiqAAc/s72-c/IBM-LPAR.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7727173460695128686</id><published>2009-12-20T14:17:00.001-08:00</published><updated>2009-12-20T14:34:15.160-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>Mirrorring Rootdisk</title><content type='html'>Set Boot list for different options:&lt;br /&gt;===================================================================&lt;br /&gt;bootlist -m normal -o           ; to see the bootlist&lt;br /&gt;bootlist -m service -o          ; to see the maintenance bootlist&lt;br /&gt;bootlist -m normal -o hdisk0 hdisk4&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To mirror rootvg, current bootdisk is hdisk0.&lt;br /&gt;===================================================================&lt;br /&gt;1. Add disk&lt;br /&gt;extendvg -f rootvg hdisk1&lt;br /&gt;chvg -Qn rootvg&lt;br /&gt;&lt;br /&gt;2. Mirror data (create LVM structure and sync data)&lt;br /&gt;&lt;br /&gt;# mklvcopy hd1 2 hdisk1&lt;br /&gt;# mklvcopy hd2 2 hdisk1&lt;br /&gt;# mklvcopy hd3 2 hdisk1&lt;br /&gt;# mklvcopy hd4 2 hdisk1&lt;br /&gt;# mklvcopy hd5 2 hdisk1&lt;br /&gt;# mklvcopy hd6 2 hdisk1&lt;br /&gt;# mklvcopy hd7 2 hdisk1&lt;br /&gt;# mklvcopy hd8 2 hdisk1&lt;br /&gt;# mklvcopy hd9var 2 hdisk1&lt;br /&gt;# mklvcopy hd10opt 2 hdisk1&lt;br /&gt;# mklvcopy hd11msb 2 hdisk1&lt;br /&gt;# mklvcopy lvtivoli 2 hdisk1&lt;br /&gt;&lt;br /&gt;Or use&lt;br /&gt;mirrorvg rootvg            ; this will disable qurum&lt;br /&gt;&lt;br /&gt;Or use&lt;br /&gt;mirrorvg -s rootvg        ; just create LVM structure, no data sync&lt;br /&gt;syncvg -v rootvg        ; sync the rootvg data&lt;br /&gt;&lt;br /&gt;or use&lt;br /&gt;mirrorvg -S rootvg        ; sync data in the background&lt;br /&gt;&lt;br /&gt;3.create BLV and boot record&lt;br /&gt;&lt;br /&gt;bosboot -ad hdisk1        ; recreate BLV and the boot record on hdisk1&lt;br /&gt;bosboot -ad -u /dev/hdisk1  or&lt;br /&gt;&lt;br /&gt;4.Update bootlist&lt;br /&gt;bootlist -m normal hdisk1 hdisk0&lt;br /&gt;bootlist -m service cd0 rmt0 hdisk0 hdisk1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(Actual operations Screen Shot)&lt;br /&gt;&lt;br /&gt;0:root@sactgx0005:/home/root # bootlist -m normal -o&lt;br /&gt;hdisk0&lt;br /&gt;0:root@sactgx0005:/home/root # ipl_varyon -i&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PVNAME          BOOT DEVICE     PVID                    VOLUME GROUP ID&lt;br /&gt;hdisk0          YES             00031523be6762d10000000000000000        00031523&lt;br /&gt;00004c00&lt;br /&gt;hdisk1          NO              00031523d36a9c5e0000000000000000        00031523&lt;br /&gt;00004c00&lt;br /&gt;hdisk2          NO              00031523f3bacf050000000000000000        00031523&lt;br /&gt;f3badb67&lt;br /&gt;hdisk3          NO              00031523f3baf1de0000000000000000        00031523&lt;br /&gt;f3badb67&lt;br /&gt;hdisk4          NO              00031523f3bb5b570000000000000000        00031523&lt;br /&gt;f3bb694c&lt;br /&gt;hdisk5          NO              00031523f3bb82350000000000000000        00031523&lt;br /&gt;f3bb694c&lt;br /&gt;0:root@sactgx0005:/home/root # bosboot -ad hdisk1&lt;br /&gt;&lt;br /&gt;bosboot: Boot image is 19527 512 byte blocks.&lt;br /&gt;0:root@sactgx0005:/home/root # bootlist -m normal -o&lt;br /&gt;hdisk0&lt;br /&gt;0:root@sactgx0005:/home/root # ipl_varyon -i&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PVNAME          BOOT DEVICE     PVID                    VOLUME GROUP ID&lt;br /&gt;hdisk0          YES             00031523be6762d10000000000000000        00031523&lt;br /&gt;00004c00&lt;br /&gt;hdisk1          YES             00031523d36a9c5e0000000000000000        00031523&lt;br /&gt;00004c00&lt;br /&gt;hdisk2          NO              00031523f3bacf050000000000000000        00031523&lt;br /&gt;f3badb67&lt;br /&gt;hdisk3          NO              00031523f3baf1de0000000000000000        00031523&lt;br /&gt;f3badb67&lt;br /&gt;hdisk4          NO              00031523f3bb5b570000000000000000        00031523&lt;br /&gt;f3bb694c&lt;br /&gt;hdisk5          NO              00031523f3bb82350000000000000000        00031523&lt;br /&gt;f3bb694c&lt;br /&gt;&lt;br /&gt;Clone rootdisk:&lt;br /&gt;===================================================================&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Other Useful Commands&lt;br /&gt;===================================================================&lt;br /&gt;lspv -m hdisk1            ; To see avaliable physical partitions on a disk&lt;br /&gt;&lt;br /&gt;bootinfo -b                     ; to see the current boot device&lt;br /&gt;&lt;br /&gt;ipl_varyon -i            ; to see which disks are bootable&lt;br /&gt;&lt;br /&gt;alt_disk_inst -C hdisk4&lt;br /&gt;alt_disk_inst -C -B -O hdisk4   ; doesn't update the bootlist&lt;br /&gt;&lt;br /&gt;bootinfo -K            ; see what kernel&lt;br /&gt;bootinfo -y            ; see if 64 bit kernel is available&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#bosboot -a -L&lt;br /&gt;#lockstat -a&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7727173460695128686?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7727173460695128686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7727173460695128686'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-mirrorring-rootdisk.html' title='Mirrorring Rootdisk'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3079958624599415763</id><published>2009-12-18T20:30:00.001-08:00</published><updated>2010-01-05T09:23:05.992-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>AIX Sybase ASE Performance Tuning</title><content type='html'>Thanks GOOGLE for making this page top 3 search result of "maxperm sybase ase".&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/S0N0Ujqx5jI/AAAAAAAACgk/dxPsuujfWXU/s1600-h/google-sybase.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/S0N0Ujqx5jI/AAAAAAAACgk/dxPsuujfWXU/s400/google-sybase.jpg" alt="" id="BLOGGER_PHOTO_ID_5423306272805086770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Resolving Poor ASE Performance Due to AIX Default Virtual Memory Paging&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ASE delivers its best performance when all of its memory resides in physical memory on the machine.&lt;br /&gt;It ASE’s memory is paged out by the operating system’s virtual memory subsystem then ASE performance&lt;br /&gt;can suffer dramatically.&lt;br /&gt;&lt;br /&gt;Poor performance due to memory paging on AIX is often reported as problems with ASE’s checkpoint and&lt;br /&gt;/ or housekeeper tasks. These tasks may be slow, appear hung, or encounter timeslice errors.&lt;br /&gt;Transaction dumps may also be affected as ASE cannot properly execute a checkpoint.&lt;br /&gt;Paging particularly affects these tasks because they often process long lists of memory.&lt;br /&gt;If ASE’s memory has been paged out access to it may require a read from disk, resulting in&lt;br /&gt;poor performance. Any other ASE task that must traverse long lists of memory pages may be similarly affected,&lt;br /&gt;resulting in timeslice errors. Logical lock contention may also increase as tasks&lt;br /&gt;which hold locks take longer to run.&lt;br /&gt;&lt;br /&gt;While this is a potential problem on all platforms, certain characteristics of AIX make it more likely&lt;br /&gt;to occur on that platform. The default configuration of the AIX kernel allows the file system cache&lt;br /&gt;to consume up to 80% of the available physical memory pages. Depending on system demand this may result&lt;br /&gt;in ASE memory pages being copied to the swap device. Sybase recommends tuning the AIX virtual memory&lt;br /&gt;subsystem to avoid this scenario.&lt;br /&gt;&lt;br /&gt;The AIX values minperm and maxperm loosely control the ratio of page frames used for files versus&lt;br /&gt;those used for computational processes (such as ASE). Tuning these values requires determining&lt;br /&gt;the physical memory load of processes running on the host machine. maxperm should then be set&lt;br /&gt;so that file pages do not interfere with process pages.&lt;br /&gt;&lt;br /&gt;For example, consider an AIX host that has 8 Gb of physical memory and hosts two ASE servers.&lt;br /&gt;One ASE server is configured to use 3 Gb of max memory and the other is configured to use 2 Gb of max memory.&lt;br /&gt;Other applications on the host require a total of 1 Gb of memory. Therefore the total memory&lt;br /&gt;requirement is 6 Gb (3 Gb + 2 Gb + 1 Gb). As 75% of this host’s physical memory is needed&lt;br /&gt;for applications (6 Gb out of 8 Gb), maxperm should be set no higher than 25%.&lt;br /&gt;&lt;br /&gt;In addition to configuring maxperm, Sybase highly recommends setting strict_maxperm to 1. When strict_maxperm&lt;br /&gt;is set to 0 (the default value), AIX may override the maxperm setting at its discretion. Setting strict_maxperm&lt;br /&gt;to 1 informs AIX that this is a hard limit.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Kernel parameters:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: Value for tunable maxperm% must be greater than or equal to the value of tunable maxclient%&lt;br /&gt;&lt;br /&gt;=======================&lt;br /&gt;maxclient%&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;Specifies maximum percentage of RAM that can be used for caching client pages.&lt;br /&gt;Similar to maxperm% but cannot be bigger than maxperm%.&lt;br /&gt;Values:&lt;br /&gt;o Default: 80&lt;br /&gt;o Range: 1 to 100%.&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;If J2 file pages or NFS pages are causing working storage pages to get paged&lt;br /&gt;out, maxclient can be reduced.&lt;br /&gt;Tuning&lt;br /&gt;Decrease the value of maxclient if paging out to paging space is occurring due&lt;br /&gt;to too many J2 client pages or NFS client pages in memory. Increasing the&lt;br /&gt;value can allow more J2 or NFS client pages to be in memory before page&lt;br /&gt;replacement starts.&lt;br /&gt;&lt;br /&gt;Refer To:&lt;br /&gt;Miscellaneous I/O Tuning Parameters&lt;br /&gt;&lt;br /&gt;========================&lt;br /&gt;&lt;br /&gt;maxperm%&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;Specifies the point above which the page-stealing algorithm steals only file&lt;br /&gt;pages.&lt;br /&gt;Values:&lt;br /&gt;o Default: total number of memory frames * 0.8&lt;br /&gt;o Range: 1 to 100&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;Monitor disk I/O with iostat n.&lt;br /&gt;Tuning&lt;br /&gt;This value is expressed as a percentage of the total real-memory page frames&lt;br /&gt;in the system. Reducing this value may reduce or eliminate page replacement of&lt;br /&gt;working storage pages caused by high number of file page accesses. Increasing&lt;br /&gt;this value may help NFS servers that are mostly read-only. For example, if&lt;br /&gt;some files are known to be read repetitively, and I/O rates do not decrease&lt;br /&gt;with time from startup, maxperm may be too low.&lt;br /&gt;Refer To:&lt;br /&gt;Tuning VMM Page Replacement with the vmtune Command&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;---------------------------------------------------------------------------------------&lt;br /&gt;maxfree&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;Specifies the number of frames on the free list at which page-stealing is to&lt;br /&gt;stop.&lt;br /&gt;Values:&lt;br /&gt;o Default: 128&lt;br /&gt;o Range: 16 to 204800&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;Observe free-list-size changes with vmstat n.&lt;br /&gt;Tuning&lt;br /&gt;If vmstat n shows free-list size frequently driven below minfree by&lt;br /&gt;application demands, increase maxfree to reduce calls to replenish the free&lt;br /&gt;list. Generally, keep maxfree - minfree equal to or less than 100. Setting the&lt;br /&gt;value too high causes page replacement to run for a longer period of time.&lt;br /&gt;Value must be at least 8 greater than minfree&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;maxpin%&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;Specifies the maximum percentage of real memory that can be pinned.&lt;br /&gt;Values:&lt;br /&gt;o Default: 80 percent&lt;br /&gt;o Range: 1 to 99&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;Cannot pin memory, although free memory is available.&lt;br /&gt;Tuning&lt;br /&gt;If this value is changed, the new value should ensure that at least 4 MB of&lt;br /&gt;real memory will be left unpinned for use by the kernel. The maxpin values&lt;br /&gt;must be greater than one and less than 100. Change this parameter only in&lt;br /&gt;extreme situations, such as maximum-load benchmarking.&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;minfree&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;Specifies the minimum number of frames on the free list at which the VMM&lt;br /&gt;starts to steal pages to replenish the free list.&lt;br /&gt;Values:&lt;br /&gt;o Default: maxfree - 8&lt;br /&gt;o Range: 8 to 204800&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;vmstat n&lt;br /&gt;Tuning&lt;br /&gt;Page replacement occurs when the number of free frames reaches minfree. If&lt;br /&gt;processes are being delayed by page stealing, increase minfree to improve&lt;br /&gt;response time. The difference between minfree and maxfree should always be&lt;br /&gt;equal to or greater than maxpgahead.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;strict_maxperm&lt;br /&gt;&lt;br /&gt;Purpose:&lt;br /&gt;If set to 1, the maxperm value will be a hard limit on how much of RAM can be&lt;br /&gt;used as a persistent file cache.&lt;br /&gt;Values:&lt;br /&gt;o Default: 0 (off)&lt;br /&gt;o Range: 0 or 1.&lt;br /&gt;o Type: Dynamic&lt;br /&gt;Diagnosis:&lt;br /&gt;Excessive page outs to page space caused by too many file pages in RAM.&lt;br /&gt;Tuning&lt;br /&gt;Set to 1 in order to make the maxperm value a hard limit (use in conjunction&lt;br /&gt;with the tuning of the maxperm parameter).&lt;br /&gt;Refer To:&lt;br /&gt;Placing a Hard Limit on Persistent File Cache with strict_maxperm&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hands-on examples:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#vmo –a   ; display all&lt;br /&gt;&lt;br /&gt;#vmo –D   ; reset all to default value&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;594     vmo -p -o maxclient%=50  ; good for both current and reboot values&lt;br /&gt;594     vmo -r -o maxclient%=50  ; good for reboot values&lt;br /&gt;595     vmo -o maxclient%=50  ; maxperm% must be larger/equal to maxclient %&lt;br /&gt;596     vmo -o maxperm%=50  ; good for now&lt;br /&gt;597     vmo -r -o maxperm%=50  ; good for reboot&lt;br /&gt;602     vmo -r -o strict_maxperm=1 ; good for reboot&lt;br /&gt;603     vmo -o strict_maxperm=1  ; good for now&lt;br /&gt;604     vmo –a&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. To list the current and reboot value, range, unit, type and dependencies of&lt;br /&gt;all tunables parameters managed by the vmo command, type:&lt;br /&gt;vmo -L&lt;br /&gt;&lt;br /&gt;2. To turn on and reserve 16MB large pages on a POWER4 system, type:&lt;br /&gt;vmo -r -o lgpg_regions=10 -o lgpg_size=16777216&lt;br /&gt;&lt;br /&gt;This command will propose bosboot to the user, and warn that a reboot is&lt;br /&gt;necessary before the change will be effective.&lt;br /&gt;3. To display help on nokilluid, type:&lt;br /&gt;vmo -h nokilluid&lt;br /&gt;&lt;br /&gt;4. To turn on v_pinshm after the next reboot, type:&lt;br /&gt;vmo -r -o v_pinshm=1&lt;br /&gt;&lt;br /&gt;5. To permanently reset all vmo tunable parameters to default, type:&lt;br /&gt;vmo -p -D&lt;br /&gt;&lt;br /&gt;6. To list the reboot value for all virtual Memory Manager tuning parameters,&lt;br /&gt;type:&lt;br /&gt;vmo -r -a&lt;br /&gt;&lt;br /&gt;7. To list (spreadsheet format) the current and reboot value, range, unit,&lt;br /&gt;type and dependencies of all tunables parameters managed by the vmo&lt;br /&gt;command, type:&lt;br /&gt;vmo -x&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;AIX Kernel-VM-Tuning&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See memory usage&lt;br /&gt;&lt;br /&gt;svmon -G -i 1 2&lt;br /&gt;&lt;br /&gt;svmon -P pid&lt;br /&gt;&lt;br /&gt;Kernel Tuning in AIX 5L Version 5.2 Performance Tools Guide and Reference.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Performance Overview of the Virtual Memory Manager&lt;br /&gt;(VMM) and Tuning VMM Page Replacement&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vmo -a    ; display&lt;br /&gt;vmo -d    ; set to default value&lt;br /&gt;vmo -o  ; display or set a tunable to new value&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vmo -p  ; When used in combination with -o, -d or -D, makes changes apply to both&lt;br /&gt;current and reboot values, that is, turns on the updating of the&lt;br /&gt;/etc/tunables/nextboot file in addition to the updating of the current value.&lt;br /&gt;These combinations cannot be used on Reboot and Bosboot type parameters becasue&lt;br /&gt;their current value can't be changed.&lt;br /&gt;&lt;br /&gt;3:root@sactgx0020:/var/log/nmonlog # vmo -a&lt;br /&gt;  memory_frames = 4194304&lt;br /&gt;pinnable_frames = 3947805&lt;br /&gt;        maxfree = 288&lt;br /&gt;        minfree = 256&lt;br /&gt;       minperm% = 20&lt;br /&gt;        minperm = 808874&lt;br /&gt;       maxperm% = 80&lt;br /&gt;        maxperm = 3235503&lt;br /&gt; strict_maxperm = 0&lt;br /&gt;        maxpin% = 80&lt;br /&gt;         maxpin = 3355444&lt;br /&gt;     maxclient% = 80&lt;br /&gt;      lrubucket = 131072&lt;br /&gt;          defps = 1&lt;br /&gt;      nokilluid = 0&lt;br /&gt;      numpsblks = 6684672&lt;br /&gt;        npskill = 52224&lt;br /&gt;        npswarn = 208896&lt;br /&gt;       v_pinshm = 0&lt;br /&gt;pta_balance_threshold = n/a&lt;br /&gt;   pagecoloring = n/a&lt;br /&gt;      framesets = 2&lt;br /&gt;       mempools = 1&lt;br /&gt;      lgpg_size = 0&lt;br /&gt;   lgpg_regions = 0&lt;br /&gt;num_spec_dataseg = 0&lt;br /&gt;spec_dataseg_int = 512&lt;br /&gt;memory_affinity = 1&lt;br /&gt;      htabscale = n/a&lt;br /&gt;force_relalias_lite = 0&lt;br /&gt;relalias_percentage = 0&lt;br /&gt;data_stagger_interval = 161&lt;br /&gt;large_page_heap_size = 0&lt;br /&gt;kernel_heap_psize = 4096&lt;br /&gt;soft_min_lgpgs_vmpool = 0&lt;br /&gt;vmm_fork_policy = 0&lt;br /&gt;low_ps_handling = 1&lt;br /&gt;mbuf_heap_psize = 4096&lt;br /&gt;strict_maxclient = 1&lt;br /&gt; cpu_scale_memp = 8&lt;br /&gt;lru_poll_interval = 0&lt;br /&gt;lru_file_repage = 1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1:root@sactgx0010:/home/root # vmo -L&lt;br /&gt;NAME                      CUR    DEF    BOOT   MIN    MAX    UNIT           TYPE&lt;br /&gt;DEPENDENCIES&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;memory_frames             3840K         3840K                4KB pages         S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;pinnable_frames           3644K         3644K                4KB pages         S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxfree                   128    128    128    16     200K   4KB pages         D&lt;br /&gt;minfree&lt;br /&gt;memory_frames&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;minfree                   120    120    120    8      200K   4KB pages         D&lt;br /&gt;maxfree&lt;br /&gt;memory_frames&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;minperm%                  20     20     20     1      100    % memory          D&lt;br /&gt;maxperm%&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;minperm                   757803        757803                                 S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxperm%                  80     80     80     1      100    % memory          D&lt;br /&gt;minperm%&lt;br /&gt;maxclient%&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxperm                   2960K         2960K                                  S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;strict_maxperm            0      0      0      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxpin%                   80     80     80     1      99     % memory          D&lt;br /&gt;pinnable_frames&lt;br /&gt;memory_frames&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxpin                    3M            3M                                     S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;maxclient%                80     80     80     1      100    % memory          D&lt;br /&gt;maxperm%&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;lrubucket                 128K   128K   128K   64K           4KB pages         D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;defps                     1      1      1      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;nokilluid                 0      0      0      0      4G-1   uid               D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;numpsblks                 7808K         7808K                4KB pages         S&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;npskill                   61K    61K    61K    1      7M-1   4KB pages         D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;npswarn                   244K   244K   244K   0      7M-1   4KB pages         D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;v_pinshm                  0      0      0      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;pta_balance_threshold     n/a    50     50     0      99     % pta segment     R&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;pagecoloring              n/a    0      0      0      1      boolean           B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;framesets                 2      2      2      1      10                       B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;mempools                  1      1      1      1      4                        B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;lgpg_size                 0      0      0      0      256M   bytes             B&lt;br /&gt;lgpg_regions&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;lgpg_regions              0      0      0      0                               B&lt;br /&gt;lgpg_size&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;num_spec_dataseg          0      0      0      0                               B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;spec_dataseg_int          512    512    512    0                               B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;memory_affinity           1      1      1      0      1      boolean           B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;htabscale                 n/a    -1     -1     -4     0                        B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;force_relalias_lite       0      0      0      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;relalias_percentage       0      0      0      0      32K-1                    D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;data_stagger_interval     161    161    161    0      0      4KB pages         D&lt;br /&gt;lgpg_size&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;large_page_heap_size      0      0      0      0      8E-1   bytes             B&lt;br /&gt;lgpg_size&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;kernel_heap_psize         4K     4K     4K     4K     16M    bytes             B&lt;br /&gt;lgpg_size&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;soft_min_lgpgs_vmpool     0      0      0      0      90     %                 D&lt;br /&gt;lgpg_size&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;vmm_fork_policy           0      0      0      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;low_ps_handling           1      1      1      1      2                        D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;mbuf_heap_psize           4K     4K     4K     4K     16M    bytes             B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;strict_maxclient          1      1      1      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;cpu_scale_memp            8      8      8      1      64                       B&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;lru_poll_interval         0      0      0      0      60000  milliseconds      D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;lru_file_repage           1      1      1      0      1      boolean           D&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;n/a means parameter not supported by the current platform or kernel&lt;br /&gt;&lt;br /&gt;Parameter types:&lt;br /&gt;S = Static: cannot be changed&lt;br /&gt;D = Dynamic: can be freely changed&lt;br /&gt;B = Bosboot: can only be changed using bosboot and reboot&lt;br /&gt;R = Reboot: can only be changed during reboot&lt;br /&gt;C = Connect: changes are only effective for future socket connections&lt;br /&gt;M = Mount: changes are only effective for future mountings&lt;br /&gt;I = Incremental: can only be incremented&lt;br /&gt;&lt;br /&gt;Value conventions:&lt;br /&gt;K = Kilo: 2^10       G = Giga: 2^30       P = Peta: 2^50&lt;br /&gt;M = Mega: 2^20       T = Tera: 2^40       E = Exa: 2^60&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3079958624599415763?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3079958624599415763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3079958624599415763'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-adjust-vritual-memory-paging.html' title='AIX Sybase ASE Performance Tuning'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_if8QouXbicI/S0N0Ujqx5jI/AAAAAAAACgk/dxPsuujfWXU/s72-c/google-sybase.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3017125856349401748</id><published>2009-12-18T20:18:00.000-08:00</published><updated>2010-01-05T12:03:36.531-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>AIX Checkpoints</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/S0ObDIGdQ8I/AAAAAAAACjo/kIEEa1P4OcU/s1600-h/iPhone+037.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_if8QouXbicI/S0ObDIGdQ8I/AAAAAAAACjo/kIEEa1P4OcU/s400/iPhone+037.JPG" alt="" id="BLOGGER_PHOTO_ID_5423348854300689346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;A general 10-point checklist for new build AIX servers.&lt;br /&gt;Actual check-point and values may vary. This is just a reference.&lt;br /&gt;&lt;br /&gt;Quick Checkpoint:&lt;br /&gt;1. Adjust paging size;&lt;br /&gt;2. Configure NIC/etherchannel;&lt;br /&gt;3. Update /etc/security/limits;&lt;br /&gt;4. Check/configure the dump devices;&lt;br /&gt;5. Create a shutdown wrapper;&lt;br /&gt;6. Setup/modify sudo privilege;&lt;br /&gt;7. Install additional packages (SAN, EMC, HDS, etc.)&lt;br /&gt;8. Setup NIS client (if required)&lt;br /&gt;9. Mirror rootvg and verify rootvg mirroring&lt;br /&gt;10. Fine tune kernel memory settings (vmo)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Increase paging space size as appropriate:&lt;br /&gt;# mkps –a –n –sXX rootvg&lt;br /&gt;&lt;br /&gt;Update the system settings:&lt;br /&gt;# chdev -l aio0 -a minservers='250' -a maxservers='500'&lt;br /&gt;# chdev -l aio0 -a maxreqs=8192 –a autoconfig='available'&lt;br /&gt;# chdev -l sys0 -a cpuguard=enable -a autorestart=true&lt;br /&gt;# chdev -l sys0 -a iostat=true&lt;br /&gt;# chdev -l sys0 -a maxuproc=500&lt;br /&gt;&lt;br /&gt;2. Configure NIC adapter and create etherchannel:&lt;br /&gt;Remove and recreate the interface used to build the OS:&lt;br /&gt;# ifconfig enX down detach&lt;br /&gt;# rmdev –dl enX&lt;br /&gt;# cfgmgr -v&lt;br /&gt;&lt;br /&gt;Check each NIC adapter's media speed:&lt;br /&gt;# lsdev -Cc adapter | awk '{print $1}' | grep ent | while read i&lt;br /&gt;do&lt;br /&gt; echo "################## $i"&lt;br /&gt; lsattr -El $i -a media_speed&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;Update each NIC adapter's media speed as necessary:&lt;br /&gt;# chdev -l entX -a media_speed=100_Full_Duplex&lt;br /&gt;(For Gigabit Ethernet, use auto_negotiation)&lt;br /&gt;&lt;br /&gt;Create the etherchannel interface which should look like:&lt;br /&gt;EtherChannel / Link Aggregation: ent8&lt;br /&gt;Status: Available&lt;br /&gt;Attributes:&lt;br /&gt;    adapter_names   ent4           EtherChannel Adapters&lt;br /&gt;    alt_addr        0x000000000000 Alternate EtherChannel Address&lt;br /&gt;    auto_recovery   yes            Enable automatic recovery after failover&lt;br /&gt;    backup_adapter  ent6           Adapter used when whole channel fails&lt;br /&gt;    hash_mode       default        Determines how outgoing adapter is chosen&lt;br /&gt;    mode            standard       EtherChannel mode of operation&lt;br /&gt;    netaddr         10.150.144.129 Address to ping&lt;br /&gt;    noloss_failover yes            Enable lossless failover after ping failure&lt;br /&gt;    num_retries     2              Times to retry ping before failing&lt;br /&gt;    retry_time      5              Wait time (in seconds) between pings&lt;br /&gt;    use_alt_addr    no             Enable Alternate EtherChannel Address&lt;br /&gt;    use_jumbo_frame no             Enable Gigabit Ethernet Jumbo Frames&lt;br /&gt;&lt;br /&gt;Use the etherchannel to set up the server's public network connectivity&lt;br /&gt;&lt;br /&gt;3. Update /etc/security/limits:&lt;br /&gt;default:&lt;br /&gt;      fsize = -1&lt;br /&gt;      core = 2097151&lt;br /&gt;      cpu = -1&lt;br /&gt;      data = -1&lt;br /&gt;      rss = -1&lt;br /&gt;      stack = -1&lt;br /&gt;      nofiles = 2000&lt;br /&gt;&lt;br /&gt;4. Configure the dump device:&lt;br /&gt;# sysdumpdev –K&lt;br /&gt;# sysdumpdev –C&lt;br /&gt;# sysdumpdev -Pp /dev/sysdumpnull&lt;br /&gt;# rmlv hd7&lt;br /&gt;# mklv -y hd7 -a im -t sysdump rootvg 16 &lt;== 4G based on 256 MB PP size # sysdumpdev -Pp /dev/hd7  5. Create the /etc/rc.shutdown script:  ##################### Beginning of rc.shutdown ##################### if [ -r /tmp/allowshutdown ];then    rm -f /tmp/allowshutdown     ps -ef | grep "/opt/VRTSvcs/bin/had" | grep -v grep &gt; /dev/null&lt;br /&gt; if [ $? -eq 0 ];then&lt;br /&gt;    echo&lt;br /&gt;    echo "WARNING: VCS should be stopped before shutdown is run"&lt;br /&gt;    echo&lt;br /&gt;    exit 1&lt;br /&gt; fi&lt;br /&gt;&lt;br /&gt; echo "Running /etc/rc.shutdown, please wait...."&lt;br /&gt; exec 1&gt;/tmp/shutdown.log 2&gt;&amp;amp;1&lt;br /&gt; date&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# Add the processes to be shut down in background here&lt;br /&gt;#&lt;br /&gt;#   sleep 120&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt; echo&lt;br /&gt; banner `hostname`&lt;br /&gt; echo&lt;br /&gt; echo "WARNING: If you really want to shutdown this system"&lt;br /&gt; echo "         you must create the file /tmp/allowshutdown"&lt;br /&gt; echo&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt;######################## End of rc.shutdown ########################&lt;br /&gt;&lt;br /&gt;# chmod 700 /etc/rc.shutdown&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. Setup sudo: edit /etc/sudoers for proper setting&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. Install EMC (optional)&lt;br /&gt;# Install EMC Software and License Key&lt;br /&gt;echo "PP_LPAR_KEY_FIX=1" &gt;&gt; /etc/environment&lt;br /&gt;&lt;br /&gt;Install EMC ODM definitions:&lt;br /&gt;# cd /emc_package_home&lt;br /&gt;# installp -agXd. EMC&lt;br /&gt;&lt;br /&gt;Install EMC PowerPath:&lt;br /&gt;# installp -agXd. EMCpower&lt;br /&gt;&lt;br /&gt;Add EMC PowerPath license key:&lt;br /&gt;# emcpreg -add wxyz-wxyz-wxyz-wxyz-wxyz-wxyz&lt;br /&gt;&lt;br /&gt;Install Solution Enabler:&lt;br /&gt;# installp -agXd. EMCsymm&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Config sendmail for security&lt;br /&gt;&lt;br /&gt;Reboot:&lt;br /&gt;# touch /tmp/allowshutdown&lt;br /&gt;# shsutdown -rF&lt;br /&gt;&lt;br /&gt;Add the appropriate netgroups to /etc/passwd&lt;br /&gt;&lt;br /&gt;Create the /etc/no_shell file:&lt;br /&gt;&lt;br /&gt;##################### Beginning of /etc/no_shell #####################&lt;br /&gt;#!/bin/sh&lt;br /&gt;/bin/cat 1&gt;&amp;amp;2 &lt;&lt;eof access="" to="" this="" computer="" is="" prohibited="" unless="" authorized="" eof="" end="" of="" chmod="" 555="" echo="" etc="" no_shell=""&gt;&gt; /etc/passwd&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;8. Setup NIS client and Test NIS:&lt;br /&gt;&lt;br /&gt;Add the following entry to /etc/environment:&lt;br /&gt;# echo "YPBIND_MAXWAIT=10" &gt;&gt; /etc/environment&lt;br /&gt;&lt;br /&gt;Create ypservers from &lt;ypserver_ip&gt; list:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Change the domain name:&lt;br /&gt;(For PROD/DR servers)&lt;br /&gt;# /usr/sbin/chypdom -B prod.us.db.com&lt;br /&gt;(For DEV/UAT servers)&lt;br /&gt;# /usr/sbin/chypdom -B dev.us.db.com&lt;br /&gt;&lt;br /&gt;This command updates /etc/rc.nfs:&lt;br /&gt;if [ -x /usr/bin/domainname ]; then&lt;br /&gt;      /usr/bin/domainname &lt;domain name=""&gt;&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;Start ypbind:&lt;br /&gt;# /usr/sbin/mkclient -B -S &lt;ypserver_ip&gt;&lt;br /&gt;&lt;br /&gt;This command updates /etc/rc.nfs:&lt;br /&gt;if [ -x /usr/lib/netsvc/yp/ypbind ]; then&lt;br /&gt; start ypbind /usr/lib/netsvc/yp/ypbind -ypsetme&lt;br /&gt; /usr/sbin/ypset &lt;ypserver_ip&gt;&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;Verify that ypbind is running:&lt;br /&gt;# ps -ef | grep ypbind&lt;br /&gt;# ypwhich&lt;br /&gt;# ypwhich -m&lt;br /&gt;# ypcat passwd&lt;br /&gt;&lt;br /&gt;Append the following line to /etc/group for NIS group access:&lt;br /&gt;# echo "+:" &gt;&gt; /etc/group&lt;br /&gt;&lt;br /&gt;Update host resolution order (if needed):&lt;br /&gt;/etc/netsvc.conf --&gt; hosts=local,bind  - OR -&lt;br /&gt;NSORDER=local,bind;export NSORDER&lt;br /&gt;(Default is bind,nis,local)&lt;br /&gt;&lt;br /&gt;9. Mirror rootvg&lt;br /&gt;# mirrorvg –S rootvg&lt;br /&gt;# bosboot -ad /dev/ipldevice&lt;br /&gt;# bootlist -m normal hdisk0 hdisk1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;10.Tune VMM (vmo, ioo)&lt;br /&gt;vmo -a&lt;br /&gt;vmo -o&lt;br /&gt;For Sybase ASE servers on AIX 5.xL, to ensure the best performance on Sybase, set the following parameters:&lt;br /&gt;maxperf% = 25%   (default is 80%)&lt;br /&gt;strict_maxperf = 1&lt;br /&gt;&lt;br /&gt;For details on vmo and database performance issue, please refer to this blog article.&lt;/ypserver_ip&gt;&lt;/ypserver_ip&gt;&lt;/domain&gt;&lt;/ypserver_ip&gt;&lt;/eof&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3017125856349401748?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3017125856349401748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3017125856349401748'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-checkpoints.html' title='AIX Checkpoints'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_if8QouXbicI/S0ObDIGdQ8I/AAAAAAAACjo/kIEEa1P4OcU/s72-c/iPhone+037.JPG' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-6809689087276384187</id><published>2009-12-18T18:51:00.000-08:00</published><updated>2009-12-18T19:29:25.726-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>AIX Breaking Root Disk Mirrors for OS Upgrade</title><content type='html'>Before performing any OS patching, it is common practice to break the root disk mirrors. One mirror is used to perform the patching and the second mirror is saved for fail back purposes. This note describes a procedure to break root disk for AIX OS upgrade. This procedure was tested successfully on AIX 5.3 TL7 but should work on all AIX 5.3+ technology levels.&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;1. Do a mksysb backup before patching to provide an alternative method of rebuilding the OS from the NIM server using mksysb copy.&lt;br /&gt;2. The following example assumes that the rootvg contains mirrored copies of LVs on hdisk0 and hdisk1.&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 1: Save the system configuration and break the root mirrors&lt;br /&gt;###&lt;br /&gt;Capture and save outputs from the following commands:&lt;br /&gt;# lspv&lt;br /&gt;# lsvg&lt;br /&gt;# lsvg -o&lt;br /&gt;# lsvg -l `lsvg -o`&lt;br /&gt;# lsvg -p `lsvg -o`&lt;br /&gt;# bootlist -m normal -o&lt;br /&gt;&lt;br /&gt;Export all non-rootvg volume groups&lt;br /&gt;Extract the major and minor number of the disk the system was booted from:&lt;br /&gt;&lt;br /&gt;# ls -al /dev/ipldevice&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 /dev/ipldevice&lt;br /&gt;&lt;br /&gt;Confirm the disk the system was booted from:&lt;br /&gt;# ls -al /dev | grep "22, 9"&lt;br /&gt;brw------- 1 root system 22, 9 Feb 11 15:50 hdisk0&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 ipldevice&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 rhdisk0&lt;br /&gt;&lt;br /&gt;Check the current bootlist:&lt;br /&gt;# bootlist -m normal -o&lt;br /&gt;hdisk0 blv=hd5&lt;br /&gt;hdisk1 blv=hd5&lt;br /&gt;&lt;br /&gt;Remove LV mirrored copies from hdisk1:&lt;br /&gt;# unmirrorvg rootvg hdisk1&lt;br /&gt;&lt;br /&gt;Remove the boot block from hdisk1:&lt;br /&gt;# chpv -c hdisk1&lt;br /&gt;&lt;br /&gt;Remove hdisk1 from rootvg:&lt;br /&gt;# reducevg rootvg hdisk1&lt;br /&gt;&lt;br /&gt;If you see the following error:&lt;br /&gt;0516-016 ldeletepv: Cannot delete physical volume with allocated&lt;br /&gt;partitions. Use either migratepv to move the partitions or&lt;br /&gt;reducevg with the -d option to delete the partitions.&lt;br /&gt;0516-884 reducevg: Unable to remove physical volume hdisk1&lt;br /&gt;some LVs are present only in hdisk1 and have not been mirrored.&lt;br /&gt;&lt;br /&gt;Migrate them to hdisk0 and then remove hdisk1 from rootvg:&lt;br /&gt;# migratepv hdisk1 hdisk0&lt;br /&gt;# reducevg rootvg hdisk1&lt;br /&gt;&lt;br /&gt;Confirm that hdisk1 has been removed from rootvg:&lt;br /&gt;# lsvg -p rootvg&lt;br /&gt;rootvg:&lt;br /&gt;PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION&lt;br /&gt;hdisk0 active 546 250 107..87..22..00..34&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 2: Create the alternate boot disk&lt;br /&gt;###&lt;br /&gt;Create the alternate boot disk on hdisk1:&lt;br /&gt;# alt_disk_copy -d hdisk1&lt;br /&gt;Check the volume groups:&lt;br /&gt;# lsvg&lt;br /&gt;rootvg&lt;br /&gt;altinst_rootvg &lt;= altinst_rootvg contains rootvg on hdisk1&lt;br /&gt;&lt;br /&gt;# lsvg -o&lt;br /&gt;rootvg &lt;= altinst_rootvg is varied off&lt;br /&gt;&lt;br /&gt;The boot list should now point to the alternate disk only:&lt;br /&gt;# bootlist -m normal -o&lt;br /&gt;hdisk1 blv=hd5&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 3: Boot from the alternate boot disk (hdisk1)&lt;br /&gt;###&lt;br /&gt;Reboot:&lt;br /&gt;# shutdown -rF&lt;br /&gt;Verify that the system was booted from the alternate boot disk (hdisk1):&lt;br /&gt;# ls -al /dev/ipldevice&lt;br /&gt;crw------- 2 root system 22, 1 Feb 20 15:50 /dev/ipldevice&lt;br /&gt;&lt;br /&gt;# ls -al /dev | grep "22, 1"&lt;br /&gt;brw------- 1 root system 22, 1 Feb 20 16:07 hdisk1&lt;br /&gt;crw------- 2 root system 22, 1 Feb 20 15:50 ipldevice&lt;br /&gt;crw------- 2 root system 22, 1 Feb 20 15:50 rhdisk1&lt;br /&gt;&lt;br /&gt;Check the volume groups:&lt;br /&gt;# lsvg&lt;br /&gt;rootvg&lt;br /&gt;old_rootvg &lt;= old_rootvg contains rootvg on hdisk0&lt;br /&gt;&lt;br /&gt;# lsvg -o&lt;br /&gt;rootvg &lt;= old_rootvg is varied off&lt;br /&gt;Change the boot list to point to the original boot disk only:&lt;br /&gt;# bootlist -m normal hdisk0&lt;br /&gt;# bootlist -m normal -o&lt;br /&gt;hdisk0 blv=hd5&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 4: Boot from the original boot disk (hdisk0)&lt;br /&gt;###&lt;br /&gt;Reboot:&lt;br /&gt;# shutdown -rF&lt;br /&gt;Confirm that the system was booted from the original boot disk (hdisk0):&lt;br /&gt;# ls -al /dev/ipldevice&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 /dev/ipldevice&lt;br /&gt;# ls -al /dev | grep "22, 9"&lt;br /&gt;brw------- 1 root system 22, 9 Feb 11 15:50 hdisk0&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 ipldevice&lt;br /&gt;crw------- 2 root system 22, 9 Feb 10 11:15 rhdisk0&lt;br /&gt;&lt;br /&gt;Proceed with the OS upgrade&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 5: If the upgrade is successful&lt;br /&gt;###&lt;br /&gt;Remove the alternate boot disk:&lt;br /&gt;# exportvg alinst_rootvg&lt;br /&gt;&lt;br /&gt;Remove the boot block from hdisk1:&lt;br /&gt;# chpv -c hdisk1&lt;br /&gt;&lt;br /&gt;Add hdisk1 to rootvg:&lt;br /&gt;# extendvg -f rootvg hdisk1&lt;br /&gt;&lt;br /&gt;Reestablish root mirroring:&lt;br /&gt;# mirrorvg -S rootvg&lt;br /&gt;&lt;br /&gt;Update the boot list:&lt;br /&gt;# bootlist -m normal hdisk0 hdisk1&lt;br /&gt;&lt;br /&gt;Rebuild the boot volume:&lt;br /&gt;# bosboot -ad /dev/ipldevice&lt;br /&gt;Import non-rootvg volume groups&lt;br /&gt;&lt;br /&gt;###&lt;br /&gt;### Step 6:&lt;br /&gt;### If the upgrade is unsuccessful, boot from the alternate boot disk&lt;br /&gt;### to failback to the OS before the upgrade&lt;br /&gt;###&lt;br /&gt;Update the boot list to point to the alternate boot disk:&lt;br /&gt;# bootlist -m normal hdisk1&lt;br /&gt;# bootlist -m normal -o&lt;br /&gt;hdisk1 blv=hd5&lt;br /&gt;&lt;br /&gt;Reboot:&lt;br /&gt;# shutdown -rF&lt;br /&gt;Check the volume groups:&lt;br /&gt;# lsvg&lt;br /&gt;rootvg&lt;br /&gt;old_rootvg &lt;= old_rootvg contains rootvg on hdisk0&lt;br /&gt;&lt;br /&gt;# lsvg -o&lt;br /&gt;rootvg &lt;= old_rootvg is varied off&lt;br /&gt;&lt;br /&gt;Remove old_rootvg permanently:&lt;br /&gt;# alt_rootvg_op -X old_rootvg - OR -&lt;br /&gt;# alt_disk_install -X old_rootvg&lt;br /&gt;&lt;br /&gt;Add hdisk0 to rootvg and reestablish root mirroring&lt;br /&gt;Import non-rootvg volume groups&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-6809689087276384187?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/6809689087276384187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/6809689087276384187'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-breaking-root-disk-mirrors-for-os.html' title='AIX Breaking Root Disk Mirrors for OS Upgrade'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4153417084313458495</id><published>2009-12-18T18:46:00.000-08:00</published><updated>2009-12-18T18:51:26.094-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AIX Administration'/><title type='text'>AIX Boot Related Administration Notes (1)</title><content type='html'>&lt;h1&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; AIX Boot Related Administration Notes&lt;/span&gt;&lt;/h1&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;RAMFS:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;RAMFS files are accessed using a prefix of /../, eg. rc.boot uses /../usr/sbin/fsck to find fsck.&lt;/p&gt;&lt;p class="MsoNormal"&gt;Mount root out onto /mnt, or you will be unable to access the RAMFS files.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;;To see the last boot device&lt;/p&gt;  &lt;p class="MsoNormal"&gt;#bootinfo -b&lt;/p&gt;  &lt;p class="MsoNormal"&gt; ;To see all boot process related messages&lt;/p&gt;  &lt;p class="MsoNormal"&gt; #alog -t boot -o&lt;/p&gt;  &lt;p class="MsoNormal"&gt; Multi-user initialization completed&lt;span style="mso-spacerun: yes"&gt;                                            &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;ot: executing "copycore"&lt;span style="mso-spacerun: yes"&gt;                                                        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Changed: tty&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;                                                                &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Changed: ipldevice&lt;span style="mso-spacerun: yes"&gt;                                                              &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Changed: IPL_rootvg&lt;span style="mso-spacerun: yes"&gt;                                                             &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;mergedev replaced 3 files in the hardfile /dev directory&lt;span style="mso-spacerun: yes"&gt;                        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: run time mount of /var&lt;span style="mso-spacerun: yes"&gt;                                                 &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: run time mount of /tmp&lt;span style="mso-spacerun: yes"&gt;                                                 &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: checking free space in /tmp&lt;span style="mso-spacerun: yes"&gt;      &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;                                      &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: executing "strload"&lt;span style="mso-spacerun: yes"&gt;                                                    &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: allow 64-bit apps&lt;span style="mso-spacerun: yes"&gt;                                                      &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: executing "cfglivedump -c"&lt;span style="mso-spacerun: yes"&gt;                    &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;                         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;rc.boot: executing "cfgmgr"&lt;span style="mso-spacerun: yes"&gt;                                                     &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;cfgmgr is running in phase 2&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;                                                 &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;----------------&lt;span style="mso-spacerun: yes"&gt;                                                   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;             &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Time: 0 LEDS: 0x538&lt;span style="mso-spacerun: yes"&gt;                                                             &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Invoking top level program -- "/etc/methods/cfgprobe -c /etc/drivers/coreprobe.e&lt;/p&gt;  &lt;p class="MsoNormal"&gt;xt"&lt;span style="mso-spacerun: yes"&gt;                                                                             &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Time: 0 LEDS: 0x539&lt;span style="mso-spacerun: yes"&gt;                                                             &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Return code = 0&lt;span style="mso-spacerun: yes"&gt;                                                                 &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;*** no stdout ****&lt;span style="mso-spacerun: yes"&gt;                                                              &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;*** no stderr ****&lt;span style="mso-spacerun: yes"&gt;                                                              &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;----------------&lt;span style="mso-spacerun: yes"&gt;                                                                &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;stdin&lt;span style="mso-spacerun: yes"&gt;                                                                           &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;                         &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;                                                       &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;;Each fs has two superblocks at 1 and 31. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;;To copy the superblock from block 31 to block 1&lt;/p&gt;  &lt;p class="MsoNormal"&gt;# dd count=1 bs=4k skip=31 seek=1 if=/dev/hd4 of=/dev/hd4&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;;To unlock rootvg&lt;/p&gt;  &lt;p class="MsoNormal"&gt;#chvg -u rootvg&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;               &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;               &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;E1F1 is the led that indicates that a system is looking for a boot devices list in the NVRAM. Please follow the procedurebelow in order to start your system in maintenance mode and then recreate the boot list:&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Booting in Service Mode&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This document describes how to boot the system into Service mode (also known as Maintenance mode) to install the machine,restore an operating system backup, or perform maintenance on the rootvg volume group.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The information in this document applies to AIX Versions 3.x, 4.x and 5.x. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;Booting PCI-based systems into Service mode&lt;/p&gt;  &lt;p class="MsoNormal"&gt;PCI machine-specific information&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Accessing rootvg and mounting file systems&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;Related documentation &lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Booting PCI-based systems into Service mode&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When booting a PowerPC into Service mode, cd0 or rmt0 must be before the hdisk in the bootlist. If not, change the bootlist &lt;/p&gt;  &lt;p class="MsoNormal"&gt;at boot time. On some models, you can set the machine to use a default bootlist that includes both cd0 and rmt0. If a bootable CD or tape is in the CD-ROM or tape drive, the machine will boot from this device.&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;For most of the newer PCI-based models, selecting the default bootlist, with a bootable tape or CD loaded in the machine, causes the system to automatically boot from that device. Generally, the next menu on the screen asks the administrator&lt;/p&gt;  &lt;p class="MsoNormal"&gt;to define the system console. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;For all machines discussed here, if you are using a graphical terminal, you will use a function key such as F5. If you are using an ASCII terminal, use an equivalent number key such as 5. Use the numbers across the top of the keyboard, not thenumbers on the numeric keypad. On ASCII terminals, the icons may not be displayed on the screen; the number can be pressedbetween the second and third beeps, the second beep being a series of three clicks.&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;PCI machine-specific information&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The following systems all use the F5 or 5 key to read from the default boot list, which is written into the system firmware: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;MODEL&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7017&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7024 &lt;span style="mso-spacerun: yes"&gt;      &lt;/span&gt;7025&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7026&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7043&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7137&lt;/p&gt;  &lt;p class="MsoNormal"&gt;--------------&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;/p&gt;  &lt;p class="MsoNormal"&gt;TYPE&lt;span style="mso-spacerun: yes"&gt;      &lt;/span&gt;&lt;span style="mso-tab-count:1"&gt;         &lt;/span&gt;S70&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;E20&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;F30&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;H10&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;43P-140&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;F3L&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;&lt;span style="mso-tab-count:2"&gt;&lt;/span&gt;            S7A&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;E30&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;F40&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;H50&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;43P-150&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;&lt;span style="mso-tab-count:2"&gt;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;                    S80&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;F50&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;H70&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;43P-240&lt;span style="mso-spacerun: yes"&gt;           &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;                                      B80&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;43P-260&lt;span style="mso-spacerun: yes"&gt;          &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;On these machines, use 5 (on the keyboard, not the keypad) if you are using an ASCII terminal. On a locally attached graphics console, use the F5 function key. The F5 or 5 key must be pressed just after the keyboard icon or message is displayed on the console. If you have either a 7026-M80, 7026-H80 or a 7025-F80, then the 5 key will be the default whether you have an ascii or graphics console.&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The following systems use the F1 key to enter System Management Services mode (SMS): &lt;/p&gt;  &lt;p class="MsoNormal"&gt;MODEL&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;6040&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7042&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7247&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7249&lt;/p&gt;  &lt;p class="MsoNormal"&gt;-------&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;/p&gt;  &lt;p class="MsoNormal"&gt;TYPE&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;620&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;850&lt;span style="mso-spacerun: yes"&gt;      &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;82x&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;860&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You should be in an Easy-Setup menu. Select the Start Up menu. Clear the current bootlist settings and then select the CD-ROM for choice 1 and hdd (the hard disk) for choice 2. Select OK. Insert the CD-ROM and select the EXIT icon. The machine should now boot from the CD-ROM.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The following systems use the F2 key to enter SMS: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;MODEL&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;6015&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;6050&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;6070&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7020&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;7248&lt;/p&gt;  &lt;p class="MsoNormal"&gt;-------&lt;span style="mso-spacerun: yes"&gt;     &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;-------&lt;/p&gt;  &lt;p class="MsoNormal"&gt;TYPE&lt;span style="mso-spacerun: yes"&gt;          &lt;/span&gt;440&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;830&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;850&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;40P&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;43P&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Select Select Boot Device from the initial menu on the screen, and then select Restore Default Settings from the list. Press the Esc key to exit all the menus, and then reboot the machine. The system should boot from your bootable media.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;For information on accessing the rootvg volume group, see the next section in this document. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;Accessing rootvg and mounting file systems For AIX Versions 4 and 5, choose Start Maintenance Mode for System Recovery , option 3. The next screen will be called Maintenance; select option 1, Access a Root Volume Group. At the next screen, type 0 to continue, and select the appropriate volume group by typing the number next to it. A screen like the following will display.&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Example: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;                &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;          &lt;/span&gt;Access a Root Volume Group&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Type the number for a volume group to display the logical volume information and press Enter. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;1)&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;Volume Group 0073656f2608e46a contains these disks:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;     &lt;/span&gt;hdisk0&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;2063 04-C0-00-4,0&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Once a volume group has been selected, information will be displayed about that volume group. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;Example: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;                          &lt;/span&gt;Volume Group Information&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;------------------------------------------------------------------------------&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;Volume Group ID 0073656f2608e46a includes the following logical volumes:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;hd6&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;hd5&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;hd8&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;hd4&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;hd2&lt;span style="mso-spacerun: yes"&gt;      &lt;/span&gt;hd9var&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;hd3&lt;span style="mso-spacerun: yes"&gt;         &lt;/span&gt;hd1&lt;span style="mso-spacerun: yes"&gt;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;------------------------------------------------------------------------------&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Type the number of your choice and press Enter. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;1) Access this Volume Group and start a shell&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;2) Access this Volume Group and start a shell before mounting filesystems&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;99) Previous Menu&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If the logical volumes listed do not include logical volumes like hd4, hd2, hd3, and so on, you may have selected the wrong volume group. Press 99 to back up one screen and select again.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Now you may select one of two options: Access this volume group and start a shell , option 1, or Access this volume group and start a shell before mounting file systems , option 2. Option 2 allows you to perform file system maintenance on /, /usr, /tmp, and /var before mounting them.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;NOTE: If you intend to use SMIT or vi, set your terminal type in preparation for editing the file. xxx stands for a terminal&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt; &lt;/span&gt;type such as lft, ibm3151, or vt100. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;TERM=&lt;xxx&gt;&lt;/xxx&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;       &lt;/span&gt;export TERM&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Errors from these steps may indicate failed or corrupt disks in rootvg. These problems should be corrected. For additional assistance, contact your vendor, your local branch office, or your AIX support center.&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;Related documentation&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;For more in-depth coverage of this subject, the following IBM publication is recommended: &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;AIX Version 4.3 System Management Guide: Operating System and Devices&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;AIX Version 5.1 System Management Guide: Operating System and Devices &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;IBM documentation can also be accessed online through the following URL: &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;http://www.rs6000.ibm.com/resource/aix_resource/Pubs/index.html &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;Similar documents can be accessed through the following URL: &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;http://techsupport.services.ibm.com/server/support?view=pSeries &lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Once you have a valid prompt, you can recreate the boot device list (it's supposed you already know the hdisk number from which AIX starts, let's supposed it's hdisk0&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bootlist -m normal hdisk0&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If ths action does not work, repeat the procedure and issue&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bosboot -ad /dev/ipldevice&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Just before the bootlist command&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4153417084313458495?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4153417084313458495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4153417084313458495'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/aix-boot-related-administration-notes_18.html' title='AIX Boot Related Administration Notes (1)'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-4588110443407100052</id><published>2009-12-16T00:21:00.000-08:00</published><updated>2010-04-08T10:24:48.997-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux Administration (Ubuntu RHEL)'/><title type='text'>Accessing Database with Perl DBI</title><content type='html'>The best book to read for this subject is &lt;a href="http://books.google.com/books?id=zbnkLLaFxtcC&amp;amp;printsec=frontcover&amp;amp;dq=programming+the+perl+dbi&amp;amp;ei=9ywpS9K6I5C0kASlxqmxCw&amp;amp;cd=1#v=onepage&amp;amp;q=&amp;amp;f=false"&gt;"Programming the Perl DBI".&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#1. Install Perl DBI::DBD module&lt;/span&gt;&lt;br /&gt;(You may need to remove any installed older versions of perl-DBI-mysql package)&lt;br /&gt;&lt;br /&gt;Several ways to install Perl modules.&lt;br /&gt;1. Download source and compile;&lt;br /&gt;2. Use perl -MCPAN -e 'install DBD::mysql';&lt;br /&gt;3. Use 'cpan';&lt;br /&gt;&lt;br /&gt;For more details about installing Perl modules, please visit&lt;a href="http://www.brandonhutchinson.com/installing_perl_modules.html"&gt; here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I pick 3, use cpan.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;cpan DBI&lt;br /&gt;cpan DBD::mysql&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;(sample run of cpan File::HomeDir)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 ~]# cpan File::HomeDir&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CPAN: Storable loaded ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Going to read /home/shan/perl/.cpan/Metadata&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  Database was generated on Tue, 15 Dec 2009 22:06:58 GMT&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Running install for module File::HomeDir&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Running make for A/AD/ADAMK/File-HomeDir-0.88.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CPAN: LWP::UserAgent loaded ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Fetching with LWP:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  ftp://cpan-du.viaverio.com/pub/CPAN/authors/id/A/AD/ADAMK/File-HomeDir-0.88.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CPAN: Digest::MD5 loaded ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Fetching with LWP:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  ftp://cpan-du.viaverio.com/pub/CPAN/authors/id/A/AD/ADAMK/CHECKSUMS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Checksum for /home/shan/perl/.cpan/sources/authors/id/A/AD/ADAMK/File-HomeDir-0.88.tar.gz ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Scanning cache /home/shan/perl/.cpan/build for sizes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;File-HomeDir-0.88/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  CPAN.pm: Going to build A/AD/ADAMK/File-HomeDir-0.88.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Checking if your kit is complete...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Looks good&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Appending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  /usr/bin/make install  -- OK&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#2. Use instmodsh utility to manage installed modules&lt;/span&gt;&lt;br /&gt;(if instmodsh doesn't show all installed modules, use perldoc perllocal or check perllocal file directly to see the installed modules)&lt;br /&gt;&lt;br /&gt;root@drbl-01 DBD-mysql-4.010]# instmodsh&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Available commands are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;l – List all installed modules&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;m – Select a module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;q – Quit the program&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;cmd? l&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Installed modules are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   CGI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   Cwd&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   DBI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   ExtUtils::MakeMaker&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   FCGI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   File::HomeDir&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   HTML::Parser&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   IO&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   Perl&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   Test::Simple&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   mod_perl2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;cmd? m DBI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Available commands are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   f [all|prog|doc]   - List installed files of a given type&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   d [all|prog|doc]   - List the directories used by a module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   v                  - Validate the .packlist - check for missing files&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   t &lt;/span&gt;&lt;tarfile&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;        - Create a tar archive of the module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   q                  - Quit the module&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;DBI cmd?&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;Available commands are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   f [all|prog|doc]   - List installed files of a given type&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   d [all|prog|doc]   - List the directories used by a module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   v                  - Validate the .packlist - check for missing files&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   t &lt;/span&gt;&lt;tarfile&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;        - Create a tar archive of the module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   q                  - Quit the module&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;DBI cmd? d&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;all directories in DBI are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/bin&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Bundle&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Gofer/Policy&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Gofer/Transport&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Const&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Const/GetInfo&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/DBD&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Gofer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Gofer/Serializer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Gofer/Transport&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/ProfileDumper&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/SQL&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI/Util&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Win32&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/share/man/man1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;   /usr/share/man/man3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can us 't' command to create a tarball to install modules on those same arch servers that don't have access to the Internet directly (e.g. behind firewall).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#3. Grant user privilege to access database&lt;/span&gt;&lt;br /&gt;[root@ipc4 perl]# mysql -u root -p&lt;br /&gt;mysql &gt; grant all privileges on database-name.* to 'user'@'localhost' identified by 'password';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;#4. Create a testing database with two tables&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;[shan@ipc4 ~]$ mysql -u root -p&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Enter password:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Your MySQL connection id is 94&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Server version: 5.1.39-community MySQL Community Server (GPL)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; create database bestbuy;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; use bestbuy;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Database changed&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; create table location(loc_id integer,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; name varchar(50),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; address varchar(60),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; city varchar(20),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; state char(2),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; zipcode char(5));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 0 rows affected (0.07 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; create table purchase&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; (item_id integer not null,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; item_name varchar(30) not null,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; purchase_date datetime,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; loc_id integer,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; unit_price decimal(8,2),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; quantity decimal(6,2),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; amount decimal(8,2),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; comment varchar(100));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 0 rows affected (0.06 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into location(loc_id,name,city,state) values(1,'BestBuy','Pasadena','CA');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.01 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into location(loc_id,name,city,state) values(1,'BestBuy','Duarte','CA');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into location(loc_id,name,city,state) values(1,'BestBuy','Sierra Madre','CA');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; describe purchase;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------------+--------------+------+-----+---------+-------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| Field         | Type         | Null | Key | Default | Extra |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------------+--------------+------+-----+---------+-------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| item_id       | int(11)      | NO   |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| item_name     | varchar(30)  | NO   |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| purchase_date | datetime     | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| loc_id        | int(11)      | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| unit_price    | decimal(8,2) | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| quantity      | decimal(6,2) | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| amount        | decimal(8,2) | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| comment       | varchar(100) | YES  |     | NULL    |       |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------------+--------------+------+-----+---------+-------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;8 rows in set (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -&gt; values(1,'Nitendo DJHero','2009-12-15 19:15:00',1,100,1,108,'Prepare for a DJ job at a LA club.');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment) values(1,'Nitendo Wii','2009-12-15 19:15:00',1,199,1,218,'Prepare for a DJ job at a LA club.');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment) values(1,'MacBookPro','2009-12-15 19:15:00',1,1699,1,1810,'Prepare for a DJ job at a LA club.');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment) values(2,'Samsung LN55B650','2009-12-15 19:15:00',1,199,1,2150,'Prepare for a DJ job at a LA club.');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment) values(3,'Samsung LN55iB8000','2009-12-15 19:15:00',1,1999,1,2150,'Prepare for a DJ job at a LA club.');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Query OK, 1 row affected (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; select * from location;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+--------+---------+---------+--------------+-------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| loc_id | name    | address | city         | state | zipcode |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+--------+---------+---------+--------------+-------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|      1 | BestBuy | NULL    | Pasadena     | CA    | NULL    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|      1 | BestBuy | NULL    | Duarte       | CA    | NULL    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|      1 | BestBuy | NULL    | Sierra Madre | CA    | NULL    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+--------+---------+---------+--------------+-------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;3 rows in set (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; select * from purchase;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+------------+----------+---------+------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| item_id | item_name          | purchase_date       | loc_id | unit_price | quantity | amount  | comment                            |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+------------+----------+---------+------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | Nitendo DJHero     | 2009-12-15 19:15:00 |      1 |     100.00 |     1.00 |  108.00 | Prepare for a DJ job at a LA club. |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | Nitendo Wii        | 2009-12-15 19:15:00 |      1 |     199.00 |     1.00 |  218.00 | Prepare for a DJ job at a LA club. |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | MacBookPro         | 2009-12-15 19:15:00 |      1 |    1699.00 |     1.00 | 1810.00 | Prepare for a DJ job at a LA club. |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       2 | Samsung LN55B650   | 2009-12-15 19:15:00 |      1 |     199.00 |     1.00 | 2150.00 | Prepare for a DJ job at a LA club. |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       3 | Samsung LN55iB8000 | 2009-12-15 19:15:00 |      1 |    1999.00 |     1.00 | 2150.00 | Prepare for a DJ job at a LA club. |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+------------+----------+---------+------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;5 rows in set (0.00 sec)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql&gt; select item_id,item_name,purchase_date,loc_id,amount from purchase;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;| item_id | item_name          | purchase_date       | loc_id | amount  |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | Nitendo DJHero     | 2009-12-15 19:15:00 |      1 |  108.00 |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | Nitendo Wii        | 2009-12-15 19:15:00 |      1 |  218.00 |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       1 | MacBookPro         | 2009-12-15 19:15:00 |      1 | 1810.00 |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       2 | Samsung LN55B650   | 2009-12-15 19:15:00 |      1 | 2150.00 |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;|       3 | Samsung LN55iB8000 | 2009-12-15 19:15:00 |      1 | 2150.00 |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+---------+--------------------+---------------------+--------+---------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;5 rows in set (0.00 sec)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tarfile&gt;&lt;/tarfile&gt;&lt;span style="font-weight: bold;"&gt;#5. Use Perl's DBI::mysql to modify and query the database&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);font-size:85%;" &gt;&lt;span style="font-family:courier new;"&gt;  1 #!/usr/bin/perl -w&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  3 use DBI;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  5 ## mysql user database name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  6 $db ="bestbuy";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  7&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  8 ## mysql database user name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  9 $user = "shan";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 11 ## mysql database password&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 12 $pass = "newyork1";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 13&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 14 ## user hostname : This should be "localhost" but it can be diffrent too&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 15 $host="localhost";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 16&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 17 # Get database handle&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 18 $dbh = DBI-&gt;connect("DBI:mysql:$db:$host", $user, $pass, {RaiseError=&gt;1});&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 19&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 20 # 1. Use $dbh-&gt;do method to perform sql modification type operations&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 21&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 22 $results = $dbh-&gt;do(q{insert into purchase(item_id,item_name,purchase_date,loc_id,unit_price,quantity,amount,comment)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 23         values(1,'SONY Laptop','2009-11-27 5:30:00',1,359,1,375,'Black Friday Bloody Reward')});&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 24         die "Unable to perform insert:$DBI::errstr\n" unless (defined $results);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 25&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 26&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 27&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 28 # 2. Use $dbh-&gt;prepare/$dhb-&gt;execute methods to perform query type operations&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 29&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 30 $sth = $dbh-&gt;prepare(q{select * from purchase})&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 31&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 32         or die "Unable to prep our query:".$dbh-&gt;errstr."\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 33&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 34 # sth is a statement handle retured by method prepare , DBI::st=HASH(0x8f7fbc4)-&gt;fetchrow_array()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 35 my $rv = $sth-&gt;execute&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 36         or die "Unable to execute our query:".$dbh-errstr."\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 37&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 38&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 39 # Output 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 40 print "The output of prepare-execute method sQL operation:\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 41&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 42 while ( @row2 = $sth-&gt;fetchrow_array () ) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 43         my $temp2 = join "\t", @row2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 44         print " $temp2 \n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 45 }&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Execution :&lt;br /&gt;The above script insert record "SONY Laptop" and shows all records in purchase database.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;tarfile&gt;&lt;tarfile&gt;&lt;span style="color: rgb(255, 255, 102);font-size:85%;" &gt;&lt;span style="font-family:courier new;"&gt;[shan@ipc4 perl]$ perl bestbuy.pl&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;The output of prepare-execute method sQL operation:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 1      Nitendo DJHero  2009-12-15 19:15:00     1       100.00  1.00    108.00  Prepare for a DJ job at a LA club.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 1      Nitendo Wii     2009-12-15 19:15:00     1       199.00  1.00    218.00  Prepare for a DJ job at a LA club.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 1      MacBookPro      2009-12-15 19:15:00     1       1699.00 1.00    1810.00 Prepare for a DJ job at a LA club.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 2      Samsung LN55B650        2009-12-15 19:15:00     1       199.00  1.00    2150.00 Prepare for a DJ job at a LA club.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 3      Samsung LN55iB8000      2009-12-15 19:15:00     1       1999.00 1.00    2150.00 Prepare for a DJ job at a LA club.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; 1      SONY Laptop     2009-11-27 05:30:00     1       359.00  1.00    375.00  Black Friday Bloody Reward&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 51, 204);"&gt;Useful Hint for DBAs:&lt;br /&gt;Tired of re-typing a long SQL command after making a typo?&lt;br /&gt;Add the following line in your home directory's &lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;.inputrc&lt;/span&gt; file, you will be able to use vi style editing mode inside mysql shell.&lt;br /&gt;e.g. ESC k to recall the last command you typed, or ESC j to travel down the command line history .. cheers!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;set editing-mode vi&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#6.Troubleshooting:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;#a. My initial (failed) installation of DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;#cpan DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Cannot find the file 'mysql_config'! Your execution PATH doesn't seem&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;not contain the path to mysql_config. Resorting to guessed values!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't exec "mysql_config": No such file or directory at Makefile.PL line 464.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't exec "mysql_config": No such file or directory at Makefile.PL line 464.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't exec "mysql_config": No such file or directory at Makefile.PL line 464.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#b. The root cause is it needs a file mysql_config which comes with  MySQL-devel-community-5.x.x-0.rhel4.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Download it,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[shan@ipc4 rpm]$wget http://opensource.become.com/mysql/Downloads/MySQL-5.4/MySQL-devel-community-5.4.3-0.rhel4.i386.rpm&lt;br /&gt;Or use curl,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tarfile&gt;&lt;/tarfile&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;[shan@ipc4 rpm]$&lt;/span&gt;&lt;/span&gt;&lt;tarfile&gt;&lt;tarfile&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;curl http://opensource.become.com/mysql/Downloads/MySQL-5.4/MySQL-devel-community-5.4.3-0.rhel4.i386.rpm -o MySQL-devel-community-5.4.3-0.rhel4.i386.rpm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;Install it:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -ivh MySQL-devel-community-5.4.3-0.rhel4.i386.rpm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note, make sure you download the correct dev package to match your MySQL server.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#c. Reinstall DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 perl]# cpan DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CPAN: Storable loaded ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Going to read /home/shan/perl/.cpan/Metadata&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Database was generated on Tue, 15 Dec 2009 22:06:58 GMT&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Running install for module DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Running make for C/CA/CAPTTOFU/DBD-mysql-4.013.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CPAN: Digest::MD5 loaded ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Checksum for /home/shan/perl/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.013.tar.gz ok&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Scanning cache /home/shan/perl/.cpan/build for sizes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD-mysql-4.013/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cflags        (mysql_config) = -I/usr/include/mysql  -g -pipe -m32 -DUNIV_LINUX&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;embedded      (mysql_config) =&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;libs          (mysql_config) = -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lmygcc&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysql_config  (guessed     ) = mysql_config&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;nocatchstderr (default     ) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;nofoundrows   (default     ) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ssl           (guessed     ) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;testdb        (default     ) = test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;testhost      (default     ) =&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;testpassword  (default     ) =&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;testsocket    (default     ) =&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;testuser      (guessed     ) = root&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;….&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You may get errors like below, that’s non-critical, it merely complains the DBD::mysql test can’t access the ‘test’ database with root account and password “NO”. You can always manually force the installation by entering the working directory ~.CPAN/build/module_name/ and type “make install”.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;nt.t line 15&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;t/80procs...................skipped&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   all skipped: ERROR: Access denied for user 'root'@'localhost' (using password: NO). Can't continue test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;t/85init_command............skipped&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   all skipped: ERROR: Access denied for user 'root'@'localhost' (using password: NO). Can't continue test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Failed Test Stat Wstat Total Fail  Failed  List of Failed&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;-------------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;t/00base.t     2   512     6   12 200.00%  1-6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;35 tests skipped.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Failed 1/36 test scripts, 97.22% okay. 6/6 subtests failed, 0.00% okay.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;make: *** [test_dynamic] Error 255&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/usr/bin/make test -- NOT OK&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Running make install&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;make test had returned bad status, won't install without force&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Manually install:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 DBD-mysql-4.013]# make install&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.so&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.bs&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Files found in blib/arch: installing files in blib/lib into architecture dependent library tree&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql/GetInfo.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql/INSTALL.pod&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Bundle/DBD/mysql.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/share/man/man3/DBD::mysql::INSTALL.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/share/man/man3/Bundle::DBD::mysql.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installing /usr/share/man/man3/DBD::mysql.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Writing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/.packlist&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Appending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#d. Verify the installation:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 ~]# instmodsh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Available commands are:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   l            - List all installed modules&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   m &lt;module&gt;   - Select a module&lt;/module&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   q            - Quit the program&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cmd? l&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Installed modules are:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   DBI&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   Perl&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   mod_perl2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cmd? m DBD::mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Available commands are:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   f [all|prog|doc]   - List installed files of a given type&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   d [all|prog|doc]   - List the directories used by a module&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   v                  - Validate the .packlist - check for missing files&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   t &lt;tarfile&gt;        - Create a tar archive of the module&lt;/tarfile&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   q                  - Quit the module&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD::mysql cmd? d&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;all directories in DBD::mysql are:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Bundle/DBD&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/share/man/man3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD::mysql cmd? v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD::mysql has no missing files&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD::mysql cmd? f&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;all files in DBD::mysql are:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/share/man/man3/DBD::mysql::INSTALL.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/share/man/man3/DBD::mysql.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql/INSTALL.pod&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.bs&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/share/man/man3/Bundle::DBD::mysql.3pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql/GetInfo.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.so&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Bundle/DBD/mysql.pm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBD::mysql cmd? q&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cmd? q&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 ~]#&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#e. Clean up:&lt;/span&gt;&lt;br /&gt;If your server is installed RHEL 4.0 and it already has MySQL, Perl installed, you may need to do some cleaning work to make sure you are using the correct versions of the package for each components. The sooner you do the cleaning job, the better. Once you installed/configured Perl, MySQL, Python, PHP, etc, etc, you find out you need to upgrade a package that’s required by 100 packages, you will feel the pain. That’s why platform engineering is very important for open source technology.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;On my system, I have RHEL 4.0, which installed very early version of mysqlclient and perl-DBD-mysql. In fact, the old version perl-DBD-mysql-2.9xx is not compatible with MySQL server 5.x.  I need to remove all those obsolete packages without damaging the system.&lt;br /&gt;&lt;br /&gt;remove mysqlclient10-3.23 and its dependencies:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -qa | grep mysql&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mysqlclient10-3.23.58-4.RHEL4.1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -ql $(rpm -qa | grep mysql)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/etc/ld.so.conf.d/mysqlclient10-i386.conf&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/usr/lib/mysql/libmysqlclient.so.10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/usr/lib/mysql/libmysqlclient.so.10.0.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/usr/lib/mysql/libmysqlclient_r.so.10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/usr/lib/mysql/libmysqlclient_r.so.10.0.0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -e $(rpm -qa | grep mysql)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;error: Failed dependencies:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   libmysqlclient.so.10 is needed by (installed) perl-DBD-MySQL-2.9004-3.1.i386&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   libmysqlclient.so.10 is needed by (installed) MySQL-python-1.0.0-1.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   libmysqlclient.so.10 is needed by (installed) MyODBC-2.50.39-21.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   mysqlclient10 is needed by (installed) MySQL-python-1.0.0-1.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -e MySQL-python-1.0.0-1.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -e MyODBC-2.50.39-21.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -e MySQL-python-1.0.0-1.RHEL4.1.i386&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;also, remove the old perl-DBD-MySQL&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[root@ipc4 rpm]# rpm -e perl-DBD-MySQL-2.9004-3.1.i386&lt;/span&gt;&lt;/span&gt;&lt;/tarfile&gt;&lt;/tarfile&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-4588110443407100052?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4588110443407100052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/4588110443407100052'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/troubleshooting-perls-dbdmysql.html' title='Accessing Database with Perl DBI'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-3956501157357055301</id><published>2009-12-13T14:31:00.000-08:00</published><updated>2009-12-15T09:55:42.977-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Auto fetch webpages/sign-in websites with curl and perl</title><content type='html'>#1 - Use curl to sign-in Ebay:&lt;br /&gt;a. create a cookie jar from ebay main page&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;curl -s -L -c cookies.txt -b cookies.txt -e ';auto' -o ebay.html 'http://www.ebay.com/'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;b. download sign-in page&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;curl -s -L -c cookies.txt -b cookies.txt -e ';auto' -o ebay-signin.html 'http://signin.ebay.com/ws/eBayISAPI.dll?SignIn'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;c. login with your ebay account and password&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;curl -s -L -c cookies.txt -b cookies.txt -e ';auto' -o ebay-pass.html \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;-d MfcISAPICommand=SignInWelcome -d siteid=0 -d co_partnerId=2 \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;-d UsingSSL=1 -d ru= -d pp= -d pa1= -d pa2= -d pa3= -d i1=-1 \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;-d pageType=-1 -d rtmData= -d &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);font-family:courier new;" &gt;userid=your-ebay-account -d pass=passwd&lt;/span&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt; \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;'https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&amp;amp;UsingSSL=1&amp;amp;pUserId=&amp;amp;co_partnerId=2&amp;amp;siteid=0'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;d. save your 'my-ebay' page&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);font-family:courier new;" &gt;curl -s -L -c cookies.txt -b cookies.txt -e ';auto' -o myebay.html 'http://my.ebay.com/ws/eBayISAPI.dll?MyEbay'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, use a browser to open  local file myebay.html, you see your MyEbay page if you entered your password correctly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#2 - Use curl to download a range of pages from a website.&lt;br /&gt;( create a directory "tmp" in your home directory to hold the download html pages. )&lt;br /&gt;# this will download 21 files ch1.htm to ch21.htm and save them as  ./tmp/ch-1.html ... ./tmp/ch-21.html&lt;br /&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;curl http://docs.rinet.ru/P7/ch[1-21].htm -o ./tmp/ch-#1.html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Simple Perl script to fetch page&lt;br /&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use LWP::UserAgent;&lt;br /&gt;use HTTP::Request::Common qw(POST);&lt;br /&gt;$UA = LWP::UserAgent-&amp;gt;new();&lt;br /&gt;$req = HTTP::Request-&amp;gt;new( GET =&gt; "http://www.ebay.com/" );&lt;br /&gt;$resp = $UA-&amp;gt;request($req);&lt;br /&gt;# check for error. Print page if it's OK&lt;br /&gt;if ( ( $resp-&amp;gt;code() &amp;gt;= 200 ) &amp;amp;&amp;amp; ( $resp-&gt;code() &amp;lt; 400 ) ) {&lt;br /&gt;print $resp-&amp;gt;decoded_content;&lt;br /&gt;} else {&lt;br /&gt;print "Error: " . $resp-&amp;gt;status_line . "\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;(to be continued...)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-3956501157357055301?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3956501157357055301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/3956501157357055301'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/auto-fetch-webpagessign-in-websites.html' title='Auto fetch webpages/sign-in websites with curl and perl'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-2454778454360925248</id><published>2009-12-13T13:39:00.000-08:00</published><updated>2009-12-18T10:33:45.862-08:00</updated><title type='text'>How much privacy we have?</title><content type='html'>Picture of one of my blog visitors' neighborhood ... Yes, I just get your info if you're viewing this page now. :-)&lt;br /&gt;(The image is processed to protect privacy)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/SyVlpfAZiEI/AAAAAAAACbc/S5zvG7WnkFw/s1600-h/privacy-2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 65px;" src="http://2.bp.blogspot.com/_if8QouXbicI/SyVlpfAZiEI/AAAAAAAACbc/S5zvG7WnkFw/s400/privacy-2.jpg" alt="" id="BLOGGER_PHOTO_ID_5414845890355103810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Picture of an oversea visitor's neighborhood ...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/SyVi1yUCusI/AAAAAAAACbM/Z9Osas7FdP8/s1600-h/india-visitor.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 198px;" src="http://1.bp.blogspot.com/_if8QouXbicI/SyVi1yUCusI/AAAAAAAACbM/Z9Osas7FdP8/s400/india-visitor.jpg" alt="" id="BLOGGER_PHOTO_ID_5414842803161316034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Picture of a Jersey visitor's neighborhood ...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/SyVj0_qBKxI/AAAAAAAACbU/bd2K1TrmGlI/s1600-h/jerseyvisitor.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 147px;" src="http://4.bp.blogspot.com/_if8QouXbicI/SyVj0_qBKxI/AAAAAAAACbU/bd2K1TrmGlI/s400/jerseyvisitor.jpg" alt="" id="BLOGGER_PHOTO_ID_5414843889074907922" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-2454778454360925248?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/2454778454360925248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/2454778454360925248'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/how-much-privacy-we-have.html' title='How much privacy we have?'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_if8QouXbicI/SyVlpfAZiEI/AAAAAAAACbc/S5zvG7WnkFw/s72-c/privacy-2.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-7080503134058291851</id><published>2009-12-07T20:21:00.000-08:00</published><updated>2010-04-13T01:06:54.156-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Desktop - vim cygwin mintty firefox etc'/><title type='text'>My Desktop (click image for full view)</title><content type='html'>Besides Mintty's improved function over Putty, the cool transparent mode allows users to read files in the background without switching the terminal back and forth.  It's very helpful when you read a pdf file while coding in vim!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/SyNlLbsaQiI/AAAAAAAACa8/kRgsEd7epco/s1600-h/vimshell9.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_if8QouXbicI/SyNlLbsaQiI/AAAAAAAACa8/kRgsEd7epco/s400/vimshell9.jpg" alt="" id="BLOGGER_PHOTO_ID_5414282424116462114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My laptop : cygwin+mintty and vim/vimshell.( At this moment, vimshell can only be patched into vim 7.0. You need to recompile vim if you have 7.x)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/Sx_7aW3wtII/AAAAAAAACY8/7z5pAplRgOU/s1600-h/linux-desktop.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://3.bp.blogspot.com/_if8QouXbicI/Sx_7aW3wtII/AAAAAAAACY8/7z5pAplRgOU/s400/linux-desktop.jpg" alt="" id="BLOGGER_PHOTO_ID_5413321707357254786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My Desktop:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/Sx3U9juJDyI/AAAAAAAACXM/UzKN_3yxTmU/s1600-h/vimshell3.png"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_if8QouXbicI/Sx3U9juJDyI/AAAAAAAACXM/UzKN_3yxTmU/s800/vimshell3.png" alt="" id="BLOGGER_PHOTO_ID_5412716481195085602" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-7080503134058291851?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7080503134058291851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/7080503134058291851'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/my-desktop.html' title='My Desktop (click image for full view)'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_if8QouXbicI/SyNlLbsaQiI/AAAAAAAACa8/kRgsEd7epco/s72-c/vimshell9.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-1737318527699493306</id><published>2009-12-07T00:44:00.000-08:00</published><updated>2009-12-09T18:05:03.778-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting ( Shell Perl Python)'/><title type='text'>Interesting Tasks for Shell (Scripting)</title><content type='html'>Here are my responses to a few help-requests at unix.ittoolbox.com:&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/getting-unique-values-3157838"&gt;The original request:&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"hi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;i have string like below&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;aabccdee&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;how to extract just the unique values from above..&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;i want my output to be&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;abcde&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"&lt;/span&gt;&lt;br /&gt;My solution:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;[shan@ipc4 ~]$ sed -n 's@\([a-zA-Z]\)\1*@\1@pg' &amp;lt; input_file &amp;gt; txt.output&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or (a smart guy's tr solution.)&lt;br /&gt;echo "aabccdee" | tr -s [[:alpha:]]&lt;br /&gt;&lt;br /&gt;2. &lt;a href="http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/arg-list-too-long-3161018"&gt;The original request:&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;i have a around ~15k csv files created in the month of nov,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;each file has around 100 fields, i have to get the unique of 10th field.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;MY solution:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;find . -name "*in" -exec awk -F" " '{print $3}' {} \; | tr -sc 0-9A-Za-z '\012' | sort | uniq -c | sort -nr&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sample output: (count : 10th field)&lt;br /&gt;43 Makefile&lt;br /&gt;38 YPPUSH&lt;br /&gt;36 YPDIR&lt;br /&gt;36 in&lt;br /&gt;19 YPSRCDIR ...&lt;br /&gt;&lt;br /&gt;3. &lt;a href="http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/multiple-files-from-a-single-file-3153834"&gt;The original request&lt;/a&gt;:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;I have a file of the following format:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;gi|*170079665*|ref|YP_001728985.1| gi|*15829256*|ref|NP_308029.1|&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;99.76 820 2 0 1 820 1 820 0.0 1645&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;gi|*170079666*|ref|YP_001728986.1| gi|*15829257*|ref|NP_308030.1|&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;99.35 310 2 0 1 310 1 310 4e-177 613&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;For each of the lines in this file I want to create a file having the two&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;numbers in bold in this format :&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;*170079665&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;**15829256*&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My solution: (there are simple ones with perl/python... but, hey, shell is great!)&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;$ mkdir tmp; export j=1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;$ for i in $(cut -d'|' -f2,6 &lt;&gt;&gt; ./tmp/file.$j&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;echo '*'$(echo $i | cut -d"|" -f2) &gt;&gt; ./tmp/file.$j&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;let j=$j+1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;done&lt;/span&gt;&lt;br /&gt;input-file:&lt;br /&gt;gi|*170079665*|ref|YP_001728985.1| gi|*15829256*|ref|NP_308029.1| 99.76 820 2 0 1 820 1 820 0.0 1645&lt;br /&gt;gi|*170079800*|ref|YP_001728235.1| gi|*15829846*|ref|NP_308029.1| 99.76 820 2 0 1 820 1 820 0.0 1645&lt;br /&gt;&lt;br /&gt;output:&lt;br /&gt;$ ls tmp&lt;br /&gt;file.1 file.2 file.3 file.4&lt;br /&gt;$ cat ./tmp/file.1&lt;br /&gt;*170079665*&lt;br /&gt;**15829256*&lt;br /&gt;$ cat ./tmp/file.2&lt;br /&gt;*170079800*&lt;br /&gt;**15829846* ...&lt;br /&gt;&lt;br /&gt;cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3647922545077012977-1737318527699493306?l=shanit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1737318527699493306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3647922545077012977/posts/default/1737318527699493306'/><link rel='alternate' type='text/html' href='http://shanit.blogspot.com/2009/12/interesting-tasks-for-shell-scripting.html' title='Interesting Tasks for Shell (Scripting)'/><author><name>Shan Jing</name><uri>http://www.blogger.com/profile/17863845298602874166</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/-B_pWKeZXfE0/TmqhZ4RK5rI/AAAAAAAADCg/QsKkJJXg3Tg/s220/53557_1584848893437_1002201757_31645182_3831356_o.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-3647922545077012977.post-5242627133399120486</id><published>2009-12-06T12:57:00.000-08:00</published><updated>2010-04-13T01:17:07.338-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Desktop - vim cygwin mintty firefox etc'/><title type='text'>vim, vimshell, mintty ( cool stuffs!)</title><content type='html'>Vim Tricks&lt;br /&gt;&lt;br /&gt;Let's see some of vim's advanced features:&lt;br /&gt;1. vim in multiple windows;&lt;br /&gt;2. use vim's tabs function (vim 7.1+)  ;&lt;br /&gt;3. vim spelling;&lt;br /&gt;4. vimshell (having a shell inside vim!)&lt;br /&gt;5. more advanced vim commands.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_if8QouXbicI/SzGzkvqFiuI/AAAAAAAACcg/8Ke66k_fNCI/s1600-h/vimshell2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://3.bp.blogspot.com/_if8QouXbicI/SzGzkvqFiuI/AAAAAAAACcg/8Ke66k_fNCI/s400/vimshell2.jpg" alt="" id="BLOGGER_PHOTO_ID_5418309270553070306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;(click the image for large view)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#1.split screens and editing multiple files:&lt;br /&gt;vim -o file1 file2  to start vim in split-mode editing two files&lt;br /&gt;if already inside vim working with one file, use :sp command to split/open new file&lt;br /&gt;:sp filename    #opens a new file and split screen in vim&lt;br /&gt;:n new_file     #opens a new file and replace current file&lt;br /&gt;:b new_file     #opens a new file and replace current file&lt;br /&gt;:args           #to see which files are open with&lt;br /&gt;&lt;br /&gt;#CTRL W + j,k key to switch/toggle between windows/files&lt;br /&gt;#CTRL W + s or v to split current window horizontally or veritically&lt;br /&gt;#CTRL W + c to close current window&lt;br /&gt;#CTRL W + x to swap window positions&lt;br /&gt;&lt;br /&gt;#2. use vim's tabs to edit multiple files- far superior to buffer ( for vim 7.1+)&lt;br /&gt;:tabe filename  #opens a file in a new tab (a new thread of vim)&lt;br /&gt;:tabn or gt     #go to next file in tab&lt;br /&gt;:tabp or gT     #go to previous file in tab&lt;br /&gt;:ls             #to see a list of current tabs/buffers&lt;br /&gt;:1b             #to switch to the 1st tab/buffer same as gt/tabn cmds&lt;br /&gt;:2b             #to switch to the 2nd tab/buffer same as gt/tabn cmds&lt;br /&gt;:help tabe      #to see tab's help&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#3. vim spelling&lt;br /&gt;To switch on: :setlocal spell spelllang=en_us&lt;br /&gt;To switch off::set nospell&lt;br /&gt;:help spell to see details.&lt;br /&gt;&lt;br /&gt;navigation:&lt;br /&gt;]s - next misspelled word&lt;br /&gt;[s - prev "&lt;br /&gt;&lt;br /&gt;interaction:&lt;br /&gt;zg - add misspelled word to system dictionary&lt;br /&gt;zG - add misspelled word to buffer-local set of "good" words&lt;br /&gt;zw - add word to 'bad' list&lt;br /&gt;zW - add word to buffer-local 'bad' list&lt;br /&gt;z= - view a numbered list of suggested spellings from which to choose for auto-replacement&lt;br /&gt;&lt;br /&gt;#4. Need a shell inside vim window? Isn't just hitting Ctrl_W e/E to drop a shell window in your VIM session cool?!&lt;br /&gt;With this feature, I virtually can do administration tasks without leaving vim. Perfect for coding while doing admin tasks.&lt;br /&gt;&lt;br /&gt;To setup is simple, just patch vim with vimshell and define ctrl_w e/E in your .vimrc file with these mappings:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;" VIM-Shell&lt;br /&gt;" Ctrl_W e opens up a vimshell in a horizontally split window&lt;br /&gt;" Ctrl_W E opens up a vimshell in a vertically split window&lt;br /&gt;" The shell window will be auto closed after termination&lt;br /&gt;nmap &amp;lt;C-W&amp;gt;e :new \| vimshell bash&amp;lt;CR&amp;gt;&lt;br /&gt;nmap &amp;lt;C-W&amp;gt;E :vnew \| vimshell bash&amp;lt;CR&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, let's see something very cool! - run vim inside mintty in transparent mode...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_if8QouXbicI/SzG0UhpIm7I/AAAAAAAACco/dHoLUoXfmsM/s1600-h/vimshell8.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_if8QouXbicI/SzG0UhpIm7I/AAAAAAAACco/dHoLUoXfmsM/s400/vimshell8.jpg" alt="" id="BLOGGER_PHOTO_ID_5418310091424701362" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Or, run mintty in glass mode...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_if8QouXbicI/SzG1PtbmOiI/AAAAAAAACcw/I4tRBpvD1yM/s1600-h/ubuntu_server.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 250px;" src="http://4.bp.blogspot.com/_if8QouXbicI/SzG1PtbmOiI/AAAAAAAACcw/I4tRBpvD1yM/s400/ubuntu_server.jpg" alt="" id="BLOGGER_PHOTO_ID_5418311108201429538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#5. some useful vim commands&lt;/span&gt;&lt;br /&gt;#load VIM without .vimrc and plugins (clean VIM)&lt;br /&gt;gvim -u NONE -U NONE -N&lt;br /&gt;" execute multiple command on a single file&lt;br /&gt;vim -c "%s/ABC/DEF/ge | update" file1.c&lt;br /&gt;" execute multiple command on a group of files&lt;br /&gt;vim -c "argdo %s/ABC/DEF/ge | update" *.c&lt;br /&gt;gvim.exe -c "/main" joe.c  : Open joe.c &amp;amp; jump to "main"&lt;br /&gt;gvim -d file1 file2        : vimdiff (compare differences)&lt;br /&gt;dp                         : "put" difference under cursor to other file&lt;br /&gt;do                         : "get" difference under cursor from other file&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;:reg             : display contents of all registers&lt;br /&gt;:reg a           : display content of register a&lt;br /&gt;:let @y='yy@"'   : pre-loading registers (put in .vimrc)&lt;br /&gt;qqq              : empty register "q"&lt;br /&gt;qaq              : empty register "a"&lt;br /&gt;:h quickref             : VIM Quick Reference Sheet (ultra)&lt;br /&gt;:h tips                 : Vim's own Tips Help&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;" where was an option set&lt;br /&gt;:scriptnames            : list all plugins, _vimrcs loaded (super)&lt;br /&gt;:verbose set history?   : reveals value of history and where set&lt;br /&gt;:function               : list functions&lt;br /&gt;:func SearchCompl       : List particular function&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;:'a,'bg/^/m'b               : Reverse a section a to b&lt;br /&gt;:g/^/t.                     : duplicate every line&lt;br /&gt;:g/fred/t$                  : copy(transfer) lines matching fred to EOF&lt;br /&gt;:g/gladiolli/#              : display with line numbers&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;:%s#&lt;[^&gt;]\+&gt;##g             : delete html tags, leave text (non-greedy)&lt;br /&gt;:%s#&lt;\_.\{-1,}&gt;##g          : delete html tags possibly multi-line (non-greedy)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_if8QouXbicI/SyCQPd-Rr3I/AAAAAAAACac/tNNdevMniXE/s1600-h/vimshell6.jpg"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_if8QouXbicI/SyCQPd-Rr3I/AAAAAAAACac/tNNdevMniXE/s800/vimshell6.jpg" alt="" id="BLOGGER_PHOTO_ID_5413485347517607794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Res
