<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AskApache &#187; Search Results  &#187;  nice</title>
	<atom:link href="http://www.askapache.com/search/nice/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Thu, 26 Apr 2012 11:29:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Show or Hide WordPress Admin Bar Plugin</title>
		<link>http://www.askapache.com/wordpress/hide-admin-bar.html</link>
		<comments>http://www.askapache.com/wordpress/hide-admin-bar.html#comments</comments>
		<pubDate>Thu, 19 Apr 2012 06:15:14 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress Plugin]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=7121</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/wordpress/hide-admin-bar.html"><img src="http://uploads.askapache.com/2012/04/profile-no-admin-bar-300x258.png" alt="WordPress No Admin Bar" title="WordPress No Admin Bar" width="300" height="258" /></a>The Admin Bar in WordPress is always shown when in the backend administration area no matter what.<br /><br />You are given the option to show/hide the admin bar when <em>viewing the site</em>, but there is no option to show/hide the admin bar when <em>using the backend</em>... So I created a plugin to provide that option on profile pages.<br /><br /><em>Why hide the admin bar in backend?</em><br />Normally I like the admin-bar and usually have it enabled, but it's nice to be able to switch it on/off from the "Edit Profile" page.  The biggest reason for not loading/showing the admin_bar in the backend is <strong>SPEED</strong>.  Here are 2 instances where I hide it-<br /><br /> &#160;&#160;&#160;&#160;&#183; <strong>Sites with many authors/admins</strong><br /> &#160;&#160;&#160;&#160;&#183; <strong>Moderating Comments on a Mobile Phone</strong><br /><br />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"></a><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"><cite>AskApache.com</cite></a></p><p><a class="IFL" href="http://uploads.askapache.com/2012/04/profile-no-admin-bar.png"><img src="http://uploads.askapache.com/2012/04/profile-no-admin-bar.png" alt="WordPress No Admin Bar" title="WordPress No Admin Bar" width="537" height="462" /></a>The Admin Bar in WordPress is always shown when in the backend administration area no matter what.<br /><br />You are given the option to show/hide the admin bar when <em>viewing the site</em>, but there is no option to show/hide the admin bar when <em>using the backend</em>... So I created a plugin to provide that option on profile pages.<br /><br /><em>Why hide the admin bar in backend?</em><br />Normally I like the admin-bar and usually have it enabled, but it's nice to be able to switch it on/off from the "Edit Profile" page.  The biggest reason for not loading/showing the admin_bar in the backend is <strong>SPEED</strong>.  Here are 2 instances where I hide it-<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;&middot; <strong>Sites with many authors/admins</strong><br /> &nbsp;&nbsp;&nbsp;&nbsp;&middot; <strong>Moderating Comments on a Mobile Phone</strong><br /><br />
I occasionally enjoy moderating blog comments using my Android mobile phone and a browser like Opera or Dolphin.... hiding the admin_bar improves Load Speed, Page Rendering Speed, and Scroll Speed. Basically everything.<br /><br />The wp-admin-bar causes additional CSS, JavaScript, and HTML to be added to every page, increasing request size and time of every request!  The jQuery used for the admin_bar keeps it floating at the top using javascript, meaning it gets executed on resize/scroll/load - MAJOR PAIN!<br class="C" /></p>


<h2>Plugin for Hiding/Showing the WP AdminBar</h2>
<p><img class="IFL" src="http://uploads.askapache.com/2012/04/profile-with-adminbar.png" alt="WordPress with Admin Bar" title="WordPress with Admin Bar" width="537" height="462" /><br /><br /><br /><br /><br /><br />This plugin provides the option of hiding the admin bar when in_admin.  It not only hides the admin_bar, it actually prevents the admin_bar class from even loading, at least in WP version 3.4-beta2-20509 thanks to the <code>wp_admin_bar_class</code> filter.<br /><br />Follow the Installation steps below and/or read on to see how it works.. it's an incredibly simple plugin and easy to extend for other purposes.<br class="C" /></p>


<h3>Installation Steps</h3>
<ol>
<li>Download the plugin file: <a href='http://uploads.askapache.com/2012/04/askapache-adminbar-prefs.txt'>askapache-adminbar-prefs.txt</a></li>
<li>Save to <code>/wp-content/plugins/askapache-adminbar-prefs/askapache-adminbar-prefs.php</code></li>
<li>Enable/Disable the plugin from the Plugins Page</li>
<li>Show/Hide admin_bar from the 'Edit Profile' Page</li>
</ol>

<h3>Add Checkbox Option to Profile Page</h3>
<pre>
function askapache_adminbar_personal_options( $profileuser )
{
 global $wpdb, $wp_query;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $profileuser-&gt;ID );
?&gt;
&lt;tr class="show-admin-bar-backend"&gt;
&lt;th scope="row"&gt;Toolbar2&lt;/th&gt;
&lt;td&gt;&lt;fieldset&gt;&lt;legend class="screen-reader-text"&gt;&lt;span&gt;Toolbar2&lt;/span&gt;&lt;/legend&gt;
&lt;label for="admin_bar_backend"&gt;
&lt;input name="admin_bar_backend" type="checkbox" id="admin_bar_backend" value="1"&lt;?php checked( _get_admin_bar_pref( &#039;backend&#039;, $profileuser-&gt;ID ) ); ?&gt; /&gt;
Show Toolbar when in backend&lt;/label&gt;&lt;br /&gt;
&lt;/fieldset&gt;
&lt;/td&gt;
&lt;/tr&gt;&lt;?php
}
add_action( &#039;personal_options&#039;, &#039;askapache_adminbar_personal_options&#039;, 10, 1 );
</pre>



<h3>Save preference when a profile updated</h3>
<pre>
function askapache_adminbar_handle_post($useridtoedit)
{
 global $wpdb, $wp_query, $current_user;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $useridtoedit );
 
 $userID=(int)$useridtoedit;
 if ( !current_user_can(&#039;edit_user&#039;, $userID) ) wp_die(__(&#039;You do not have permission to edit this user.&#039;));
 
 $show_admin_bar_backend=(isset( $_POST[&#039;admin_bar_backend&#039;] ) ? &#039;true&#039; : &#039;false&#039;);
 update_user_option($userID, "show_admin_bar_backend", $show_admin_bar_backend);
}
add_action( &#039;personal_options_update&#039;, &#039;askapache_adminbar_handle_post&#039;, 10, 1);
add_action( &#039;edit_user_profile_update&#039;, &#039;askapache_adminbar_handle_post&#039;, 10, 1);
</pre>




<h3>Remove admin_bar from backend</h3>
<p>Now we need to hook into <code>init</code> to either show/hide the admin_bar while in the backend (<code>in_admin()</code>) based on the users preference.</p>
<ol>
<li>Fetches the users preference for showing the admin_bar in the backend</li>
<li>Removes the wp_admin_bar class from even loading (<code>wp_admin_bar_class</code> filter)</li>
<li>Returns false to the <code>show_admin_bar</code> filter</li>
<li>Overrules the <code>admin-bar</code> css applied to the body</li>
</ol>
<pre>
function askapache_adminbar_personal_options_init()
{
 global $wpdb, $wp_query, $current_user;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $current_user-&gt;ID );
 if(!$show_admin_bar_backend &amp;&amp; is_admin())
 {
  add_filter(&#039;wp_admin_bar_class&#039;, create_function(&#039;&#039;, &#039;return "none".rand(1000,666666);&#039;), 9999999);
  add_filter(&#039;show_admin_bar&#039;, create_function(&#039;&#039;, &#039;return false;&#039;), 999999);
  add_action(&#039;admin_head&#039;, create_function(&#039;&#039;, &#039;echo \&#039;&lt;style type="text/css"&gt;body.admin-bar {padding-top:0 !important;}&lt;/style&gt;\&#039;;&#039;));
 }
}
add_action( &#039;init&#039;, &#039;askapache_adminbar_personal_options_init&#039;,0); 
</pre>

<h2>Add to Core WordPress</h2>
<p>I'm sure this will be added to the dev version of WordPress by someone (volunteers?) and eventually integrated into stable.  Note this was built and used on WordPress 3.4-beta2-20509.</p><p><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"></a><a href="http://www.askapache.com/wordpress/hide-admin-bar.html">Show or Hide WordPress Admin Bar Plugin</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/hide-admin-bar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add CSS Class to body when Sidebar is Present</title>
		<link>http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html</link>
		<comments>http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html#comments</comments>
		<pubDate>Fri, 07 Oct 2011 11:39:23 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=5128</guid>
		<description><![CDATA[<p>Here's the problem I was having while working on a custom theme for a client.  Certain pages, posts, tag pages, archive pages, and custom pages either had the sidebar, or did not have the sidebar.  The main content div <code>#ContentW</code> had a 72% width when the sidebar was present, otherwise it was 96%.  The problem was that I dislike having to do things manually when they can be automated through code.  What I was having to do was manually add/remove page-specific classes to the css file to reflect whether the sidebar was present on that page or not.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html"></a><a href="http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html"><cite>AskApache.com</cite></a></p><p>Here's the problem I was having while working on a custom theme for a client.  Certain pages, posts, tag pages, archive pages, and custom pages either had the sidebar, or did not have the sidebar.  The main content div <code>#ContentW</code> had a 72% width when the sidebar was present, otherwise it was 96%.  The problem was that I dislike having to do things manually when they can be automated through code.  What I was having to do was manually add/remove page-specific classes to the css file to reflect whether the sidebar was present on that page or not.</p>

<h2>body_class()</h2>
<p>WordPress uses a function called <a href="http://codex.wordpress.org/Function_Reference/body_class">body_class()</a> to output page-specific classnames for the <code>&lt;body class=""&gt;</code> tag. So for instance on a single post, body_class includes the class "single" along with others like "post-147" or "page-123" or "category-34" depending on what page it is.</p>
<p>So back to my width problem:  I was having to create css rules for each specific type of page to be applied to the ContentW div to make it either wide (no sidebar) or not.. The following css is for pages that have the sidebar, thus making the <code>#ContentW</code> div only 72% wide.  These include the homepage, single post pages, and a page with the id of 345.</p>
<pre>.home #ContentW,
.single #ContentW,
.page-345 #ContentW { width:72%; }</pre>

<p>What I really would like to do would be to just add a class to body named "withsidebar" that is automatically added to the body class when sidebar.php is included, and is automatically not added when <code>sidebar.php</code> is not included.  Then my css would be so simple:</p>
<pre>#ContentW { float:left; overflow:hidden; width:96%; }
.withsidebar #ContentW { width:72%; }</pre>
<p>Meaning I'm free to include or not include the sidebar on any page or post on the site and the #ContentW width will always be right.</p>


<h2>In the header</h2>
<p>The problem, is that <code>body_class()</code> is executed in the themes header.php file by the <a href="http://codex.wordpress.org/Function_Reference/get_header">get_header()</a> function, which is always called before calling <a href="http://codex.wordpress.org/Function_Reference/get_sidebar">get_sidebar()</a> to include <code>sidebar.php</code>, SO I wasn't able to change the output of <code>body_class()</code> to reflect whether or not <code>sidebar.php</code> had been included or not.  By the time <code>sidebar.php</code> was included, body_class had already been output.</p>

<h2>The Solution for adding a sidebar class</h2>
<p>The solution I came up with is very nice and foolproof, and is only 2 lines of code.  Simply does a basic "search and replace" on the output of get_header, where body_class is executed to replace or remove my own class to the body tag when the sidebar is included.</p>
<pre>&lt;?php
add_action(&#039;wp_head&#039;,create_function("",&#039;ob_start();&#039;));
add_action( &#039;get_sidebar&#039;, create_function(&#039;&#039;,&#039;echo str_replace("&lt;body class=\"","&lt;body class=\"withsidebar ",ob_get_clean());ob_start();&#039;) );
?&gt;</pre>

<h3>Start output buffer in header</h3>
<p>First I started an output buffer with <a href="http://php.net/manual/en/function.ob-start.php">ob_start()</a> (to save the output of get_header) by hooking into the wp_head action which is where body_class is executed.</p>
<pre>add_action(&#039;wp_head&#039;,create_function("",&#039;ob_start();&#039;));</pre>

<p>I prefer to use create_function when possible, but the above is exactly the same as:</p>
<pre>add_action(&#039;wp_head&#039;,&#039;start_sidebar_class_fix_output&#039;);
function start_sidebar_class_fix_output()
{
  ob_start();
}</pre>


<h3>Search and Replace Function in sidebar.php</h3>
<p>Now that the output from wp_header containing the body class is accessible in an output buffer, we need to be able to execute the search and replace ONLY when the sidebar.php file is included.  To do this, I hooked into the get_sidebar action that is called by get_sidebar().  This function created by create_function replaces <code>&lt;body class="</code> with <code>&lt;body class="withsidebar </code> in the $buffer and echos it.  If the search string isn't found it echos the $buffer intact.</p>
<pre>add_action( &#039;get_sidebar&#039;, create_function(&#039;&#039;,&#039;echo str_replace("&lt;body class=\"","&lt;body class=\"withsidebar ",ob_get_clean());ob_start();&#039;) );</pre>
<p>This function simply adds "withsidebar" to the body class by search and replace on the output buffer.  The output buffer passed to the str_replace function by using <a href="http://php.net/manual/en/function.ob-get-clean.php">ob_get_clean()</a> which returns the buffer.  Finally, ob_start is called again to resume output buffering (it will automatically be flushed at EOF), just because I like doing things that way, it's not neccessary to restart the output buffer with ob_start however.</p>




<h2>Enhanced for Multiple Sidebars</h2>
<p>Now then, say you have multiple sidebars like <code>sidebar-left.php</code> and <code>sidebar-right.php</code>, and you want a class added to the body class for every single sidebar that is used?  Or let's decide we want this sidebar class adding-feature as robust and future-proofed as needed (in case you use multiple sidebars or your theme does in the future).</p>
<p>Instead of the code above, use this.  Just paste it into your themes <code>functions.php</code> file or add it to a plugin (paste this in the file <code>/wp-content/plugins/sidebar_class_replace.php</code> and you have yourself a plugin).</p>

<p>This enhanced version still adds the class "withsidebar" to the body class the first time any sidebar is included.  Every additionaly sidebar that is included has a class appended to the body class as well.  Finally, in the wp_footer the search and replace takes place, 1 time no matter how many sidebars.  It even works if you nest get_sidebar calls within other sidebars.</p>
<pre>&lt;?php
&nbsp;
add_action(&#039;wp_head&#039;, create_function("",&#039;ob_start();&#039;) );
add_action(&#039;get_sidebar&#039;, &#039;my_sidebar_class&#039;);
add_action(&#039;wp_footer&#039;, &#039;my_sidebar_class_replace&#039;);
&nbsp;
function my_sidebar_class($name=&#039;&#039;){
  static $class="withsidebar";
  if(!empty($name))$class.=" sidebar-{$name}";
  my_sidebar_class_replace($class);
}
&nbsp;
function my_sidebar_class_replace($c=&#039;&#039;){
  static $class=&#039;&#039;;
  if(!empty($c)) $class=$c;
  else {
    echo str_replace(&#039;&lt;body class="&#039;,&#039;&lt;body class="&#039;.$class.&#039; &#039;,ob_get_clean());
    ob_start();
  }
}
?&gt;</pre>

<h3>Example sidebar.php with multiple sidebars</h3>
<p>Here is an example of a sidebar.php with multiple sidebars.  This would result in the body class having "withsidebar sidebar-top sidebar-special sidebar-bottom" added to it.</p>
<pre>&lt;?php
&nbsp;
&lt;div id="sidebar"&gt;
&nbsp;
&lt;?php get_sidebar( &#039;top&#039; );?&gt;
&lt;?php get_sidebar( &#039;special&#039; );?&gt;
&lt;?php get_sidebar( &#039;bottom&#039; );?&gt;
&nbsp;
&lt;/div&gt;
?&gt;</pre>




<h2>Notes and Thoughts</h2>
<p>I use the development version of WordPress, so this will work on any version of wordpress 1.5.0 to beta, and will definately work for the next 100 versions of wordpress.</p>
<p>I love using <a href="http://php.net/manual/en/function.create-function.php" title="create_function php reference">create_function</a> like this, really as much as I can as it produces more optimized code and optimized execution environments, though it is more confusing to read, especially if you are unfamiliar with it.  I also really find the static variable useful.  Last thought, I really love wordpress's actions and filters and the hooking ability.  Way cool!</p>
<p>Using this basic idea, you are unlimited by what you want to do with your site.  You now know how to change and modify the output produced by wordpress after it is produced, but before it is shown to the browser, the possibilities are exciting.</p><p><a href="http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html"></a><a href="http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html">Add CSS Class to body when Sidebar is Present</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/add-css-class-to-body-sidebar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Ways to Serve PDF Files using Htaccess Cookies, Headers, Rewrites</title>
		<link>http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html</link>
		<comments>http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html#comments</comments>
		<pubDate>Sun, 21 Aug 2011 03:07:53 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Htaccess]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=2328</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html"><img height="60" width="45" src='http://uploads.askapache.com/2007/11/60x45_acrobat_trefoil.gif' alt='Adobe PDF' /></a>FYI, using the <a href="http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html">Mod_Rewrite Variables Cheatsheet</a> makes this example, and all advanced .htaccess code easier to understand.  This demo lets you set a cookie with 1 of 3 values, then you just request the pdf file with a normal link click and get 1 of 3 different responses. This is accomplished with a nice bit of <a href="http://www.askapache.com/htaccess/htaccess.html">.htaccess</a> code.<br class="C" /></p>
<div class="cnote">
<p><strong>Set PDF Viewing Mode</strong> - <kbd id="pdfr">Make a selection, then click the view pdf button.</kbd></p>
<p><span id="pdfi" class="FL btnn">Inline</span> <span id="pdfa" class="FL btnn">Download</span> <span id="pdfs" class="FL btnn">Save As</span> <a class="FL btnn" style="margin-left:10px; border-top:1px solid #96F8AF; background:-moz-linear-gradient(center top , #3E9D43, #6ED766) repeat scroll 0 0 transparent;margin-left:20px;" rel="nofollow" href="http://www.askapache.com/storage/pdf/AskApache-Test.pdf">View PDF using selected mode &#187;</a><br class="C" /></p>
</div>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html"></a><a href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html"><cite>AskApache.com</cite></a></p><p><a class="IFL" id="id10" href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html"></a>FYI, using the <a href="http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html">Mod_Rewrite Variables Cheatsheet</a> makes this example, and all advanced .htaccess code easier to understand.  This demo lets you set a cookie with 1 of 3 values, then you just request the pdf file with a normal link click and get 1 of 3 different responses. This is accomplished with a nice bit of <a href="http://www.askapache.com/htaccess/htaccess.html">.htaccess</a> code.<br /><br />As I explain the htaccess code that achieves this, keep in mind this is merely one simple application for this code.  It's much more advanced than your basic htaccess trick, notice how this htaccess acts like a php script, very unusual..  I really wanted to share this trick after I created it for one of my clients because this is the tip of the iceberg.  Another use would be to display an alternate style sheet depending on a users theme preference.  The coolest thing is that it uses multiple advanced .htaccess ideas.  This code uses mod_headers to set the Content-Disposition header for forcing a download and uses mod_rewrite to: Send different Content-Type headers, Check the value of a cookie, Set environment variables for use later by mod_headers header directive<br class="C" /></p>

<div class="cnote">
<p><strong>Set PDF Viewing Mode</strong> - <kbd id="pdfr">Make a selection, then click the view pdf button.</kbd></p>
<p><span id="pdfi" class="FL btnn">Inline</span> <span id="pdfa" class="FL btnn">Download</span> <span id="pdfs" class="FL btnn">Save As</span> <a class="FL btnn" style="margin-left:10px; border-top:1px solid #96F8AF; background:-moz-linear-gradient(center top , #3E9D43, #6ED766) repeat scroll 0 0 transparent;margin-left:20px;" rel="nofollow" href="http://www.askapache.com/storage/pdf/AskApache-Test.pdf">View PDF using selected mode &raquo;</a><br class="C" /></p>
</div>


<h2>What's Going On</h2>
<p>There are 3 different ways for a server to send a pdf file in response to a request for one.  This causes 3 different ways to open/view the pdf file in the clients browser.</p>
<ol>
<li>The browser display's a <strong>"Save File As"</strong> dialog, allowing you to save the file or open.</li>
<li>The browser opens the pdf file <strong>"Inline"</strong>, opening the pdf file in the browser like a web page.</li>
<li>The browser "<strong>Downloads</strong>" the pdf file automatically as an "<strong>Attachment</strong>" and then causes an external pdf reader program like adobe reader to open the file.</li>
</ol>
<p>Some people prefer to have the option of saving the file to view later, some prefer opening it with an external program, and some just like the pdf file to load right in the browser...  The point is that by using .htaccess, we can let them choose any of the 3 methods and save their preference for all further pdf files requested from our site by that user.</p>





<h2>How It Works</h2>
<p>When you click on one of the 3 demo buttons above, "Inline", "Save As", or "Download", a cookie named <code>askapache_pdf</code> is saved in your browser using the javascript below, with the value being set to which button you clicked.  Then when you request the pdf file the .htaccess code below uses mod_rewrite to read the value of the askapache_pdf cookie, and depending on which was your preference it will send alternate HTTP Headers that control how your browser handles the file.</p>


<h3>Unique HTTP Headers Returned</h3>
<p>When it comes down to it, the following information is the 3 modes.  Notice each one is different, because these headers are the only thing controlling how your browser handles the file.</p>
<h4>Save As Mode (askapache_pdf=s)</h4>
<pre>Content-Disposition: attachment
Content-Type: application/pdf</pre>
<h4>Inline Mode (askapache_pdf=i)</h4>
<pre>Content-Type: application/pdf</pre>
<h4>Download Mode (askapache_pdf=a)</h4>
<pre>Content-Type: application/octet-stream</pre>


<h3>Htaccess Demo File</h3>
<p>For the demo I created the folder /storage/pdf/ and this is the .htaccess file at /storage/pdf/.htaccess</p>
<p>The default Content-Type for .pdf files.  This will make .pdf files default Content-Type header have  the value 'application/pdf' - but the default can be overridden by using RewriteRule with the <code>[T=&#039;different/type&#039;]</code></p>
<pre>AddType application/pdf .pdf</pre>

<p>Turn on the rewrite engine if its already on you dont need this </p>
<pre>RewriteEngine On</pre>

<p>Skip RewriteRules if not .pdf request, like autoindexing. The next [2] RewriteRule directives are specific for .pdf files so if the filename requested does not end in .pdf then the <code>[S=2]</code> instructs the next 2 RewriteRule  directives to be completely skipped.</p>
<pre>RewriteRule !.*\.pdf$ - [S=2]</pre>


<p>The first RewriteCond checks to see if the askapache_pdf cookie is NOT set.  The second RewriteCond checks to see if the askapche_pdf cookie has the value of s, which is the value corresponding to someone clicking the "Save As" button.</p>
<p>The <code>[NC,OR]</code> flag means that if the cookie askapache_pdf does not exist, OR (next cond) if the askapache_pdf cookie does exist and is set to 's' then process the RewriteRule.  If neither cond is true the rewriterule is skipped.</p>
<p>If one of the RewriteCond is true, then the RewriteRule is processed.   The RewriteRule applies to any/all requests (.*) but doesn't rewrite anything (-) This RewriteRule sets an Apache environment variable ASKAPACHE_PDFS to have the value of 1 if either rewritecond is true.  The variable can be checked by any directives following the rewriterule in the whole htaccess file.  The ASKAPACHE_PDFS ends in S because if this variable exists then it means the users preference is 'Save As'</p>
<p>Notice that if the user requested the pdf file without selecting a preference i.e. no cookie exists, then the ASKAPACHE_PDFS variable is still set. This just lets us pick the default preference for them, in this example the default is 'Save As'</p>
<pre>RewriteCond %{HTTP_COOKIE} !^.*askapache_pdf.*$ [NC,OR]
RewriteCond %{HTTP_COOKIE} ^.*askapache_pdf=s.*$ [NC]
RewriteRule .* - [E=ASKAPACHE_PDFS:1]</pre>

<p>The RewriteCond checks the askapache_pdf cookie for the value 'a' which 'a' represents 'Download'</p>
<p>If the cookies value is 'a' then the RewriteRule overrides the default Content-Type from 'application/pdf' set with AddType earlier, to 'application/octet-stream', which is a special content-type that tells the browser that the file cannot be loaded by the browser 'Inline', but must be saved which will be opened by an external viewer depending on browser configuration and plugins.</p>
<pre>RewriteCond %{HTTP_COOKIE} ^.*askapache_pdf=a.*$
RewriteRule .* - [T=application/octet-stream]</pre>

<p>This is superfly.  If the cookie/users-preference was 'Save As' (s) then the RewriteRule above the last one set the environment variable ASKAPACHE_PDFS to have the value 1.  The Header directive here is ONLY processed in that variable ASKAPACHE_PDFS exists.  That is what the end 'env=ASKAPACHE_PDFS' does, it is the condition that must be met or the Header directive is skipped.  If the ASKAPACHE_PDFS environment variable set by RewriteRule does exist then the header directive adds the header '<code>Content-Disposition: attachment</code>' to  the normal Response Headers.  The 'Content-Disposition: attachment' header instructs your browser to present you with the 'Save As' dialog box allowing you to choose whether you want to save or open.</p>
<pre>Header set Content-Disposition "attachment" env=ASKAPACHE_PDFS</pre>






<h2>Javascript used by Demo</h2>
<p>The best place for javascript is quirksmode, here is a definitive article on setting, reading, parsing, etc.. <a title="I am a javascript cookie monster" href="http://www.quirksmode.org/js/cookies.html">COOKIES</a>.</p>
<p>Note, I now prefer using jQuery over my AAJS javascript library.  Also, the whole using cookies aspect is just to highlight some advanced htaccess, you can accomplish this much easier without javascript or cookies.</p>
<pre>if(!gi(&#039;pdfr&#039;))return;
var pdfr=gi(&#039;pdfr&#039;);
var cval=getCookie(&#039;askapache_pdf&#039;);
&nbsp;
if(cval==&#039;i&#039;){pdfr.innerHTML=&#039;Currently set to "Inline".&#039;;}
else if(cval==&#039;a&#039;){pdfr.innerHTML=&#039;Currently set to "Download" mode.&#039;;}
else if(cval==&#039;s&#039;){pdfr.innerHTML=&#039;Currently set to "Save As" mode.&#039;;}
&nbsp;
addMyEvent(gi(&#039;pdfi&#039;),"mousedown",function(){
  setCookie("askapache_pdf", "i", "", "/", "www.askapache.com"); gi(&#039;pdfr&#039;).innerHTML = &#039;Changed mode to "Inline".&#039;; return false; });
addMyEvent(gi(&#039;pdfa&#039;),"mousedown",function(){
  setCookie("askapache_pdf", "a", "", "/", "www.askapache.com"); gi(&#039;pdfr&#039;).innerHTML = &#039;Changed mode to "Download".&#039;; return false; });
addMyEvent(gi(&#039;pdfs&#039;),"mousedown",function(){
  setCookie("askapache_pdf", "s", "", "/", "www.askapache.com"); gi(&#039;pdfr&#039;).innerHTML = &#039;Changed mode to "Save As".&#039;; return false; });</pre>

<h2>Alternative Method - No Cookies + PHP</h2>
<p>This is what I came up with first for my client, and then while programming the php I noticed.. Hey!  I think I can do the same thing using .htaccess, which would save me on cpu/memory/potential security/etc.. but this works great too.  Though you will need to hack the code to get it working probably..</p>
<p>Note that the .htaccess rewrite code I used here used FILENAME-i.pdf or FILENAME-s.pdf to pass the preference to the pdf-dl.php script, it also worked for FILENAME.pdf?i=i</p>

<h3>pdf-dl.php</h3>
<pre>&lt;?php
if (
  !isset($_GET[&#039;file&#039;])
  || ($f=$_GET[&#039;file&#039;])===false
  || ($fp=@fopen($f,"rb"))===false
  || ($fi=pathinfo($f))===false
  || ($fi[&#039;fsize&#039;]=filesize($f))===false
  || strtolower($fi["extension"])!=&#039;pdf&#039;
) die(&#039;Failed&#039;);
&nbsp;
ob_start();
header(&#039;Accept-Ranges: bytes&#039;);
header("Content-Length: {$fi[&#039;fsize&#039;]}");
header(&#039;Content-Type: application/pdf&#039;);
if(!isset($_GET[&#039;i&#039;])) header("Content-Disposition: attachment; filename=\"{$fi[&#039;basename&#039;]}\"");
&nbsp;
$sent = 0;
while ( !feof($fp) &amp;&amp; $sent &lt; $fi[&#039;fsize&#039;] &amp;&amp; ($buf = fread($fp, 8192)) != &#039;&#039; ){
  echo $buf;
  $sent += strlen($buf);
  flush();  ob_flush();
}
fclose($fp);
exit;
?&gt;</pre>


<h3>Alternate Method .htaccess</h3>
<p>Deny direct request to pdf-dl.php file</p>
<pre>RewriteCond %{THE_REQUEST} ^.*pdf-dl\.php.*$ [NC]
RewriteRule .* - [F]</pre>
<p>Handle PDF files named anything-i.pdf as inline</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^/]*)-i\.pdf$  /cgi-bin/pdf-dl.php?i=i&amp;file=%{DOCUMENT_ROOT}/storage/pdf/$1.pdf [L,NC,QSA,S=1]</pre>
<p>Handle PDF files without -i.pdf as attachments</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^/]*)\.pdf$  /cgi-bin/pdf-dl.php?file=%{DOCUMENT_ROOT}/storage/pdf/$1.pdf [L,NC,QSA]</pre>




<h2>More Info</h2>
<p>The following is more information about the Content-Dispositon header and related subjects for fast readers.</p>

<h3>Interesting Reading</h3>
<p>Here is the thread of the original draft proposal for the Content-Disposition header.</p>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03620.html">Content-Disposition Header</a>, <em>Rens Troost - 22 Jun 1993</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03629.html">Re: Content-Disposition Header</a>, <em>Nathaniel Borenstein</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03630.html">Re: Content-Disposition Header</a>, <em>Gabe Beged-Dov</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03631.html">Re: Content-Disposition Header</a>, <em>Rens Troost</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03635.html">Re: Content-Disposition Header</a>, <em>Gabe Beged-Dov</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03641.html">Content-Disposition Header and multipart/alternative</a>, <em>Rens Troost</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03645.html">Re: Content-Disposition Header and multipart/alternative</a>, <em>Nathaniel Borenstein</em></li>
</ul>
</li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03632.html">Re: Content-Disposition Header</a>, <em>Keith Moore</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03633.html">Re: Content-Disposition Header</a>, <em>Nathaniel Borenstein</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03634.html">Re: Content-Disposition Header</a>, <em>Ed Levinson (Contractor)</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03636.html">Re: Content-Disposition Header</a>, <em>Keith Moore</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03640.html">Re: Content-Disposition Header</a>, <em>Rens Troost</em></li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03650.html">Re: Content-Disposition Header</a>, <em>Harald Tveit Alvestrand</em></li>
</ul>
</li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03621.html">Re: Content-Disposition Header</a>, <em>Steve Dorner</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03622.html">Re: Content-Disposition Header</a>, <em>Rens Troost</em>
<ul>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03624.html">Re: Content-Disposition Header</a>, <em>Keith Moore</em></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://www.imc.org/ietf-822/old-archive1/msg03652.html">Re: Content-Disposition Header</a>, <em>Carlyn M. Lowery</em></li>
</ul>
</li>
</ul>
</li>
</ul>



<h3>Intense Reading</h3>
<ul>
<li><a href="http://www2.roguewave.com/support/docs/leif/sourcepro/html/protocolsug/10-1.html">Using the MIME Headers Effectively</a></li>
<li><a href="http://www.iana.org/assignments/mail-cont-disp">Mail Content Disposition Values and Parameters</a></li>
<li><cite><a href="http://rfc.askapache.com/rfc1766/rfc1766.txt">Tags for the Identification of Languages</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1436/rfc1436.txt">The Internet Gopher Protocol (a distributed document search and retrieval protocol)</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1630/rfc1630.txt">Universal Resource Identifiers in WWW</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1738/rfc1738.txt">Uniform Resource Locators (URL)</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1866/rfc1866.txt">Hypertext Markup Language - 2.0</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1945/rfc1945.txt">Hypertext Transfer Protocol -- HTTP/1.0</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2045/rfc2045.txt">Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1123/rfc1123.txt">Requirements for Internet Hosts -- Communication Layers</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc822/rfc822.txt">Standard for The Format of ARPA Internet Text Messages</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1808/rfc1808.txt">Relative Uniform Resource Locators</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1036/rfc1036.txt">Standard for Interchange of USENET Messages</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc977/rfc977.txt">Network News Transfer Protocol</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2047/rfc2047.txt">MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1867/rfc1867.txt">Form-based File Upload in HTML</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc821/rfc821.txt">Simple Mail Transfer Protocol</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1590/rfc1590.txt">Media Type Registration Procedure</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc959/rfc959.txt">File Transfer Protocol</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1700/rfc1700.txt">Assigned Numbers</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1737/rfc1737.txt">Functional Requirements for Uniform Resource Names</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1864/rfc1864.txt">The Content-MD5 Header Field</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1900/rfc1900.txt">Renumbering Needs Work</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1952/rfc1952.txt">GZIP file format specification version 4.3</a></cite></li>
<li><cite>Improving HTTP Latency</cite></li>
<li><cite><a href="http://www.isi.edu/touch/pubs/http-perf96/">Analysis of HTTP Performance</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1305/rfc1305.txt">Network Time Protocol (Version 3) Specification, Implementation and Analysis</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1951/rfc1951.txt">DEFLATE Compressed Data Format Specification version 1.3</a></cite></li>
<li><cite><a href="http://sunsite.unc.edu/mdma-release/http-prob.html">Analysis of HTTP Performance Problems,</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1950/rfc1950.txt">ZLIB Compressed Data Format Specification version 3.3</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2069/rfc2069.txt">An Extension to HTTP: Digest Access Authentication</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2068/rfc2068.txt">Hypertext Transfer Protocol -- HTTP/1.1</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2119/rfc2119.txt">Key words for use in RFCs to Indicate Requirement Levels</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc1806/rfc1806.txt">Communicating Presentation Information in Internet Messages: The Content-Disposition Header</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2145/rfc2145.txt">Use and Interpretation of HTTP Version Numbers</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2076/rfc2076.txt">Common Internet Message Headers</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2279/rfc2279.txt">UTF-8, a transformation format of Unicode and ISO-10646</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2046/rfc2046.txt">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2277/rfc2277.txt">IETF Policy on Character Sets and Languages</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2396/rfc2396.txt">Uniform Resource Identifiers (URI): Generic Syntax and Semantics</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2617/rfc2617.txt">HTTP Authentication: Basic and Digest Access Authentication</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2110/rfc2110.txt">MIME E-mail Encapsulation of Aggregate Documents, such as HTML (MHTML)</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2026/rfc2026.txt">The Internet Standards Process -- Revision 3</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2324/rfc2324.txt">Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2049/rfc2049.txt">Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples</a></cite></li>
<li><cite><a href="http://rfc.askapache.com/rfc2183/rfc2183.txt">Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field</a></cite></li>
</ul><p><a href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html"></a><a href="http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html">3 Ways to Serve PDF Files using Htaccess Cookies, Headers, Rewrites</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/pdf-cookies-headers-rewrites.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>HOWTO: Uninstall CPANEL over SSH</title>
		<link>http://www.askapache.com/hacking/uninstall-cpanel.html</link>
		<comments>http://www.askapache.com/hacking/uninstall-cpanel.html#comments</comments>
		<pubDate>Mon, 04 Jul 2011 18:55:40 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4404</guid>
		<description><![CDATA[<p>The following is just a quick reference of some of the commands I used to successfully uninstall cpanel.  This is for advanced users of the shell.  If you aren't that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren't 100% sure you won't run into problems, you should contact your hosts technical support - but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, you are just a drop in their bucket.</p>

<blockquote cite="http://www.askapache.com/server-administration/uninstall-cpanel.html#comment-168222">
<p><strong>Wow!</strong></p>
<p>You sure gotta bigger set that *I* do. . . . - for real! I've been known to do some abysmally stupid things in my day - and actually had them work the way I wanted them to! - but this takes the <strong>titanium, gadolinium, rhodium alloy cake</strong>!</p>
<p>Me, I'd try something like that and find out later that the fire-trucks showed up right after I hit the "Enter" key. It's a REALLY interesting post, and a real eye-opener - especially for someone who is relatively new to the whole web-hosting-service paradigm.  I know, no guts, no glory - but THIS is WAY over the top!  I'm reading this and thinking <em>"Why not just put a couple of sticks of dynamite under the thing?"</em></p>
<p>Seriously now, this was an excellent read - and for someone who is just now looking into the whole web-hosting paradigm, it's a real eye-opener.  Though I think I'll just tiptoe past this <strong>REAL QUIETLY</strong> for now. . . .  (laughing!)</p>
<p><a href="http://www.qatechtips.com/">Jim</a></p>
</blockquote>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/hacking/uninstall-cpanel.html"></a><a href="http://www.askapache.com/hacking/uninstall-cpanel.html"><cite>AskApache.com</cite></a></p><p><strong>WARNING!</strong> This is for advanced users of the shell, this is NOT a howto or tutorial.  The thing is, I googled <strong>how to uninstall cpanel</strong> and for once in my life I came up empty.. And certainly the cpanel official sites themselves don't provide any instructions other than to say "Dont uninstall it, reinstall your entire operating system without it."..   they sure don't seem confident that they know exactly what their code is doing.  Cpanel is great for most people, perfect for many situations, so don't get me wrong.. this is just for fun.</p>

<h2>Why Uninstall?</h2>
<p>Why?  Because I have always built my servers, php installations, perl installs, ruby, iptables, everything from source.  I read the INSTALL/README docs, I read the man pages, and I read the info pages as well.  I google for configuration advice, I google for tips, and I don't need a web-based perl script messing my stuff up!</p>
<p>The main problems I had with cpanel, which really is a great bit of software for millions of website developers, is that it was incredibly sneaky!  I used it for about 6 months and spent that entire time trying to figure out what the heck it was doing.  A couple issues that I really disliked, it takes over your bind install, it takes over your apache install, it takes over your php install.  And although it does let you configure some things (very few) for custom configurations and the like, I just don't need any of that.  By removing the darn thing I am saving GIGS of space on my server, tons of bandwidth, and most importantly to me I am saving CPU and processing time along with RAM and IO speed.</p>
<h3>Anything Else</h3>
<p>Please.. I could go on for DAYS!  Another reason I have wanted to be rid of cpanel is that I like my servers to be as lean and mean as possible.  This means I like as few files and processes as possible.  There are many benefits to this, like it's much easier for my integrity checking software and rootkit/antivirus software to run and drastically reduces the false positives.  And there is that glaring security issue of constantly having cpanel run it's own software to create the WHM/Cpanel web interface, which is accessible online.  I haven't researched cpanel security at all, it's possible that it never has security problems that are published, but for me, why take the chance?</p>


<h2>Warning - Caution!</h2>
<p>The following is just a quick reference of some of the commands I used to uninstall cpanel.  This is for advanced users of the shell.  If you aren't that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren't 100% sure you won't run into problems, you should contact your hosts technical support - but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, and the last thing tech support wants is to fix a server broken by someone who doesn't know what they are doing.</p>

<h2>Last Warning!</h2>
<p>Unless you understand what theses commands do and the purpose they serve, do not try any of this.  These are not the exact commands I used verbatim, they are also not in order.  I only put them up here because I was so amazed that google didn't have any uninstall cpanel intructions.  Hopefully it's not a conspiracy that will get my site taken down.. ;)</p>
<p>That said and out of the way, it really only took me about 10 minutes to uninstall cpanel completely.  But keep in mind I have been closely monitoring and debugging cpanel for 6 months, so I knew what I was doing.  And finally, I do apologize for not having better instructions.. but hey, if you don't get this then you have no business trying to figure out how to uninstall cpanel!  It's great software and shouldn't be removed unless you are fully capable of managing email/dns/www/ftp and any/all other servers and services on your machine by hand.</p>

<h2>Do This First</h2>
<p>I have a few drafts I'm working on at the moment with specifics, but for now you will have to figure it out with google.  Basically you want to make sure you don't totally knock your machine offline without being able to reconnect.  What I do is compile a static version of openssh and a few other security-type shell tools, and configure this binary sshd to run by using inittab, which is the file run by init (pid 1) and makes sure if it dies it is restarted.  Here is my /etc/inittab to run the static sshd binary:</p>
<pre>hh:12345:respawn:/failover/os/sbin/aassh -D -q -u0 -f /failover/os/etc/aassh</pre>

<p>Another trick is to keep a detached screen logged in to root.  That way if you mess up your sudoers or securetty or pam or whatever, you can just reattach and fix it.</p>
<p>Finally, you may want to setup your syslog to start earlier than usual, and set up more than normal verbosity.  ( I take it to the max ).  Then you should setup a 2nd server or machine somewhere to act as a syslog server.  Lastly, configure your web server syslog to copy all messages to the remote syslog you set up.  I use a reverse ssh tunnel to encrypt the syslog packets, but when I do something serious like reboot after uninstalling cpanel, I prepare for it by adding additional networking routes on my machine to make sure I will get some logs even if sshd cant start or even if my network addresses aren't brought up correctly.</p>
<p>If that sounds easy to you, please continue.   If you are saying: Wha??? Continue in read-only mode.</p>

<p class="cnote">Also, you can't just uninstall cpanel, I have replaced a lot of cpanel already, like building my own bind, apache, php, syslog and making sure they work and aren't being tampered with by cpanel.  Basically cpanel runs everything on your server in most cases, so you should prepare by creating your own static software to replace cpanel, and make sure it works.</p>


<h2>Find files Accessing /var/cpanel</h2>
<p>More than likely these will need to be killed.</p>
<pre>lsof +w -Rg -nP +c15 -x f +D /var/cpanel
lsof +w -Rg -nP +c15 -x f +D /usr/local/cpanel</pre>

<h2>Killing cpanel</h2>
<p>Just an example, your machine may have a lot more than these, I have been slowly taking control of my machine back from cpanel for 6 months, so it was easier for me.</p>
<pre>for P in tailwatchd queueprocd cpanellogd exim; do pkill -9 $P; done</pre>

<h2>Commands and Shortcuts</h2>
<pre>alias NF=&#039;nice find $PWD -mount -depth ! -type d&#039;
alias NFF=&#039;nice find $PWD -mount -depth ! -type d | xargs -IF87 file F87&#039;
alias NA=&#039;nice find $PWD -mount -depth&#039;
alias NAF=&#039;nice find $PWD -mount -depth | xargs -IF87 file F87&#039;</pre>


<h2>Watch out for crontab</h2>
<p>An example of the sneakiness (from my POV, from most it's called builtin robustness) that cpanel does is automagically adding crontab entries that make it behave similarly to a self-propagating virus.  If you don't disable the cronjobs and kill the right processes within a short period of time, be prepared for a magic resurrection.</p>

<p>Here's my awesome crontab information function, you will need to check every file, it lists the default crons on my box, and every users crontab, but it can't account for other cron software like at and other crons.</p>
<pre>function askapache_crontab()
{
  local GG i;
  for i in `getent passwd|cut -d ":" -f1`;
  do
    GG=$(sudo crontab -u $i -l 2&gt;$N6 | tr -s &#039;\n\000&#039; | sed &#039;/^#/d&#039;);
    [[ ${#GG} -gt 3 ]] &amp;&amp; sleep 1 &amp;&amp; echo -e "$i \n\n${GG}"
  done;
   sleep 4;
   ls -aLls1ch --color=always /etc/cron.{hourly,daily,weekly,monthly,d} | sed &#039;/^total/d; /\ drwxr-xr-x/d&#039;;
}</pre>



<pre>grep -ir /var/spool cpan</pre>
<pre>#6 3 * * * /scripts/upcp
#0 1 * * * /scripts/cpbackup
#0 2 * * * /scripts/mailman_chown_archives
#35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check &amp;&amp; /usr/local/cpanel/bin/tail-check
#11,26,41,56 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue &gt; /dev/null 2&gt;&amp;1
#30 */4 * * * /usr/bin/test -x /scripts/update_db_cache &amp;&amp; /scripts/update_db_cache
#45 */8 * * * /usr/bin/test -x /usr/local/cpanel/bin/optimizefs &amp;&amp; /usr/local/cpanel/bin/optimizefs
#*/5 * * * * /usr/local/cpanel/bin/dcpumon &gt;/dev/null 2&gt;&amp;1
#25 1 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl --notify</pre>



<h2>Delete Crontabs</h2>
<pre>sudo crontab -u mailman -r</pre>


<h2>Find INIT scripts with cpanel</h2>
<p>This is the main startup script: <code>/usr/local/cpanel/etc/init/startup</code></p>
<p>I had no idea ruby-on-rails was being controlled by cpanel.. sneaky bugger.  You can tell by all of these advanced unix commands just how difficult it would be to uninstall cpanel, its totally like the Alien!</p>
<pre>(1:3744)# find . ! -type d -print0|xargs -0 -I&#039;F87&#039; grep -Hi "cpan\|tailwat\|chkser" F87
./fastmail:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./httpd:        HTTPD=/usr/local/cpanel/bin/chroothttpd
./cpanel:# cpanel8       Start Cpanel Services
./cpanel:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./cpanel:# description: This is the cpanel webserver and chat.
./cpanel:# processname: cpaneld
./cpanel:# pidfile: /var/run/cpanel.pid
./cpanel:[ -f /usr/local/cpanel/etc/init/startup ] || exit 0
./cpanel:       if [ -f "/var/cpanel/smtpgidonlytweak" ]; then
./cpanel:       echo -n "Starting cPanel services: "
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpsrvd
./cpanel:       echo -n "Starting cPanel brute force detector services: "
./cpanel:       daemon /usr/local/cpanel/etc/init/startcphulkd
./cpanel:    echo -n "Starting cPanel dav services: "
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpdavd
./cpanel:               daemon /usr/local/cpanel/etc/init/startcppop
./cpanel:       echo -n "Starting cPanel Chat services: "
./cpanel:               daemon /usr/local/cpanel/entropychat/entropychat
./cpanel:               daemon /usr/local/cpanel/bin/startmelange
./cpanel:                       /usr/local/cpanel/bin/startinterchange
./cpanel:       echo -n "Starting cPanel ssl services: "
./cpanel:       daemon /usr/local/cpanel/startstunnel
./cpanel:    echo -n "Starting cPanel Queue services: "
./cpanel:       daemon /usr/local/cpanel/etc/init/startqueueprocd
./cpanel:    echo -n "Starting tailwatchd: "
./cpanel:    daemon /usr/local/cpanel/libexec/tailwatchd --start
./cpanel:       echo -n "Starting cPanel Log services: "
./cpanel:       daemon /usr/local/cpanel/cpanellogd
./cpanel:    action "Starting mailman services: " /usr/local/cpanel/etc/init/startmailman
./cpanel:    action "Stopping tailwatchd: " /usr/local/cpanel/libexec/tailwatchd --stop
./cpanel:    action "Stopping cPanel services: " /usr/local/cpanel/etc/init/stopcpsrvd
./cpanel:       action "Stopping cPanel dav services: " /usr/local/cpanel/etc/init/stopcpdavd
./cpanel:       action "Stopping cPanel queue services: " /usr/local/cpanel/etc/init/stopqueueprocd
./cpanel:       action "Stopping cPanel brute force detector services: " /usr/local/cpanel/etc/init/stopcphulkd
./cpanel:               action "Stopping pop3 services: " /usr/local/cpanel/etc/init/stopcppop
./cpanel:       echo -n "Stopping cPanel log services: "
./cpanel:       killproc cpanellogd
./cpanel:       echo -n "Stopping cPanel Chat services: "
./cpanel:       action "Stopping cPanel ssl services: " /usr/local/cpanel/etc/init/stopstunnel
./cpanel:       action "Stopping mailman services: " /usr/local/cpanel/etc/init/stopmailman
./cpanel:       if [ -e "/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl" ]; then
./exim:if [ -e "/etc/chkserv.d" ]; then
./exim:        for file in `ls /etc/chkserv.d`
./exim:            if [ ! -e "/usr/local/cpanel/libexec/tailwatchd" ]; then
./exim:    if [ -x "/usr/local/cpanel/etc/init/startspamd" ]; then
./exim:        /usr/local/cpanel/etc/init/startspamd
./exim:        if [ ! -e "/usr/local/cpanel/libexec/tailwatchd" ]; then
./ror:  /usr/local/cpanel/bin/rormgr --startboot
./ror:  /usr/local/cpanel/bin/rormgr --stopall
./ror:  /usr/local/cpanel/bin/rormgr --stopall
./ror:  /usr/local/cpanel/bin/rormgr --startboot
./ror:  /usr/local/cpanel/bin/rormgr --statusall
./securetmp:# Author:       cPanel, Inc. &lt;copyright@cpanel.net&gt;</pre>

<h3>Turn off cpanel services</h3>
<p>You should remove the below delete command and start by just disabling the inits by turning them off.  Then reboot. Then delete.  If your machine won't reboot, I told you so, Cpanel told you so, and likely your host told you so.</p>
<pre>for S in cpanel ror securetmp fastmail exim; do R=$(command chkconfig --level 123456 $S off ||echo); R=$(command chkconfig --del $S ||echo); done</pre>


<h4>HTTPD</h4>
<p>If you are running chrooted httpd then you'll need to make sure you don't delete your entire webserver on accident.  Here's a relevant part from the /etc/init.d/httpd script.</p>
<pre># the path to your httpd binary, including options if necessary
if [ -e "/etc/chroothttpd" ]; then
        HTTPD=/usr/local/cpanel/bin/chroothttpd
else
        HTTPD=/usr/local/apache/bin/httpd
fi</pre>




<h2>Finding files owned by cpanel</h2>
<p>Some super cool bash commands in this post.. let's start with one to find all the files and folders on your machine owned by cpanel.  Check your /etc/passwd file for your machines specific usernames and groups.  This command saves all the filenames to ~/cpanel-files-backup.txt, which is used by tar next to create a backup of all of them.</p>
<pre>{ find / -mount -depth -maxdepth 150 \( -group cpanel -o   -group cpanel-phpmyadmin -o -group cpanel-phppgadmin   -o -group cpanelphpmyadmin   -o -group cpanelphppgadmin   -o -group cpanelhorde   -o -group cpanelroundcube \) -print; find / -mount -depth -maxdepth 150 \( -user cpanel -o   -user cpanel-phpmyadmin -o -user cpanel-phppgadmin   -o -user cpanelphpmyadmin   -o -user cpanelphppgadmin   -o -user cpanelhorde   -o -user cpanelroundcube \) -print; } &gt; ~/cpanel-files-backup.txt</pre>

<p>Here's another way to search directories.</p>
<pre> grep --color=always -Hir cpanel /var</pre>

<h2>Create the Backup</h2>
<p>Note that you must have the latest version of tar for this exact command, also you should backup /var/cpanel and /usr/local/cpanel and /etc and heck the whole machine why dontcha!</p>
<pre>tar -T ~/cpanel-files-backup.txt -cvz --checkpoint=1000 --checkpoint-action="ttyout=\rHit %s checkpoint #%u" -f /cpanel-files-backup.tgz --totals</pre>


<h2>Remove Files</h2>
<p>Once you do this your upstream without a paddle, you better make sure you know what you're doing with this.  This removes all those files.</p>
<pre>cat ~/cpanel-files-backup.txt | xargs -I&#039;F87&#039; rm -vfr F87</pre>

<p>Additionally you will want to remove /usr/local/cpanel and /var/cpanel - What I always do when running as root is alias my rm command to instead simply move the files to a .trash folder.  That way if something goes bork you have a better chance at fixing it.</p>


<h2>Find Group-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \
\(  -group cpanel -o \
  -group cpanel-phpmyadmin \
  -o -group cpanel-phppgadmin \
  -o -group cpanelphpmyadmin \
  -o -group cpanelphppgadmin \
  -o -group mailman \
  -o -group cpanelhorde \
  -o -group cpanelroundcube \
\) -fprintf /root/cpanel-group-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>

<h2>Find User-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \(
  -user cpanel \
  -o -user cpanel-phpmyadmin \
  -o -user cpanel-phppgadmin \
  -o -user cpanelphpmyadmin \
  -o -user cpanelphppgadmin \
  -o -user mailman \
  -o -user cpanelhorde \
  -o -user cpanelroundcube
\) -fprintf /root/cpanel-users-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>



<pre>       4  0755  drwxr-xr-x     cpanel:cpanel     32002:32004 /var/cpanel/userhomes/cpanel cpanel d reiserfs
       4  0700  drwx------ cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/tmp tmp d reiserfs
       4  0644  -rw-r--r-- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx------ cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx------ cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx------ cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x--- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/mail mail d reiserfs
       4  0711  drwx--x--x cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin cpanel-phpmyadmin d reiserfs
       4  0700  drwx------ cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/sessions sessions d reiserfs
       4  0644  -rw-r--r-- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx------ cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx------ cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx------ cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x--- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/mail mail d reiserfs
       4  0711  drwx--x--x cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin cpanelphppgadmin d reiserfs
       4  0750  drwxr-x--- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/mail mail d reiserfs
       4  0700  drwx------ cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/sessions sessions d reiserfs
       4  0711  drwx--x--x cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube cpanelroundcube d reiserfs
       4  0644  -rw-r--r--     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx------     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx------     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches caches d reiserfs
       4  0700  drwx------     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel .cpanel d reiserfs
       4  0700  drwx------ cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/tmp tmp d reiserfs
       4  0700  drwx------ cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/log log d reiserfs</pre>


<h3>Find Permissions</h3>
<pre>cat ~/cpanel-group-files.log ~/cpanel-users-files.log |tr -s &#039;\000 \t&#039;|cut -d&#039; &#039; -f3|sort -u</pre>






<h3>Find files tailwatchd</h3>
<pre>(1:3732)# $NICE find ${1:-`pwd`} -mount -name &#039;*tailwatch*&#039;
/usr/local/cpanel/libexec/tailwatchd
/usr/local/cpanel/libexec/tailwatch
/usr/local/cpanel/libexec/tailwatch/tailwatchd
/usr/local/cpanel/etc/init/scripts/freebsd/tailwatchd.sh
/usr/local/cpanel/etc/init/scripts/trustix/tailwatchd
/usr/local/cpanel/etc/init/scripts/centos/tailwatchd
/usr/local/cpanel/etc/init/scripts/suse/tailwatchd
/usr/local/cpanel/etc/init/scripts/caos/tailwatchd
/usr/local/cpanel/etc/init/scripts/whitebox/tailwatchd
/usr/local/cpanel/etc/init/scripts/mandrake/tailwatchd
/usr/local/cpanel/etc/init/scripts/debian/tailwatchd
/usr/local/cpanel/etc/init/scripts/redhat/tailwatchd
/usr/local/cpanel/etc/init/scripts/fedora/tailwatchd
/usr/local/cpanel/etc/init/stoptailwatchd
/usr/local/cpanel/etc/init/starttailwatchd
/usr/local/cpanel/bin/tailwatchd
/usr/local/cpanel/logs/tailwatchd_log
/var/log/cpanel/tailwatchd_log
/var/cpanel/log_rotation/cp_tailwatchd_log.cpanellogd
/var/cpanel/tailwatch.positions
/var/run/tailwatchd.pid
/etc/chkserv.d/tailwatchd
/scripts/restartsrv_tailwatchd</pre>


<h2>Delete cpanel Users/Groups</h2>
<pre>for U in cpanel-phpmyadmin cpanel-phppgadmin cpanelphpmyadmin cpanelphppgadmin cpanelhorde cpanelroundcube machbuild; do userdel -fr $U; groupdel $U; done</pre>

<h2>Check for broken symlinks</h2>
<pre>find / -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;</pre>
<p>Especially check /etc</p>
<pre>$ find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;
/etc/ftpd-rsa.pem                   broken symbolic link to `/var/cpanel/ssl/ftp/ftpd-rsa.pem&#039;
/etc/rc.d/rc1.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc1.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc1.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc3.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc6.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc5.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc2.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc2.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc2.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc4.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc4.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc4.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc0.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/authlib/authProg               broken symbolic link to `/usr/local/cpanel/bin/courier-auth&#039;</pre>

<p>And delete if you are sure</p>
<pre>find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039; |cut -d&#039; &#039; -f1|xargs -I&#039;F87&#039; rm -rvf &#039;F87&#039;</pre>


<h2>Reinstall CSF</h2>
<p>The only thing I actually used that came with cpanel is the CSF/LFD Firewall package, which is a fantastic piece of software.  I had to reinstall this, and to get it working without cpanel add the following line to the csf.conf</p>
<pre>GENERIC = "1"</pre>

<h2>Thats It</h2>
<p>Now once you've cleaned up everything, you should try everything conceivable to get an error before rebooting.  Like you should start and stop every service in /etc/init.d/, you should use telinit to check various runlevels (which keeps your sshd connection still live).  Go all out, should take at least a full hour.</p>
<p>Another thing I like to do is rebuild alot of my source-built software again in case anything got messed up.  I upgrade perl from cpanels 5.8.8 to 5.10, which is pretty thorough, and you know, reinstall anything else I think I might need.  One of the benefits of compiling your own software is all I have to do is cd to the source directory and type <code>make -B &amp;&amp; ( { make test || make check || make checks || make tests; } || echo  ) &amp;&amp; sudo make install</code> and that's it.  The tests/checks are optional of course.</p>


<p>If anyone actually ever reads this and does it, please share your advice here.. everybody knows we need it!  Good Luck</p><p><a href="http://www.askapache.com/hacking/uninstall-cpanel.html"></a><a href="http://www.askapache.com/hacking/uninstall-cpanel.html">HOWTO: Uninstall CPANEL over SSH</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/uninstall-cpanel.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Terminal Escape Code Zen</title>
		<link>http://www.askapache.com/linux/zen-terminal-escape-codes.html</link>
		<comments>http://www.askapache.com/linux/zen-terminal-escape-codes.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 04:00:27 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4113</guid>
		<description><![CDATA[<p><strong>An image and technicacl achievement so profound, it will touch yoour heart</strong>..        So 3D... it'll hurt you eyes!  LOL..  lol.. Man I am cracking up here.  haha  Ha definately the best intro ever, those really do look 3D for terminal though huh.. Sweet.  Here is the little function I wrote to output that grey marble.</p>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3db.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="795" height="481" class="alignnone size-full wp-image-4886" /></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"></a><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><cite>AskApache.com</cite></a></p><h3>Lightning Strikes Twice!</h3>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3da.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="892" height="375" class="alignnone size-full wp-image-4885" /></a></p>
<p>LOL.. </p>
<h2>3rd Dimension Broken with Bash!</h2>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3db.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="795" height="481" class="alignnone size-full wp-image-4886" /></a></p>
<p><strong>So 3D... it'll hurt you eyes!</strong>  lol.. Man I am cracking up here.   Ha but seriously those really do look 3D for terminal though..  I am actually really impressed.   Sweet.  Here is the little function I wrote to output that grey marble.</p>

<p class="cnote">Just a word to the wise, start learning and going over some of these concepts, especially the code used in functions, I will be back in a followup that details actually using this stu.


<p>This function is one of my favorites because it is so fast and useful.  Like when designing a 256color prompt.</p>
<pre>
aa_256 ()
{
    local o x=`tput op` y=`printf %$((${COLUMNS}-6))s`;
    for i in {0..256};
    do
        o=00$i;
        echo -e ${o:${#o}-3:3} `tputm "setaf $i" "setab $i"`${y// /=}$x;
    done
}</pre>



<p>Ya this is actually not very helpful or useful, but there you have it.</p>
<pre>tputm ()
{
    local a;
    for a in "$@";
    do
        echo -en "${a}\n";
    done | tput -S
}</pre>



<p>Some people call this function the grey bringer of death.  Not really.</p>
<pre>a256 ()
{
    ( x=`tput op` y=`printf %$((${COLUMNS}-6))slocal `;
    for i in {242..232} 232 232;
    do
        echo -en "`tput setaf $i;tput setab $i`${y}${x}`tput op`";
    done )
}</pre>



<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348099">Fix screen</a>











<h2>Helpful Ncurses Programs</h2>
<table class="bordered"><tbody><tr class="header"><th>Program Name</th><th>Description</th><th>Example Usage</th></tr>
<tr><td>infotocap</td><td>convert a terminfo description into a termcap description</td><td><code></code></td></tr>
<tr><td>tic</td><td>the terminfo entry-description compiler</td><td><code></code></td></tr>
<tr><td>toe</td><td>table of (terminfo) entries</td><td><code>toe -a|sort -d</code></td></tr>
<tr><td>infocmp</td><td>compare or print out terminfo descriptions</td><td><code>infocmp -a  -L -1 -T -x</code></td></tr>
<tr><td>capconvert</td><td>automated conversion from termcap to terminfo</td><td><code></code></td></tr>
<tr><td>stty</td><td>prints or changes terminal characteristics, such as baud rate.</td><td><code></code></td></tr>
<tr><td>clear</td><td>clears the terminal's screen</td><td><code></code></td></tr>
<tr><td>capconvert</td><td>automated conversion from termcap to terminfo</td><td><code></code></td></tr>
</tbody></table>


<h3>ALWAYS check out my functions!</h3>
<p>This function will print out the terminal, show it's colors, etc..  I have some really nice ones in this article that I use for tmux, screen, and that sort of thing.</p>
<pre>c ()
{
    tput clear;
    pm "$TERM: [colors:`tput colors`/`tput pairs`]";
    RC=`tput op` L1=$(L &#039;=&#039; $(( ${COLUMNS} - 25 )));
    for i in `seq ${1:-0} ${2:-16}`;
    do
        o="  $i";
        echo -e " ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${L1}${RC}";
    done
}</pre>








<h2>Standard Capabilities</h2>
<h4>X.364 and iBCS2</h4>
<ul>
<li><code>\033c</code> - <var>RIS</var> - full reset</li>
<li><code>\0337</code> - <var>SC</var> - save cursor</li>
<li><code>\0338</code> - <var>RC</var> - restore cursor</li>
<li><code>\033[r</code> - <var>RSR</var> - not an X.364 mnemonic</li>
<li><code>\033[m</code> - <var>SGR0</var> - not an X.364 mnemonic</li>
<li><code>\033[2J</code> - <var>ED2</var> - clear page</li>
</ul>

<h4>Specified by ISO 2022</h4>
<ul>
<li><code>\033(0</code> - <var>ISO DEC G0</var> - enable DEC graphics for G0</li>
<li><code>\033(A</code> - <var>ISO UK G0</var> - enable UK chars for G0</li>
<li><code>\033(B</code> - <var>ISO US G0</var> - enable US chars for G0</li>
<li><code>\033)0</code> - <var>ISO DEC G1</var> - enable DEC graphics for G1</li>
<li><code>\033)A</code> - <var>ISO UK G1</var> - enable UK chars for G1</li>
<li><code>\033)B</code> - <var>ISO US G1</var> - enable US chars for G1</li>
</ul>


<h2>ISO 2022 charset switching:</h2>
<ul>
   <li><a href="http://www.iso.ch/cate/d22747.html">ISO/IEC 2022:1994</a> </li>
   <li>"Character code structure and extension techniques" </li>
   <li><a href="http://www.ecma.ch/stand/ECMA-035.HTM">ECMA-035</a> </li>
   <li>code structure
      <ul>
         <li>=00..=1F C0 set of <a href="iso6429.html">control characters</a> </li>
         <li>=20..=7F G0 set of 94 or 96 <a href="iso646.html">graphic characters</a> </li>
         <li>=80..=9F C1 set of control characters "C1 controls" </li>
         <li>=A0..=FF G1 set of 94 or 96 graphic characters </li>
         <li>... G2 and G3 </li>
      </ul>
   </li>
   <li><a href="http://www.iso.ch/infoe/agency/2375.htm">registration authority</a>
      <ul>
         <li><a href="http://www.iso.ch/cate/d7217.html">ISO/IEC 2375:1985</a> Procedure for registration of escape sequences </li>
         <li>"ECMA registry" </li>
         <li>ISO-IR registration number </li>
         <li><a href="ftp://dkuug.dk/i18n/iso2375reg.txt">ftp://dkuug.dk/i18n/iso2375reg.txt</a> </li>
         <li><a href="http://www.itscj.ipsj.or.jp/ISO-IR/practice/practice.html">Internaltional</a> <a href="http://www.itscj.ipsj.or.jp/ISO-IR/">register of coded character sets to be used with escape sequences</a> </li>
         <li><a href="http://www.dkuug.dk/jtc1/sc2/wg3/">ISO/IEC JTC1/SC2/WG3</a> </li>
      </ul>
   </li>
   <li>ISO-2022 terminals from Siemens </li>
   <li>recode iso-2022..<a href="http://web.archive.org/web/czyborra.com/utf/#UTF-8">utf-8</a> not yet
      implemented </li>
   <li><a href="cjk.html">CJK charsets</a>
      <ul>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1458.txt">ISO-2022-JP</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1554.txt">ISO-2022-JP-2</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1557.txt">ISO-2022-KR</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1922.txt">ISO-2022-CN</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1922.txt">ISO-2022-CN-EXT</a> </li>
      </ul>
   </li>
</ul>


<h4>DEC private controls widely supported by emulators</h4>
<ul>
<li><code>\033=</code> - <var>DECPAM</var> - application keypad mode</li>
<li><code>\033&gt;</code> - <var>DECPNM</var> - normal keypad mode</li>
<li><code>\033&lt;</code> - <var>DECANSI</var> - enter ANSI mode</li>
<li><code>\033[!p</code> - <var>DECSTR</var> - soft reset</li>
<li><code>\033 F</code> - <var>S7C1T</var> - 7-bit controls</li>
</ul>


<h3>ECMA modes</h3>
<h4>ISO 2022</h4>
<ul>
<li><code>2</code> - <var>AM</var> - keyboard action mode</li>
<li><code>4</code> - <var>IRM</var> - insert/replace mode</li>
<li><code>12</code> - <var>SRM</var> - send/receive mode</li>
<li><code>20</code> - <var>LNM</var> - linefeed mode</li>
</ul>

<h3>DEC modes</h3>
<ul>
<li><code>1</code> - <var>CKM</var> - application cursor keys</li>
<li><code>2</code> - <var>ANM</var> - set VT52 mode</li>
<li><code>3</code> - <var>COLM</var> - 132-column mode</li>
<li><code>4</code> - <var>SCLM</var> - smooth scroll</li>
<li><code>5</code> - <var>SCNM</var> - reverse video mode</li>
<li><code>6</code> - <var>OM</var> - origin mode</li>
<li><code>7</code> - <var>AWM</var> - wraparound mode</li>
<li><code>8</code> - <var>ARM</var> - auto-repeat mode</li>
</ul>

<h3>ECMA attribute sequences</h3>
<ul>
<li><var>0</var> - <code>NORMAL</code> - normal</li>
<li><var>1</var> - <code>+BOLD</code> - bold on</li>
<li><var>2</var> - <code>+DIM</code> - dim on</li>
<li><var>3</var> - <code>+ITALIC</code> - italic on</li>
<li><var>4</var> - <code>+UNDERLINE</code> - underline on</li>
<li><var>5</var> - <code>+BLINK</code> - blink on</li>
<li><var>6</var> - <code>+FASTBLINK</code> - fastblink on</li>
<li><var>7</var> - <code>+REVERSE</code> - reverse on</li>
<li><var>8</var> - <code>+INVISIBLE</code> - invisible on</li>
<li><var>9</var> - <code>+DELETED</code> - deleted on</li>
<li><var>10</var> - <code>MAIN-FONT</code> - select primary font</li>
<li><var>11</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>12</var> - <code>ALT-FONT-2</code> - select alternate font 2</li>
<li><var>13</var> - <code>ALT-FONT-3</code> - select alternate font 3</li>
<li><var>14</var> - <code>ALT-FONT-4</code> - select alternate font 4</li>
<li><var>15</var> - <code>ALT-FONT-5</code> - select alternate font 5</li>
<li><var>16</var> - <code>ALT-FONT-6</code> - select alternate font 6</li>
<li><var>17</var> - <code>ALT-FONT-7</code> - select alternate font 7</li>
<li><var>18</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>19</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>20</var> - <code>FRAKTUR</code> - Fraktur font</li>
<li><var>21</var> - <code>DOUBLEUNDER</code> - double underline</li>
<li><var>22</var> - <code>-DIM</code> - dim off</li>
<li><var>23</var> - <code>-ITALIC</code> - italic off</li>
<li><var>24</var> - <code>-UNDERLINE</code> - underline off</li>
<li><var>25</var> - <code>-BLINK</code> - blink off</li>
<li><var>26</var> - <code>-FASTBLINK</code> - fastblink off</li>
<li><var>27</var> - <code>-REVERSE</code> - reverse off</li>
<li><var>28</var> - <code>-INVISIBLE</code> - invisible off</li>
<li><var>29</var> - <code>-DELETED</code> - deleted off</li>
</ul>



<h3>Init strings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>is1</var></td><td>init_1string</td></tr>
<tr><td><var>is2</var></td><td>init_2string</td></tr>
<tr><td><var>is3</var></td><td>init_3string</td></tr>
<tr><td><var>rs1</var></td><td>reset_1string</td></tr>
<tr><td><var>rs2</var></td><td>reset_2string</td></tr>
<tr><td><var>rs3</var></td><td>reset_3string</td></tr>
<tr><td><var>smcup</var></td><td>enter_ca_mode</td></tr>
<tr><td><var>rmcup</var></td><td>exit_ca_mode</td></tr>
</tbody></table>

<h3>Cap strings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>so</td><td>String of commands to enter standout mode.</td></tr>
<tr><td>se</td><td>String of commands to leave standout mode.</td></tr>
<tr><td>sg</td><td>Numeric capability, the width on the screen of the magic cookie.  This capability is absent in terminals that record appearance modes character by character.</td></tr>
<tr><td>ms</td><td>Flag whose presence means that it is safe to move the cursor while the appearance modes are not in the normal state.  If this flag is absent, programs should always reset the appearance modes to normal before moving the cursor.</td></tr>
<tr><td>xs</td><td>Flag whose presence means that the only way to reset appearance modes already on the screen is to clear to end of line.  On a per-character terminal, you must clear the area where the modes are set.  On a magic cookie terminal, you must clear an area containing the cookie. See the discussion above.</td></tr>
<tr><td>xt</td><td>Flag whose presence means that the cursor cannot be positioned right in front of a magic cookie, and that seis a command to delete the next magic cookie following the cursor.  See discussion above.</td></tr>
<tr><td>mb</td><td>String of commands to enter blinking mode.</td></tr>
<tr><td>md</td><td>String of commands to enter double-bright mode.</td></tr>
<tr><td>mh</td><td>String of commands to enter half-bright mode.</td></tr>
<tr><td>mk</td><td>String of commands to enter invisible mode.</td></tr>
<tr><td>mp</td><td>String of commands to enter protected mode.</td></tr>
<tr><td>mr</td><td>String of commands to enter reverse-video mode.</td></tr>
<tr><td>me</td><td>String of commands to turn off all appearance modes, including standout mode and underline mode.  On some terminals it also turns off alternate character set mode; on others, it may not.  This capability must be present if any of mb<small>...</small> mris present.</td></tr>
<tr><td>as</td><td>String of commands to turn on alternate character set mode.  This mode assigns some or all graphic characters an alternate picture on the screen.  There is no standard as to what the alternate pictures look like.</td></tr>
<tr><td>ae</td><td>String of commands to turn off alternate character set mode.</td></tr>
<tr><td>sa</td><td>String of commands to turn on an arbitrary combination of appearance modes.  It accepts 9 parameters, each of which controls a particular kind of appearance mode.  A parameter should be 1 to turn its appearance mode on, or zero to turn that mode off.  Most terminals do not support the sacapability, even among those that do have various appearance modes.  The nine parameters are, in order,
<ol>
<li><var>standout</var></li><li><var>underline</var> </li><li><var>reverse</var> </li><li><var>blink</var> </li><li><var>half-bright</var> </li><li><var>double-bright</var> </li><li><var>blank</var> </li><li><var>protect</var> </li><li><var>alt char set</var> </li>
</ol>
</td></tr>
</tbody></table>



<h2>Variable and Function Index</h2>
<p>For stty</p>
<ul>
<li><code>BC</code>: tgoto</li>
<li><code>ospeed</code>: Output Padding</li>
<li><code>PC</code>: Output Padding</li>
<li><code>tgetent</code>: Find</li>
<li><code>tgetflag</code>: Interrogate</li>
<li><code>tgetnum</code>: Interrogate</li>
<li><code>tgetstr</code>: Interrogate</li>
<li><code>tgoto</code>: tgoto</li>
<li><code>tparam</code>: tparam</li>
<li><code>tputs</code>: Output Padding</li>
<li><code>UP</code>: tgoto</li>
</ul>


<h2>Summary of Capability Names</h2>
<p>Here are all the terminal capability names in alphabetical order with a brief description of each.  For cross references to their definitions, see the index of capability names.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>ae</td><td>String to turn off alternate character set mode.</td></tr>
<tr><td>al</td><td>String to insert a blank line before the cursor.</td></tr>
<tr><td>AL</td><td>String to insert <var>n</var> blank lines before the cursor.</td></tr>
<tr><td>am</td><td>Flag: output to last column wraps cursor to next line.</td></tr>
<tr><td>as</td><td>String to turn on alternate character set mode.like.</td></tr>
<tr><td>bc</td><td>Very obsolete alternative name for the lecapability.</td></tr>
<tr><td>bl</td><td>String to sound the bell.</td></tr>
<tr><td>bs</td><td>Obsolete flag: ASCII backspace may be used for leftward motion.</td></tr>
<tr><td>bt</td><td>String to move the cursor left to the previous hardware tab stop column.</td></tr>
<tr><td>bw</td><td>Flag: leat left margin wraps to end of previous line.</td></tr>
<tr><td>CC</td><td>String to change terminal's command character.</td></tr>
<tr><td>cd</td><td>String to clear the line the cursor is on, and following lines.</td></tr>
<tr><td>ce</td><td>String to clear from the cursor to the end of the line.</td></tr>
<tr><td>ch</td><td>String to position the cursor at column <var>c</var> in the same line.</td></tr>
<tr><td>cl</td><td>String to clear the entire screen and put cursor at upper left corner.</td></tr>
<tr><td>cm</td><td>String to position the cursor at line <var>l</var>, column <var>c</var>.</td></tr>
<tr><td>CM</td><td>String to position the cursor at line <var>l</var>, column <var>c</var>, relative to display memory.</td></tr>
<tr><td>co</td><td>Number: width of the screen.</td></tr>
<tr><td>cr</td><td>String to move cursor sideways to left margin.</td></tr>
<tr><td>cs</td><td>String to set the scroll region.</td></tr>
<tr><td>cS</td><td>Alternate form of string to set the scroll region.</td></tr>
<tr><td>ct</td><td>String to clear all tab stops.</td></tr>
<tr><td>cv</td><td>String to position the cursor at line <var>l</var> in the same column.</td></tr>
<tr><td>da</td><td>Flag: data scrolled off top of screen may be scrolled back.</td></tr>
<tr><td>db</td><td>Flag: data scrolled off bottom of screen may be scrolled back.</td></tr>
<tr><td>dB</td><td>Obsolete number: msec of padding needed for the backspace character.</td></tr>
<tr><td>dc</td><td>String to delete one character position at the cursor.</td></tr>
<tr><td>dC</td><td>Obsolete number: msec of padding needed for the carriage-return character.</td></tr>
<tr><td>DC</td><td>String to delete <var>n</var> characters starting at the cursor.</td></tr>
<tr><td>dF</td><td>Obsolete number: msec of padding needed for the formfeed character.</td></tr>
<tr><td>dl</td><td>String to delete the line the cursor is on.</td></tr>
<tr><td>DL</td><td>String to delete <var>n</var> lines starting with the cursor's line.</td></tr>
<tr><td>dm</td><td>String to enter delete mode.</td></tr>
<tr><td>dN</td><td>Obsolete number: msec of padding needed for the newline character.</td></tr>
<tr><td>do</td><td>String to move the cursor vertically down one line.</td></tr>
<tr><td>DO</td><td>String to move cursor vertically down <var>n</var> lines.</td></tr>
<tr><td>ds</td><td>String to disable the display of the status line.</td></tr>
<tr><td>dT</td><td>Obsolete number: msec of padding needed for the tab character.</td></tr>
<tr><td>ec</td><td>String of commands to clear <var>n</var> characters at cursor.</td></tr>
<tr><td>ed</td><td>String to exit delete mode.</td></tr>
<tr><td>ei</td><td>String to leave insert mode.</td></tr>
<tr><td>eo</td><td>Flag: output of a space can erase an overstrike.</td></tr>
<tr><td>es</td><td>Flag: other display commands work while writing the status line.</td></tr>
<tr><td>ff</td><td>String to advance to the next page, for a hardcopy terminal.</td></tr>
<tr><td>fs</td><td>String to move the cursor back from the status line to its previous position (outside the status line).</td></tr>
<tr><td>gn</td><td>Flag: this terminal type is generic, not real.</td></tr>
<tr><td>hc</td><td>Flag: hardcopy terminal.</td></tr>
<tr><td>hd</td><td>String to move the cursor down half a line.</td></tr>
<tr><td>ho</td><td>String to position cursor at upper left corner.</td></tr>
<tr><td>hs</td><td>Flag: the terminal has a status line.</td></tr>
<tr><td>hu</td><td>String to move the cursor up half a line.</td></tr>
<tr><td>hz</td><td>Flag: terminal cannot accept ~as output.</td></tr>
<tr><td>i1</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>i3</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>ic</td><td>String to insert one character position at the cursor.</td></tr>
<tr><td>IC</td><td>String to insert <var>n</var> character positions at the cursor.</td></tr>
<tr><td>if</td><td>String naming a file of commands to initialize the terminal.</td></tr>
<tr><td>im</td><td>String to enter insert mode.</td></tr>
<tr><td>in</td><td>Flag: outputting a space is different from moving over empty positions.</td></tr>
<tr><td>ip</td><td>String to output following an inserted character in insert mode.</td></tr>
<tr><td>is</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>it</td><td>Number: initial spacing between hardware tab stop columns.</td></tr>
<tr><td>k0</td><td>String of input sent by function key 0 or 10.</td></tr>
<tr><td>k1 ... k9</td><td>Strings of input sent by function keys 1 through 9.</td></tr>
<tr><td>K1 ... K5</td><td>Strings sent by the five other keys in 3-by-3 array with arrows.</td></tr>
<tr><td>ka</td><td>String of input sent by the “clear all tabs” key.</td></tr>
<tr><td>kA</td><td>String of input sent by the “insert line” key.</td></tr>
<tr><td>kb</td><td>String of input sent by the “backspace” key.</td></tr>
<tr><td>kC</td><td>String of input sent by the “clear screen” key.</td></tr>
<tr><td>kd</td><td>String of input sent by typing the down-arrow key.</td></tr>
<tr><td>kD</td><td>String of input sent by the “delete character” key.</td></tr>
<tr><td>ke</td><td>String to make the function keys work locally.</td></tr>
<tr><td>kE</td><td>String of input sent by the “clear to end of line” key.</td></tr>
<tr><td>kF</td><td>String of input sent by the “scroll forward” key.</td></tr>
<tr><td>kh</td><td>String of input sent by typing the “home-position” key.</td></tr>
<tr><td>kH</td><td>String of input sent by the “home down” key.</td></tr>
<tr><td>kI</td><td>String of input sent by the “insert character” or “enter insert mode” key.</td></tr>
<tr><td>kl</td><td>String of input sent by typing the left-arrow key.</td></tr>
<tr><td>kL</td><td>String of input sent by the “delete line” key.</td></tr>
<tr><td>km</td><td>Flag: the terminal has a Meta key.</td></tr>
<tr><td>kM</td><td>String of input sent by the “exit insert mode” key.</td></tr>
<tr><td>kn</td><td>Numeric value, the number of numbered function keys.</td></tr>
<tr><td>kN</td><td>String of input sent by the “next page” key.</td></tr>
<tr><td>ko</td><td>Very obsolete string listing the terminal's named function keys.</td></tr>
<tr><td>kP</td><td>String of input sent by the “previous page” key.</td></tr>
<tr><td>kr</td><td>String of input sent by typing the right-arrow key.</td></tr>
<tr><td>kR</td><td>String of input sent by the “scroll reverse” key.</td></tr>
<tr><td>ks</td><td>String to make the function keys transmit.</td></tr>
<tr><td>kS</td><td>String of input sent by the “clear to end of screen” key.</td></tr>
<tr><td>kt</td><td>String of input sent by the “clear tab stop this column” key.</td></tr>
<tr><td>kT</td><td>String of input sent by the “set tab stop in this column” key.</td></tr>
<tr><td>ku</td><td>String of input sent by typing the up-arrow key.</td></tr>
<tr><td>l0</td><td>String on keyboard labelling function key 0 or 10.</td></tr>
<tr><td>l1 ... l9</td><td>Strings on keyboard labelling function keys 1 through 9.</td></tr>
<tr><td>le</td><td>String to move the cursor left one column.</td></tr>
<tr><td>LE</td><td>String to move cursor left <var>n</var> columns.</td></tr>
<tr><td>li</td><td>Number: height of the screen.</td></tr>
<tr><td>ll</td><td>String to position cursor at lower left corner.</td></tr>
<tr><td>lm</td><td>Number: lines of display memory.</td></tr>
<tr><td>LP</td><td>Flag: writing to last column of last line will not scroll.</td></tr>
<tr><td>mb</td><td>String to enter blinking mode.</td></tr>
<tr><td>md</td><td>String to enter double-bright mode.</td></tr>
<tr><td>me</td><td>String to turn off all appearance modes</td></tr>
<tr><td>mh</td><td>String to enter half-bright mode.</td></tr>
<tr><td>mi</td><td>Flag: cursor motion in insert mode is safe.</td></tr>
<tr><td>mk</td><td>String to enter invisible mode.</td></tr>
<tr><td>mm</td><td>String to enable the functioning of the Meta key.</td></tr>
<tr><td>mo</td><td>String to disable the functioning of the Meta key.</td></tr>
<tr><td>mp</td><td>String to enter protected mode.</td></tr>
<tr><td>mr</td><td>String to enter reverse-video mode.</td></tr>
<tr><td>ms</td><td>Flag: cursor motion in standout mode is safe.</td></tr>
<tr><td>nc</td><td>Obsolete flag: do not use ASCII carriage-return on this terminal.</td></tr>
<tr><td>nd</td><td>String to move the cursor right one column.</td></tr>
<tr><td>NF</td><td>Flag: do not use XON/XOFF flow control.</td></tr>
<tr><td>nl</td><td>Obsolete alternative name for the doand sfcapabilities.</td></tr>
<tr><td>ns</td><td>Flag: the terminal does not normally scroll for sequential output.</td></tr>
<tr><td>nw</td><td>String to move to start of next line, possibly clearing rest of old line.</td></tr>
<tr><td>os</td><td>Flag: terminal can overstrike.</td></tr>
<tr><td>pb</td><td>Number: the lowest baud rate at which padding is actually needed.</td></tr>
<tr><td>pc</td><td>String containing character for padding.</td></tr>
<tr><td>pf</td><td>String to terminate redirection of output to the printer.</td></tr>
<tr><td>po</td><td>String to redirect further output to the printer.</td></tr>
<tr><td>pO</td><td>String to redirect <var>n</var> characters ofoutput to the printer.</td></tr>
<tr><td>ps</td><td>String to print the screen on the attached printer.</td></tr>
<tr><td>rc</td><td>String to move to last saved cursor position.</td></tr>
<tr><td>RI</td><td>String to move cursor right <var>n</var> columns.</td></tr>
<tr><td>rp</td><td>String to output character <var>c</var> repeated <var>n</var> times.</td></tr>
<tr><td>rs</td><td>String to reset the terminal from any strange modes.</td></tr>
<tr><td>sa</td><td>String to turn on an arbitrary combination of appearance modes.</td></tr>
<tr><td>sc</td><td>String to save the current cursor position.</td></tr>
<tr><td>se</td><td>String to leave standout mode.</td></tr>
<tr><td>sf</td><td>String to scroll the screen one line up.</td></tr>
<tr><td>SF</td><td>String to scroll the screen <var>n</var> lines up.</td></tr>
<tr><td>sg</td><td>Number: width of magic standout cookie.  Absent if magic cookies are not used.</td></tr>
<tr><td>so</td><td>String to enter standout mode.</td></tr>
<tr><td>sr</td><td>String to scroll the screen one line down.</td></tr>
<tr><td>SR</td><td>String to scroll the screen <var>n</var> line down.</td></tr>
<tr><td>st</td><td>String to set tab stop at current cursor column on all lines. programs.</td></tr>
<tr><td>ta</td><td>String to move the cursor right to the next hardware tab stop column.</td></tr>
<tr><td>te</td><td>String to return terminal to settings for sequential output.</td></tr>
<tr><td>ti</td><td>String to initialize terminal for random cursor motion.</td></tr>
<tr><td>ts</td><td>String to move the terminal cursor into the status line.</td></tr>
<tr><td>uc</td><td>String to underline one character and move cursor right.</td></tr>
<tr><td>ue</td><td>String to turn off underline mode</td></tr>
<tr><td>ug</td><td>Number: width of underlining magic cookie.  Absent if underlining doesn't use magic cookies.</td></tr>
<tr><td>ul</td><td>Flag: underline by overstriking with an underscore.</td></tr>
<tr><td>up</td><td>String to move the cursor vertically up one line.</td></tr>
<tr><td>UP</td><td>String to move cursor vertically up <var>n</var> lines.</td></tr>
<tr><td>us</td><td>String to turn on underline mode</td></tr>
<tr><td>vb</td><td>String to make the screen flash.</td></tr>
<tr><td>ve</td><td>String to return the cursor to normal.</td></tr>
<tr><td>vi</td><td>String to make the cursor invisible.</td></tr>
<tr><td>vs</td><td>String to enhance the cursor.</td></tr>
<tr><td>wi</td><td>String to set the terminal output screen window.</td></tr>
<tr><td>ws</td><td>Number: the width of the status line.</td></tr>
<tr><td>xb</td><td>Flag: superbee terminal.</td></tr>
<tr><td>xn</td><td>Flag: cursor wraps in a strange way.</td></tr>
<tr><td>xs</td><td>Flag: clearing a line is the only way to clear the appearance modes of positions in that line (or, only way to remove magic cookies on that line).</td></tr>
<tr><td>xt</td><td>Flag: Teleray 1061; several strange characteristics.</td></tr>
</tbody></table>

<h2>Variable and Function Index</h2>
<ul>
<li><code>BC</code>: tgoto</li>
<li><code>ospeed</code>: Output Padding</li>
<li><code>PC</code>: Output Padding</li>
<li><code>tgetent</code>: Find</li>
<li><code>tgetflag</code>: Interrogate</li>
<li><code>tgetnum</code>: Interrogate</li>
<li><code>tgetstr</code>: Interrogate</li>
<li><code>tgoto</code>: tgoto</li>
<li><code>tparam</code>: tparam</li>
<li><code>tputs</code>: Output Padding</li>
<li><code>UP</code>: tgoto</li>
</ul>

<hr class="HR" />

<ul>
<li><code>ae</code>: Standout</li>
<li><code>AL</code>: Insdel Line</li>
<li><code>al</code>: Insdel Line</li>
<li><code>am</code>: Wrapping</li>
<li><code>as</code>: Standout</li>
<li><code>bc</code>: Cursor Motion</li>
<li><code>bl</code>: Bell</li>
<li><code>bs</code>: Cursor Motion</li>
<li><code>bt</code>: Cursor Motion</li>
<li><code>bw</code>: Cursor Motion</li>
<li><code>CC</code>: Basic</li>
<li><code>cd</code>: Clearing</li>
<li><code>ce</code>: Clearing</li>
<li><code>ch</code>: Cursor Motion</li>
<li><code>cl</code>: Clearing</li>
<li><code>CM</code>: Cursor Motion</li>
<li><code>cm</code>: Cursor Motion</li>
<li><code>co</code>: Screen Size</li>
<li><code>cr</code>: Cursor Motion</li>
<li><code>cS</code>: Scrolling</li>
<li><code>cs</code>: Scrolling</li>
<li><code>ct</code>: Initialization</li>
<li><code>cv</code>: Cursor Motion</li>
<li><code>da</code>: Scrolling</li>
<li><code>dB</code>: Pad Specs</li>
<li><code>db</code>: Scrolling</li>
<li><code>dC</code>: Pad Specs</li>
<li><code>DC</code>: Insdel Char</li>
<li><code>dc</code>: Insdel Char</li>
<li><code>dF</code>: Pad Specs</li>
<li><code>DL</code>: Insdel Line</li>
<li><code>dl</code>: Insdel Line</li>
<li><code>dm</code>: Insdel Char</li>
<li><code>dN</code>: Pad Specs</li>
<li><code>DO</code>: Cursor Motion</li>
<li><code>do</code>: Cursor Motion</li>
<li><code>ds</code>: Status Line</li>
<li><code>dT</code>: Pad Specs</li>
<li><code>ec</code>: Clearing</li>
<li><code>ed</code>: Insdel Char</li>
<li><code>ei</code>: Insdel Char</li>
<li><code>eo</code>: Basic</li>
<li><code>es</code>: Status Line</li>
<li><code>ff</code>: Cursor Motion</li>
<li><code>fs</code>: Status Line</li>
<li><code>gn</code>: Basic</li>
<li><code>hc</code>: Basic</li>
<li><code>hd</code>: Half-Line</li>
<li><code>ho</code>: Cursor Motion</li>
<li><code>hs</code>: Status Line</li>
<li><code>hu</code>: Half-Line</li>
<li><code>hz</code>: Basic</li>
<li><code>i1</code>: Initialization</li>
<li><code>i3</code>: Initialization</li>
<li><code>IC</code>: Insdel Char</li>
<li><code>ic</code>: Insdel Char</li>
<li><code>if</code>: Initialization</li>
<li><code>im</code>: Insdel Char</li>
<li><code>in</code>: Insdel Char</li>
<li><code>ip</code>: Insdel Char</li>
<li><code>is</code>: Initialization</li>
<li><code>it</code>: Initialization</li>
<li><code>K1...K5</code>: Keypad</li>
<li><code>k1...k9</code>: Keypad</li>
<li><code>kA...kT</code>: Keypad</li>
<li><code>ka...ku</code>: Keypad</li>
<li><code>km</code>: Meta Key</li>
<li><code>l0...l9</code>: Keypad</li>
<li><code>LE</code>: Cursor Motion</li>
<li><code>le</code>: Cursor Motion</li>
<li><code>li</code>: Screen Size</li>
<li><code>ll</code>: Cursor Motion</li>
<li><code>lm</code>: Scrolling</li>
<li><code>LP</code>: Wrapping</li>
<li><code>mb</code>: Standout</li>
<li><code>md</code>: Standout</li>
<li><code>me</code>: Standout</li>
<li><code>mh</code>: Standout</li>
<li><code>mi</code>: Insdel Char</li>
<li><code>mk</code>: Standout</li>
<li><code>mm</code>: Meta Key</li>
<li><code>mo</code>: Meta Key</li>
<li><code>mp</code>: Standout</li>
<li><code>mr</code>: Standout</li>
<li><code>ms</code>: Underlining</li>
<li><code>ms</code>: Standout</li>
<li><code>nc</code>: Cursor Motion</li>
<li><code>nd</code>: Cursor Motion</li>
<li><code>NF</code>: Initialization</li>
<li><code>nl</code>: Cursor Motion</li>
<li><code>ns</code>: Scrolling</li>
<li><code>nw</code>: Cursor Motion</li>
<li><code>os</code>: Basic</li>
<li><code>pb</code>: Pad Specs</li>
<li><code>pc</code>: Pad Specs</li>
<li><code>pf</code>: Printer</li>
<li><code>pO</code>: Printer</li>
<li><code>po</code>: Printer</li>
<li><code>ps</code>: Printer</li>
<li><code>rc</code>: Cursor Motion</li>
<li><code>RI</code>: Cursor Motion</li>
<li><code>rp</code>: Basic</li>
<li><code>rs</code>: Initialization</li>
<li><code>sa</code>: Standout</li>
<li><code>sc</code>: Cursor Motion</li>
<li><code>se</code>: Standout</li>
<li><code>SF</code>: Scrolling</li>
<li><code>sf</code>: Scrolling</li>
<li><code>sg</code>: Standout</li>
<li><code>so</code>: Standout</li>
<li><code>SR</code>: Scrolling</li>
<li><code>sr</code>: Scrolling</li>
<li><code>st</code>: Initialization</li>
<li><code>ta</code>: Cursor Motion</li>
<li><code>te</code>: Initialization</li>
<li><code>ti</code>: Initialization</li>
<li><code>ts</code>: Status Line</li>
<li><code>uc</code>: Underlining</li>
<li><code>ue</code>: Underlining</li>
<li><code>ug</code>: Underlining</li>
<li><code>ul</code>: Underlining</li>
<li><code>UP</code>: Cursor Motion</li>
<li><code>up</code>: Cursor Motion</li>
<li><code>us</code>: Underlining</li>
<li><code>vb</code>: Bell</li>
<li><code>ve</code>: Cursor Visibility</li>
<li><code>vi</code>: Cursor Visibility</li>
<li><code>vs</code>: Cursor Visibility</li>
<li><code>wi</code>: Windows</li>
<li><code>ws</code>: Status Line</li>
<li><code>xb</code>: Basic</li>
<li><code>xn</code>: Wrapping</li>
<li><code>xs</code>: Standout</li>
<li><code>xt</code>: Standout</li>
<li><code>xt</code>: Cursor Motion</li>
</ul>





<hr class="HR" />

<ul>
<li>Basic:        Basic characteristics.</li>
<li>Screen Size:   Screen size, and what happens when it changes.</li>
<li>Cursor Motion:   Various ways to move the cursor.</li>
<li>Wrapping:     What happens if you write a character in the last column.</li>
<li>Scrolling:    Pushing text up and down on the screen.</li>
<li>Windows:      Limiting the part of the window that output affects.</li>
<li>Clearing:     Erasing one or many lines.</li>
<li>Insdel Line:   Making new blank lines in mid-screen; deleting lines.</li>
<li>Insdel Char:   Inserting and deleting characters within a line.</li>
<li>Standout:     Highlighting some of the text.</li>
<li>Underlining:   Underlining some of the text.</li>
<li>Cursor Visibility:   Making the cursor more or less easy to spot.</li>
<li>Bell:         Attracts user's attention; not localized on the screen.</li>
<li>Keypad:  Recognizing when function keys or arrows are typed.</li>
<li>Meta Key:     META acts like an extra shift key.</li>
<li>Initialization:   Commands used to initialize or reset the terminal.</li>
<li>Pad Specs:    Info for the kernel on how much padding is needed.</li>
<li>Status Line:   A status line displays <code>background</code> information.</li>
<li>Half-Line:    Moving by half-lines, for superscripts and subscripts.</li>
<li>Printer:      Controlling auxiliary printers of display terminals.</li>
</ul>
<hr class="HR" />





<h2>Translated Term Capabilities</h2>
<pre></pre>
<p>This is helpful so you can understand what a term cap does, by looking at the long name.</p>
<table class="bordered"><tbody><tr class="header"><th>Tput Name</th><th>Terminfo Long Name</th></tr>
<tr><td>@7</td><td>key_end</td></tr><tr><td>AB</td><td>set_a_background</td></tr><tr><td>AF</td><td>set_a_foreground</td></tr><tr><td>AL</td><td>parm_insert_line</td></tr><tr><td>AX</td><td>AX</td></tr><tr><td>Co</td><td>max_colors</td></tr><tr><td>DC</td><td>parm_dch</td></tr><tr><td>DL</td><td>parm_delete_line</td></tr><tr><td>DO</td><td>parm_down_cursor</td></tr><tr><td>E0</td><td>E0</td></tr><tr><td>F1</td><td>key_f11</td></tr><tr><td>F2</td><td>key_f12</td></tr><tr><td>G0</td><td>G0</td></tr><tr><td>HC</td><td>5i</td></tr><tr><td>IC</td><td>parm_ich</td></tr><tr><td>Ic</td><td>initialize_color</td></tr><tr><td>Km</td><td>delete_line</td></tr><tr><td>LE</td><td>parm_left_cursor</td></tr><tr><td>NC</td><td>no_color_video</td></tr><tr><td>ND</td><td>MT</td></tr><tr><td>NP</td><td>NL</td></tr><tr><td>RI</td><td>parm_right_cursor</td></tr><tr><td>S0</td><td>S0</td></tr><tr><td>UP</td><td>parm_up_cursor</td></tr><tr><td>YA</td><td>NR</td></tr><tr><td>YC</td><td>YB</td></tr><tr><td>YE</td><td>YD</td></tr><tr><td>YG</td><td>YF</td></tr><tr><td>ac</td><td>acs_chars</td></tr><tr><td>ae</td><td>exit_alt_charset_mode</td></tr><tr><td>al</td><td>insert_line</td></tr><tr><td>am</td><td>auto_right_margin</td></tr><tr><td>as</td><td>enter_alt_charset_mode</td></tr><tr><td>back_color_erase</td><td>backspaces_with_bs</td></tr><tr><td>bl</td><td>bell</td></tr><tr><td>bs</td><td>eat_newline_glitch</td></tr><tr><td>bt</td><td>back_tab</td></tr><tr><td>bw</td><td>auto_left_margin</td></tr><tr><td>cb</td><td>clr_bol</td></tr><tr><td>cc</td><td>can_change</td></tr><tr><td>cd</td><td>clr_eos</td></tr><tr><td>ce</td><td>clr_eol</td></tr><tr><td>cl</td><td>clear_screen</td></tr><tr><td>cm</td><td>cursor_address</td></tr><tr><td>co</td><td>columns</td></tr><tr><td>col_addr_glitch</td><td>ceol_standout_glitch</td></tr><tr><td>cpi_changes_res</td><td>cr_cancels_micro_mode</td></tr><tr><td>cr</td><td>carriage_return</td></tr><tr><td>cs</td><td>change_scroll_region</td></tr><tr><td>ct</td><td>clear_all_tabs</td></tr><tr><td>cursor_up</td><td>scroll_reverse</td></tr><tr><td>da</td><td>crt_no_scrolling</td></tr><tr><td>db</td><td>dest_tabs_magic_smso</td></tr><tr><td>dc</td><td>delete_character</td></tr><tr><td>dl</td><td>key_mouse</td></tr><tr><td>do</td><td>cursor_down</td></tr><tr><td>eA</td><td>ena_acs</td></tr><tr><td>ei</td><td>exit_insert_mode</td></tr><tr><td>eo</td><td>erase_overstrike</td></tr><tr><td>es</td><td>generic_type</td></tr><tr><td>gn</td><td>gnu_has_meta_key</td></tr><tr><td>hard_copy</td><td>hard_cursor</td></tr><tr><td>has_meta_key</td><td>has_hardware_tabs</td></tr><tr><td>has_status_line</td><td>has_print_wheel</td></tr><tr><td>hl</td><td>hc</td></tr><tr><td>ho</td><td>cursor_home</td></tr><tr><td>hs</td><td>hue_lightness_saturation</td></tr><tr><td>im</td><td>enter_insert_mode</td></tr><tr><td>in</td><td>hz</td></tr><tr><td>insert_null_glitch</td><td>linefeed_is_newline</td></tr><tr><td>is</td><td>init_2string</td></tr><tr><td>it</td><td>init_tabs</td></tr><tr><td>k1</td><td>key_f1</td></tr><tr><td>k2</td><td>key_f2</td></tr><tr><td>k3</td><td>key_f3</td></tr><tr><td>k4</td><td>key_f4</td></tr><tr><td>k5</td><td>key_f5</td></tr><tr><td>k6</td><td>key_f6</td></tr><tr><td>k7</td><td>key_f7</td></tr><tr><td>k8</td><td>key_f8</td></tr><tr><td>k9</td><td>key_f9</td></tr><tr><td>k;</td><td>key_f10</td></tr><tr><td>kB</td><td>key_btab</td></tr><tr><td>kD</td><td>key_dc</td></tr><tr><td>kI</td><td>key_ic</td></tr><tr><td>kN</td><td>key_npage</td></tr><tr><td>kP</td><td>key_ppage</td></tr><tr><td>kb</td><td>cursor_left</td></tr><tr><td>kd</td><td>key_down</td></tr><tr><td>ke</td><td>keypad_local</td></tr><tr><td>kh</td><td>key_home</td></tr><tr><td>kl</td><td>key_left</td></tr><tr><td>kr</td><td>key_right</td></tr><tr><td>ks</td><td>keypad_xmit</td></tr><tr><td>ku</td><td>key_up</td></tr><tr><td>le</td><td>key_backspace</td></tr><tr><td>li</td><td>lines</td></tr><tr><td>mb</td><td>enter_blink_mode</td></tr><tr><td>md</td><td>enter_bold_mode</td></tr><tr><td>me</td><td>exit_attribute_mode</td></tr><tr><td>memory_above</td><td>lpi_changes_res</td></tr><tr><td>mi</td><td>km</td></tr><tr><td>move_insert_mode</td><td>move_standout_mode</td></tr><tr><td>mr</td><td>enter_reverse_mode</td></tr><tr><td>nc</td><td>memory_below</td></tr><tr><td>nd</td><td>cursor_right</td></tr><tr><td>needs_xon_xoff</td><td>no_correctly_working_cr</td></tr><tr><td>no_pad_char</td><td>no_esc_ctlc</td></tr><tr><td>non_rev_rmcup</td><td>non_dest_scroll_region</td></tr><tr><td>nw</td><td>newline</td></tr><tr><td>nx</td><td>ns</td></tr><tr><td>op</td><td>orig_pair</td></tr><tr><td>os</td><td>over_strike</td></tr><tr><td>pa</td><td>max_pairs</td></tr><tr><td>prtr_silent</td><td>return_does_clr_eol</td></tr><tr><td>pt</td><td>ms</td></tr><tr><td>r2</td><td>reset_2string</td></tr><tr><td>rc</td><td>restore_cursor</td></tr><tr><td>row_addr_glitch</td><td>semi_auto_right_margin</td></tr><tr><td>sa</td><td>set_attributes</td></tr><tr><td>sc</td><td>save_cursor</td></tr><tr><td>se</td><td>exit_standout_mode</td></tr><tr><td>sf</td><td>scroll_forward</td></tr><tr><td>so</td><td>enter_standout_mode</td></tr><tr><td>st</td><td>set_tab</td></tr><tr><td>ta</td><td>tab</td></tr><tr><td>te</td><td>exit_ca_mode</td></tr><tr><td>ti</td><td>enter_ca_mode</td></tr><tr><td>tilde_glitch</td><td>status_line_esc_ok</td></tr><tr><td>ue</td><td>exit_underline_mode</td></tr><tr><td>ul</td><td>transparent_underline</td></tr><tr><td>up</td><td>sr</td></tr><tr><td>us</td><td>enter_underline_mode</td></tr><tr><td>vb</td><td>flash_screen</td></tr><tr><td>ve</td><td>cursor_normal</td></tr><tr><td>vi</td><td>cursor_invisible</td></tr><tr><td>vs</td><td>cursor_visible</td></tr><tr><td>xn</td><td>ut</td></tr><tr><td>xo</td><td>xb</td></tr><tr><td>xr</td><td>xon_xoff</td></tr><tr><td>xt</td><td>xs</td></tr></tbody></table>


<h2>List of All Terminals</h2>
<p>You can view this list with the following command:</p>
<pre>$ toe -a|sort -d</pre>





<h2><a href="http://vt100.net/docs/vt100-ug/chapter3.html#S3.3.2">VT100 keypad Diagram</a></h2>
<p><a href="http://vt100.net/docs/vt100-ug/chapter3.html#S3.3.2">VT100 LINK</a></p>
<p>Here's a diagram of the VT100 keypad keys with their bindings.  The top line is the name of the key (some DEC keyboards have the keys labelled somewhat differently, like GOLD instead of PF1, but this is the most "official" name).  The second line is the escape sequence it generates in Application Keypad mode (where "$" means the ESC character).  The third line contains two items, first the mapping of the key in terminfo, and then in termcap.</p>
<pre>   _______________________________________
  |   PF1   |   PF2   |   PF3   |   PF4   |
  |   $OP   |   $OQ   |   $OR   |   $OS   |
  |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_|
  |    7         8         9         -    |
  |   $Ow   |   $Ox   |   $Oy   |   $Om   |
  |_kf9__k9_|_kf10_k;_|_kf0__k0_|_________|
  |    4    |    5    |    6    |    ,    |
  |   $Ot   |   $Ou   |   $Ov   |   $Ol   |
  |_kf5__k5_|_kf6__k6_|_kf7__k7_|_kf8__k8_|
  |    1    |    2    |    3    |         |
  |   $Oq   |   $Or   |   $Os   |  enter  |
  |_ka1__K1_|_kb2__K2_|_ka3__K3_|  $OM    |
  |         0         |   .     |         |
  |        $Op        |  $On    |         |
  |___kc1_______K4____|_kc3__K5_|_kent_@8_|</pre>

<p>A better adaptation to modern keyboards such as the PC's, which have a dozen function keys and the keypad 2,4,6,8 keys are labeled with arrows keys, is to use the 5-key arrangement to model the arrow keys as suggested in the terminfo guidelines:</p>
<pre>   _______________________________________
  |   PF1   |   PF2   |   PF3   |   PF4   |
  |   $OP   |   $OQ   |   $OR   |   $OS   |
  |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_|
  |    7         8         9         -    |
  |   $Ow   |   $Ox   |   $Oy   |   $Om   |
  |_ka1__K1_|_________|_ka3__K3_|_________|
  |    4    |    5    |    6    |    ,    |
  |   $Ot   |   $Ou   |   $Ov   |   $Ol   |
  |_________|_kb2__K2_|_________|_________|
  |    1    |    2    |    3    |         |
  |   $Oq   |   $Or   |   $Os   |  enter  |
  |_kc1__K4_|_________|_kc3__K5_|  $OM    |
  |         0         |   .     |         |
  |        $Op        |  $On    |         |
  |___________________|_________|_kent_@8_|</pre>





<h2>SGR parameter values</h2>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>0</var></td><td>default mode (attributes off)</td></tr>
<tr><td><var>1</var></td><td>bold</td></tr>
<tr><td><var>2</var></td><td>dim</td></tr>
<tr><td><var>3</var></td><td>italicized</td></tr>
<tr><td><var>4</var></td><td>underlined</td></tr>
<tr><td><var>5</var></td><td>slow blink</td></tr>
<tr><td><var>6</var></td><td>fast blink</td></tr>
<tr><td><var>7</var></td><td>reverse video</td></tr>
<tr><td><var>8</var></td><td>invisible</td></tr>
<tr><td><var>9</var></td><td>crossed-out (marked for deletion)</td></tr>
<tr><td><var>10</var></td><td>primary font [10 + n (n in 1..9) = nth alternative font]</td></tr>
<tr><td><var>20</var></td><td>Fraktur</td></tr>
<tr><td><var>21</var></td><td>double underline</td></tr>
<tr><td><var>22</var></td><td>turn off 2</td></tr>
<tr><td><var>23</var></td><td>turn off 3</td></tr>
<tr><td><var>24</var></td><td>turn off 4</td></tr>
<tr><td><var>25</var></td><td>turn off 5</td></tr>
<tr><td><var>26</var></td><td>proportional spacing</td></tr>
<tr><td><var>27</var></td><td>turn off 7</td></tr>
<tr><td><var>28</var></td><td>turn off 8</td></tr>
<tr><td><var>29</var></td><td>turn off 9</td></tr>
<tr><td><var>30</var></td><td>black fg</td></tr>
<tr><td><var>31</var></td><td>red fg</td></tr>
<tr><td><var>32</var></td><td>green fg</td></tr>
<tr><td><var>33</var></td><td>yellow fg</td></tr>
<tr><td><var>34</var></td><td>blue fg</td></tr>
<tr><td><var>35</var></td><td>magenta fg</td></tr>
<tr><td><var>36</var></td><td>cyan fg</td></tr>
<tr><td><var>37</var></td><td>white fg</td></tr>
<tr><td><var>38</var></td><td>set fg color as in CCIT T.416</td></tr>
<tr><td><var>39</var></td><td>set default fg color</td></tr>
<tr><td><var>40</var></td><td>black bg</td></tr>
<tr><td><var>41</var></td><td>red bg</td></tr>
<tr><td><var>42</var></td><td>green bg</td></tr>
<tr><td><var>43</var></td><td>yellow bg</td></tr>
<tr><td><var>44</var></td><td>blue bg</td></tr>
<tr><td><var>45</var></td><td>magenta bg</td></tr>
<tr><td><var>46</var></td><td>cyan bg</td></tr>
<tr><td><var>47</var></td><td>white bg</td></tr>
<tr><td><var>48</var></td><td>set bg color as in CCIT T.416</td></tr>
<tr><td><var>39</var></td><td>set default bg color</td></tr>
<tr><td><var>50</var></td><td>turn off 26</td></tr>
<tr><td><var>51</var></td><td>framed</td></tr>
<tr><td><var>52</var></td><td>encircled</td></tr>
<tr><td><var>53</var></td><td>overlined</td></tr>
<tr><td><var>54</var></td><td>turn off 51 &amp; 52</td></tr>
<tr><td><var>55</var></td><td>not overlined</td></tr>
<tr><td><var>56-59</var></td><td>reserved</td></tr>
<tr><td><var>61-65</var></td><td>variable highlights for ideograms.</td></tr>
</tbody></table>






<pre>Sequence     Sequence                             Parameter   or
Mnemonic     Name              Sequence           Value      Mode   terminfo
-----------------------------------------------------------------------------
APC  Applicatn Program Command \E _                -         Delim  -
BEL  Bell *                    ^G                  -         -      bel
BPH  Break Permitted Here *    \E B                -         *      -
BS   Backpace *                ^H                  -         EF     -
CAN  Cancel *                  ^X                  -         -      -   (A)
CBT  Cursor Backward Tab       \E [ Pn Z           1         eF     cbt
CCH  Cancel Previous Character \E T                -         -      -
CHA  Cursor Horizntal Absolute \E [ Pn G           1         eF     hpa (B)
CHT  Cursor Horizontal Tab     \E [ Pn I           1         eF     tab (C)
CMD  Coding Method Delimiter * \E
CNL  Cursor Next Line          \E [ Pn E           1         eF     nel (D)
CPL  Cursor Preceding Line     \E [ Pn F           1         eF     -
CPR  Cursor Position Report    \E [ Pn ; Pn R      1, 1      -      -   (E)
CSI  Control Sequence Intro    \E [                -         Intro  -
CTC  Cursor Tabulation Control \E [ Ps W           0         eF     -   (F)
CUB  Cursor Backward           \E [ Pn D           1         eF     cub
CUD  Cursor Down               \E [ Pn B           1         eF     cud
CUF  Cursor Forward            \E [ Pn C           1         eF     cuf
CUP  Cursor Position           \E [ Pn ; Pn H      1, 1      eF     cup (G)
CUU  Cursor Up                 \E [ Pn A           1         eF     cuu
CVT  Cursor Vertical Tab       \E [ Pn Y           -         eF     -   (H)
DA   Device Attributes         \E [ Pn c           0         -      -
DAQ  Define Area Qualification \E [ Ps o           0         -      -
DCH  Delete Character          \E [ Pn P           1         eF     dch
DCS  Device Control String     \E P                -         Delim  -
DL   Delete Line               \E [ Pn M           1         eF     dl
DLE  Data Link Escape *        ^P                  -         -      -
DMI  Disable Manual Input      \E \                -         Fs     -
DSR  Device Status Report      \E [ Ps n           0         -      -   (I)
DTA  Dimension Text Area *     \E [ Pn ; Pn SPC T  -         PC     -
EA   Erase in Area             \E [ Ps O           0         eF     -   (J)
ECH  Erase Character           \E [ Pn X           1         eF     ech
ED   Erase in Display          \E [ Ps J           0         eF     ed  (J)
EF   Erase in Field            \E [ Ps N           0         eF     -
EL   Erase in Line             \E [ Ps K           0         eF     el  (J)
EM   End of Medium *           ^Y                  -         -      -
EMI  Enable Manual Input       \E b                          Fs     -
ENQ  Enquire                   ^E                  -         -      -
EOT  End Of Transmission       ^D                  -         *      -
EPA  End of Protected Area     \E W                -         -      -   (K)
ESA  End of Selected Area      \E G                -         -      -
ESC  Escape                    ^[                  -         -      -
ETB  End Transmission Block    ^W                  -         -      -
ETX  End of Text               ^C                  -         -      -
FF   Form Feed                 ^L                  -         -      -
FNK  Function Key *            \E [ Pn SPC W       -         -      -
GCC  Graphic Char Combination* \E [ Pn ; Pn SPC B  -         -      -
FNT  Font Selection            \E [ Pn ; Pn SPC D  0, 0      FE     -
GSM  Graphic Size Modify       \E [ Pn ; Pn SPC B  100, 100  FE     -   (L)
GSS  Graphic Size Selection    \E [ Pn SPC C       none      FE     -
HPA  Horz Position Absolute    \E [ Pn `           1         FE     -   (B)
HPB  Char Position Backward    \E [ j              1         FE     -
HPR  Horz Position Relative    \E [ Pn a           1         FE     -   (M)
HT   Horizontal Tab *          ^I                  -         FE     -   (N)
HTJ  Horz Tab w/Justification  \E I                -         FE     -
HTS  Horizontal Tab Set        \E H                -         FE     hts
HVP  Horz &amp;amp; Vertical Position  \E [ Pn ; Pn f      1, 1      FE     -   (G)
ICH  Insert Character          \E [ Pn @           1         eF     ich
IDCS ID Device Control String  \E [ SPC O          -         *      -
IGS  ID Graphic Subrepertoire  \E [ SPC M          -         *      -
IL   Insert Line               \E [ Pn L           1         eF     il
IND  Index                     \E D                -         FE     -
INT  Interrupt                 \E a                -         Fs     -
JFY  Justify                   \E [ Ps SPC F       0         FE     -
IS1  Info Separator #1 *       ^_                  -         *      -
IS2  Info Separator #1 *       ^^                  -         *      -
IS3  Info Separator #1 *       ^]                  -         *      -
IS4  Info Separator #1 *       ^\                  -         *      -
LF   Line Feed                 ^J                  -         -      -
LS1R Locking Shift Right 1 *   \E ~                -         -      -
LS2  Locking Shift 2 *         \E n                -         -      -
LS2R Locking Shift Right 2 *   \E }                -         -      -
LS3  Locking Shift 3 *         \E o                -         -      -
LS3R Locking Shift Right 3 *   \E |                -         -      -
MC   Media Copy                \E [ Ps i           0         -      -   (S)
MW   Message Waiting           \E U                -         -      -
NAK  Negative Acknowledge *    ^U                  -         *      -
NBH  No Break Here *           \E C                -         -      -
NEL  Next Line                 \E E                -         FE     nel (D)
NP   Next Page                 \E [ Pn U           1         eF     -
NUL  Null *                    ^@                  -         -      -
OSC  Operating System Command  \E ]                -         Delim  -
PEC  Pres. Expand/Contract *   \E Pn SPC Z         0         -      -
PFS  Page Format Selection *   \E Pn SPC J         0         -      -
PLD  Partial Line Down         \E K                -         FE     -   (T)
PLU  Partial Line Up           \E L                -         FE     -   (U)
PM   Privacy Message           \E ^                -         Delim  -
PP   Preceding Page            \E [ Pn V           1         eF     -
PPA  Page Position Absolute *  \E [ Pn SPC P       1         FE     -
PPB  Page Position Backward *  \E [ Pn SPC R       1         FE     -
PPR  Page Position Forward *   \E [ Pn SPC Q       1         FE     -
PTX  Parallel Texts *          \E [ \              -         -      -
PU1  Private Use 1             \E Q                -         -      -
PU2  Private Use 2             \E R                -         -      -
QUAD Typographic Quadding      \E [ Ps SPC H       0         FE     -
REP  Repeat Char or Control    \E [ Pn b           1         -      rep
RI   Reverse Index             \E M                -         FE     -   (V)
RIS  Reset to Initial State    \E c                -         Fs     -
RM   Reset Mode *              \E [ Ps l           -         -      -   (W)
SACS Set Add. Char. Sep. *     \E [ Pn SPC /       0         -      -
SAPV Sel. Alt. Present. Var. * \E [ Ps SPC ]       0         -      -   (X)
SCI  Single-Char Introducer    \E Z                -         -      -
SCO  Sel. Char. Orientation *  \E [ Pn ; Pn SPC k  -         -      -
SCS  Set Char. Spacing *       \E [ Pn SPC g       -         -      -
SD   Scroll Down               \E [ Pn T           1         eF     rin
SDS  Start Directed String *   \E [ Pn ]           1         -      -
SEE  Select Editing Extent     \E [ Ps Q           0         -      -   (Y)
SEF  Sheet Eject &amp;amp; Feed *  \E [ Ps ; Ps SPC Y  0,0       -      -
SGR  Select Graphic Rendition  \E [ Ps m           0         FE     sgr (O)
SHS  Select Char. Spacing *    \E [ Ps SPC K       0         -      -
SI   Shift In                  ^O                  -         -      -   (P)
SIMD Sel. Imp. Move Direct. *  \E [ Ps ^           -         -      -
SL   Scroll Left               \E [ Pn SPC @       1         eF     -
SLH  Set Line Home *           \E [ Pn SPC U       -         -      -
SLL  Set Line Limit *          \E [ Pn SPC V       -         -      -
SLS  Set Line Spacing *        \E [ Pn SPC h       -         -      -
SM   Select Mode               \E [ Ps h           none      -      -   (W)
SO   Shift Out                 ^N                  -         -      -   (Q)
SOH  Start Of Heading *        ^A                  -         -      -
SOS  Start of String *         \E X                -         -      -
SPA  Start of Protected Area   \E V                -         -      -   (Z)
SPD  Select Pres. Direction *  \E [ Ps ; Ps SPC S  0,0       -      -
SPH  Set Page Home *           \E [ Ps SPC G       -         -      -
SPI  Spacing Increment         \E [ Pn ; Pn SPC G  none      FE     -
SPL  Set Page Limit *          \E [ Ps SPC j       -         -      -
SPQR Set Pr. Qual. &amp;amp; Rapid. *  \E [ Ps SPC X       0         -      -
SR   Scroll Right              \E [ Pn SPC A       1         eF     -
SRCS Set Reduced Char. Sep. *  \E [ Pn SPC f       0         -      -
SRS  Start Reversed String *   \E [ Ps [           0         -      -
SSA  Start of Selected Area    \E F                -         -      -
SSU  Select Size Unit *        \E [ Pn SPC I       0         -      -
SSW  Set Space Width *         \E [ Pn SPC [       none      -      -
SS2  Single Shift 2 (G2 set)   \E N                -         Intro  -
SS3  Single Shift 3 (G3 set)   \E O                -         Intro  -
ST   String Terminator         \E \                -         Delim  -
STAB Selective Tabulation *    \E [ Pn SPC ^       -         -      -
STS  Set Transmit State        \E S                -         -      -
STX  Start pf Text *           ^B                  -         -      -
SU   Scroll Up                 \E [ Pn S           1         eF     indn
SUB  Substitute *              ^Z                  -         -      -
SVS  Select Line Spacing *     \E [ Pn SPC \       1         -      -
SYN  Synchronous Idle *        ^F                  -         -      -
TAC  Tabul. Aligned Centered * \E [ Pn SPC b       -         -      -
TALE Tabul. Al. Leading Edge * \E [ Pn SPC a       -         -      -
TATE Tabul. Al. Trailing Edge* \E [ Pn SPC `       -         -      -
TBC  Tab Clear                 \E [ Ps g           0         FE     tbc
TCC  Tabul. Centered on Char * \E [ Pn SPC c       -         -      -
TSR  Tabulation Stop Remove  * \E [ Pn SPC d       -         FE     -
TSS  Thin Space Specification  \E [ Pn SC E        none      FE     -
VPA  Vert. Position Absolute   \E [ Pn d           1         FE     vpa
VPB  Line Position Backward *  \E [ Pn k           1         FE     -
VPR  Vert. Position Relative   \E [ Pn e           1         FE     -   (R)
VPR  Vert. Position Relative   \E [ Pn e           1         FE     -   (R)
VT   Vertical Tabulation *     ^K                  -         FE     -
VTS  Vertical Tabulation Set   \E J                -         FE     -</pre>









<h3>Basic Characteristics</h3>
<p>This section documents the capabilities that describe the basic and nature of the terminal, and also those that are relevant to the output of graphic characters.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>os</td><td>Flag whose presence means that the terminal can overstrike.  This means that outputting a graphic character does not erase whatever was present in the same character position before.  The terminals that can overstrike include printing terminals, storage tubes (all obsolete nowadays), and many bit-map displays.</td></tr>
<tr><td>eo</td><td>Flag whose presence means that outputting a space erases a character position even if the terminal supports overstriking.  If this flag is not present and overstriking is supported, output of a space has no effect except to move the cursor.  (On terminals that do not support overstriking, you can always assume that outputting a space at a position erases whatever character was previously displayed there.)</td></tr>
<tr><td>gn</td><td>Flag whose presence means that this terminal type is a generic type which does not really describe any particular terminal.  Generic types are intended for use as the default type assigned when the user connects to the system, with the intention that the user should specify what type he really has.  One example of a generic type is the type <code>network</code>.  Since the generic type cannot say how to do anything interesting with the terminal, termcap-using programs will always find that the terminal is too weak to be supported if the user has failed to specify a real terminal type in place of the generic one.  The gnflag directs these programs to use a different error message: “You have not specified your real terminal type”, rather than “Your terminal is not powerful enough to be used”.</td></tr>
<tr><td>hc</td><td>Flag whose presence means this is a hardcopy terminal.</td></tr>
<tr><td>rp</td><td>String of commands to output a graphic character <var>c</var>, repeated <var>n</var> times.  The first parameter value is the ASCII code for the desired character, and the second parameter is the number of times to repeat the character.  Often this command requires padding proportional to the number of times the character is repeated.  This effect can be had by using parameter arithmetic with <code>&lt;samp&gt;%&lt;/samp&gt;</code>-sequences to compute the amount of padding, then generating the result as a number at the front of the string so that <code>tputs</code> will treat it as padding.</td></tr>
<tr><td>hz</td><td>Flag whose presence means that the ASCII character cannot be output on this terminal because it is used for display commands.  Programs handle this flag by checking all text to be output and replacing each ~with some other character(s).  If this is not done, the screen will be thoroughly garbled.  The old Hazeltine terminals that required such treatment are probably very rare today, so you might as well not bother to support this flag.</td></tr>
<tr><td>CC</td><td>String whose presence means the terminal has a settable command character.  The value of the string is the default command character (which is usually &lt;ESC&gt;).  All the strings of commands in the terminal description should be written to use the default command character.  If you are writing an application program that changes the command character, use the CCcapability to figure out how to translate all the display commands to work with the new command character.  Most programs have no reason to look at the CCcapability.</td></tr>
<tr><td>xb</td><td>Flag whose presence identifies Superbee terminals which are unable to transmit the characters &lt;ESC&gt; and <kbd>Control-C</kbd>.  Programs which support this flag are supposed to check the input for the code sequences sent by the &lt;F1&gt; and &lt;F2&gt; keys, and pretend that &lt;ESC&gt; or <kbd>Control-C</kbd> (respectively) had been read.  But this flag is obsolete, and not worth supporting.</td></tr>
</tbody></table>

<h2>7bit vs. 8bit</h2>
<p>These recommendations are optional.  IBCS2 allows the leading escape to # be either the 7-bit <code>\E[</code> or 8-bit <code>\0233</code> introducer, in accordance with # the ANSI X.364/ISO 6429/ECMA-48 standard.</p>
<blockquote><cite>1.6.1 Describing the Encoding</cite> <p>For example, the <code>cm</code> string for a standard ANSI terminal is written as <code>\E[%i%d;%dH</code>.  (<code>\E</code> stands for .)  <code>cm</code> by convention always requires two parameters, the vertical and horizontal goal positions, so this string specifies the encoding of two parameters.  Here <code>%i</code> increments the two values supplied, and each <code>%d</code> encodes one of the values in decimal.  If the cursor position values 20,58 are encoded with this string, the result is <code>\E[21;59H</code>.</p></blockquote>
<p>First, here are the <code>%</code>-sequences that generate output.  Except for <code>%%</code>, each of them encodes one parameter and advances the pointer to the following parameter.</p>
<ul>
<li><code>%%</code> Output a single <code>%</code>.  This is the only way to represent a literal <code>%</code> in a terminal command with parameters.  <code>%%</code> does not use up a parameter.</li>
<li><code>%d</code> As in <code>printf</code>, output the next parameter in decimal.</li>
<li><code>%2</code> Like <code>%02d</code> in <code>printf</code>: output the next parameter in decimal, and always use at least two digits.</li>
<li><code>%3</code> Like <code>%03d</code> in <code>printf</code>: output the next parameter in decimal, and always use at least three digits.  Note that <code>%4</code> and so on are _not_ defined.</li>
<li><code>%.</code> Output the next parameter as a single character whose ASCII code is the parameter value.  Like <code>%c</code> in <code>printf</code>.</li>
<li><code>%+CHAR</code> Add the next parameter to the character CHAR, and output the resulting character.  For example, <code>%+ </code> represents 0 as a space, 1 as <code>!</code>, etc.</li>
</ul>

<p>The following <code>%</code>-sequences specify alteration of the parameters (their values, or their order) rather than encoding a parameter for output.  They generate no output; they are used only for their side effects on the parameters.  Also, they do not advance the "next parameter" pointer except as explicitly stated.  Only <code>%i</code>, <code>%r</code> and <code>%&gt;</code> are defined in standard Unix termcap.  The others are GNU extensions.</p>
<ul>
<li><code>%i</code> Increment the next two parameters.  This is used for terminals that expect cursor positions in origin 1.  For example, <code>%i%d,%d</code> would output two parameters with <code>1</code> for 0, <code>2</code> for 1, etc.</li>
<li><code>%r</code> Interchange the next two parameters.  This is used for terminals whose cursor positioning command expects the horizontal position first.</li>
<li><code>%s</code> Skip the next parameter.  Do not output anything.</li>
<li><code>%b</code> Back up one parameter.  The last parameter used will become once again the next parameter to be output, and the next output command will use it.  Using <code>%b</code> more than once, you can back up any number of parameters, and you can refer to each parameter any number of times.</li>
<li><code>%&gt;C1C2</code> Conditionally increment the next parameter.  Here C1 and C2 are characters which stand for their ASCII codes as numbers.  If the next parameter is greater than the ASCII code of C1, the ASCII code of C2 is added to it.</li>
<li><code>%a OP TYPE POS</code> Perform arithmetic on the next parameter, do not use it up, and do not output anything.  Here OP specifies the arithmetic operation, while TYPE and POS together specify the other operand.</li>
</ul>


<p>Spaces are used above to separate the operands for clarity; the spaces don't appear in the data base, where this sequence is exactly five characters long.  The character OP says what kind of arithmetic operation to perform.  It can be any of these characters:</p>
<ul>
<li><var>=</var> - assign a value to the next parameter, ignoring its old value.   The new value comes from the other operand.</li>
<li><var>+</var> - add the other operand to the next parameter.</li>
<li><var>-</var> - subtract the other operand from the next parameter.</li>
<li><var>*</var> - multiply the next parameter by the other operand.</li>
<li><var>/</var> - divide the next parameter by the other operand.</li>
</ul>

<p>The "other operand" may be another parameter's value or a constant; the character TYPE says which.  It can be:</p>
<ul>
<li><var>p</var> - Use another parameter.  The character POS says which   parameter to use.  Subtract 64 from its ASCII code to get the   position of the desired parameter relative to this one.  Thus,   the character <code>A</code> as POS means the parameter after the next   one; the character <code>?</code> means the parameter before the next   one.</li>
<li><var>c</var> - Use a constant value.  The character POS specifies the value   of the constant.  The 0200 bit is cleared out, so that 0200   can be used to represent zero.</li>
</ul>

<p>The following <code>%</code>-sequences are special purpose hacks to compensate for the weird designs of obscure terminals.  They modify the next parameter or the next two parameters but do not generate output and do not use up any parameters.  <code>%m</code> is a GNU extension; the others are defined in standard Unix termcap.</p>
<ul>
<li><var>%n</var> - Exclusive-or the next parameter with 0140, and likewise the parameter after next.</li>
<li><var>%m</var> - Complement all the bits of the next parameter and the parameter after next.</li>
<li><var>%B</var> - Encode the next parameter in BCD.  It alters the value of the parameter by adding six times the quotient of the parameter by ten. Here is a C statement that shows how the new value is computed:  <code>PARM = (PARM / 10) * 16 + PARM % 10;</code></li>
<li><var>%D</var> - Transform the next parameter as needed by Delta Data terminals. This involves subtracting twice the remainder of the parameter by 16.  <code>PARM -= 2 * (PARM % 16);</code></li>
</ul>

<h2>Terminal Type Name Conventions</h2>
<p>Here is a list of standard suffixes and their conventional meanings:</p>
<ul>
<li><var>-w</var> - Short for "wide".  This is a mode that gives the terminal more columns than usual.  This is normally a user option.</li>
<li><var>-am</var> - "Automatic margins".  This is an alternate description for use when the terminal's margin-wrap switch is on; it contains the <code>am</code> flag.  The implication is that normally the switch is off and the usual description for the terminal says that the switch is off.</li>
<li><var>-nam</var> - "No automatic margins".  The opposite of <code>-am</code>, this names an alternative description which lacks the <code>am</code> flag.  This implies that the terminal is normally operated with the margin-wrap switch turned on, and the normal description of the terminal says so.</li>
<li><var>-na</var> - "No arrows".  This terminal description initializes the terminal to keep its arrow keys in local mode.  This is a user option.</li>
<li><var>-rv</var> - "Reverse video".  This terminal description causes text output for normal video to appear as reverse, and text output for reverse video to come out as normal.  Often this description differs from the usual one by interchanging the two strings which turn reverse video on and off.</li>
</ul>

<p>This is a user option; you can choose either the "reverse video" variant terminal type or the normal terminal type, and termcap will obey.</p>
<ul>
<li><var>-s</var> - "Status".  Says to enable use of a status line which ordinary output does not touch (*note Status Line::).</li>
</ul>

<p>Some terminals have a special line that is used only as a status line.  For these terminals, there is no need for an <code>-s</code> variant; the status line commands should be defined by default.  On other terminals, enabling a status line means removing one screen line from ordinary use and reducing the effective screen height.  For these terminals, the user can choose the <code>-s</code> variant type to request use of a status line.</p>
<ul>
<li><var>-NLINES</var> - Says to operate with NLINES lines on the screen, for terminals such as the Ambassador which provide this as an option.  Normally this is a user option; by choosing the terminal type, you control how many lines termcap will use.</li>
<li><var>-NPAGESp</var> - Says that the terminal has NPAGES pages worth of screen memory, for terminals where this is a hardware option.</li>
<li><var>-unk</var> - Says that description is not for direct use, but only for reference in <code>tc</code> capabilities.  Such a description is a kind of subroutine, because it describes the common characteristics of several variant descriptions that would use other suffixes in place of <code>-unk</code>.</li>
</ul>

<h2>MS-DOS ANSI.SYS</h2>
<p>Here is a description of the color and attribute controls supported in the ANSI.SYS driver under MS-DOS.  Most console drivers and ANSI terminal emulators for Intel boxes obey these.  They are a proper subset of the ECMA-48 escapes.</p>
<p>Bright black becomes gray, bright brown becomes yellow. These coincide with the prescriptions of the ISO 6429/ECMA-48 standard.  * If the 5 attribute is on and you set a background color (40-47) it is supposed to enable bright background.</p>
<pre>0        all attributes off
1        foreground bright
4        underscore on
5        blink on/background bright (not reliable with brown)
7        reverse-video
8        set blank (non-display)
10       set primary font
11       set first alternate font (on PCs, display ROM characters 1-31)
12       set second alternate font (on PCs, display IBM high-half chars)
3n       set foreground color       / 0=black, 1=red,     2=green, 3=brown,
4n       set background color       \ 4=blue,  5=magenta, 6=cyan,  7=white</pre>

<h2>STTY</h2>
<h3>Stty Control Settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>parenb</td><td><code>parenb</code> Generate parity bit in output and expect parity bit in input.  May be negated.</td></tr>
<tr><td>parodd</td><td>Set odd parity (even if negated).  May be negated.</td></tr>
<tr><td>cs5, cs6, cs7, cs8</td><td>Set character size to 5, 6, 7, or 8 bits.</td></tr>
<tr><td>hup, hupcl</td><td>Send a hangup signal when the last process closes the tty.  May be negated.</td></tr>
<tr><td>cstopb</td><td>Use two stop bits per character (one if negated).  May be negated.</td></tr>
<tr><td>cread</td><td>Allow input to be received.  May be negated.</td></tr>
<tr><td>clocal</td><td>Disable modem control signals.  May be negated.</td></tr>
<tr><td>crtscts</td><td>Enable RTS/CTS flow control. Disables DTR/DSR flow control. Non-POSIX.  May be negated.</td></tr>
<tr><td>cdtrdsr</td><td>Enable DTR/DSR flow control. Disables RTS/CTS flow control. Non-POSIX.  May be negated.  No stty-readable form available.  It needs to be supported by device.  Usage on device without DTR/DSR support could lead to an error and failure of <code>stty</code>.</td></tr>
</tbody></table><h3>Stty Input settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>ignbrk</td><td>Ignore break characters.  May be negated.</td></tr>
<tr><td>brkint</td><td>Make breaks cause an interrupt signal.  May be negated.</td></tr>
<tr><td>ignpar</td><td>Ignore characters with parity errors.  May be negated.</td></tr>
<tr><td>parmrk</td><td>Mark parity errors (with a 255-0-character sequence).  May be negated.</td></tr>
<tr><td>inpck</td><td>Enable input parity checking.  May be negated.</td></tr>
<tr><td>istrip</td><td>Clear high (8th) bit of input characters.  May be negated.</td></tr>
<tr><td>inlcr</td><td>Translate newline to carriage return.  May be negated.</td></tr>
<tr><td>igncr</td><td>Ignore carriage return.  May be negated.</td></tr>
<tr><td>icrnl</td><td>Translate carriage return to newline.  May be negated.</td></tr>
<tr><td>iutf8</td><td>Assume input characters are UTF-8 encoded.  May be negated.</td></tr>
<tr><td>ixon</td><td>Enable XON/XOFF flow control (that is, <code>CTRL-S</code>/<code>CTRL-Q</code>).  May be negated.</td></tr>
<tr><td>ixoff, tandem</td><td>Enable sending of <code>stop</code> character when the system input buffer is almost full, and <code>start</code> character when it becomes almost empty again.  May be negated.</td></tr>
<tr><td>iuclc</td><td>Translate uppercase characters to lowercase.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ixany</td><td>Allow any character to restart output (only the start character if negated).  Non-POSIX.  May be negated.</td></tr>
<tr><td>imaxbel</td><td>Enable beeping and not flushing input buffer if a character arrives when the input buffer is full.  Non-POSIX.  May be negated.</td></tr>
</tbody></table>
<h3>Stty Output settings</h3>
<p>These arguments specify output-related operations.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>opost</td><td>Postprocess output.  May be negated.</td></tr>
<tr><td>olcuc</td><td>Translate lowercase characters to uppercase.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ocrnl</td><td>Translate carriage return to newline.  Non-POSIX.  May be negated.</td></tr>
<tr><td>onlcr</td><td>Translate newline to carriage return-newline.  Non-POSIX.  May be negated.</td></tr>
<tr><td>onocr</td><td>Do not print carriage returns in the first column.  Non-POSIX. May be negated.</td></tr>
<tr><td>onlret</td><td>Newline performs a carriage return.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ofill</td><td>Use fill (padding) characters instead of timing for delays. Non-POSIX.  May be negated.</td></tr>
<tr><td>ofdel</td><td>Use delete characters for fill instead of null characters. Non-POSIX.  May be negated.</td></tr>
<tr><td>nl1, nl0</td><td>Newline delay style.  Non-POSIX.</td></tr>
<tr><td>cr3, cr2, cr1, cr0</td><td>Carriage return delay style.  Non-POSIX.</td></tr>
<tr><td>tab3, tab2, tab1, tab0</td><td>Horizontal tab delay style.  Non-POSIX.</td></tr>
<tr><td>bs1, bs0</td><td>Backspace delay style.  Non-POSIX.</td></tr>
<tr><td>vt1, vt0</td><td>Vertical tab delay style.  Non-POSIX.</td></tr>
<tr><td>ff1, ff0</td><td>Form feed delay style.  Non-POSIX.</td></tr>
</tbody></table>
<h3>Stty Local settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>isig</td><td>Enable <code>interrupt</code>, <code>quit</code>, and <code>suspend</code> special characters.  May be negated.</td></tr>
<tr><td>icanon</td><td>Enable <code>erase</code>, <code>kill</code>, <code>werase</code>, and <code>rprnt</code> special characters. May be negated.</td></tr>
<tr><td>iexten</td><td>Enable non-POSIX special characters.  May be negated.</td></tr>
<tr><td>echo</td><td>Echo input characters.  May be negated.</td></tr>
<tr><td>echoe, crterase</td><td>Echo <code>erase</code> characters as backspace-space-backspace.  May be negated.</td></tr>
<tr><td>echok</td><td>Echo a newline after a <code>kill</code> character.  May be negated.</td></tr>
<tr><td>echonl</td><td>Echo newline even if not echoing other characters.  May be negated.</td></tr>
<tr><td>noflsh</td><td>Disable flushing after <code>interrupt</code> and <code>quit</code> special characters. May be negated.</td></tr>
<tr><td>xcase</td><td>Enable input and output of uppercase characters by preceding their lowercase equivalents with <code>\</code>, when <code>icanon</code> is set.  Non-POSIX. May be negated.</td></tr>
<tr><td>tostop</td><td>Stop background jobs that try to write to the terminal.  Non-POSIX. May be negated.</td></tr>
<tr><td>echoprt, prterase</td><td>Echo erased characters backward, between <code>\</code> and <code>/</code>.  Non-POSIX. May be negated.</td></tr>
<tr><td>echoctl, ctlecho</td><td>Echo control characters in hat notation (<code>^C</code>) instead of literally.  Non-POSIX.  May be negated.</td></tr>
<tr><td>echoke, crtkill</td><td>Echo the <code>kill</code> special character by erasing each character on the line as indicated by the <code>echoprt</code> and <code>echoe</code> settings, instead of by the <code>echoctl</code> and <code>echok</code> settings.  Non-POSIX.  May be negated.</td></tr>
</tbody></table>
<h3>Stty Combination settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>evenp, parity</td><td>Same as <code>parenb -parodd cs7</code>.  May be negated.  If negated, same as <code>-parenb cs8</code>.</td></tr>
<tr><td>oddp</td><td>Same as <code>parenb parodd cs7</code>.  May be negated.  If negated, same as <code>-parenb cs8</code>.</td></tr>
<tr><td>nl</td><td>Same as <code>-icrnl -onlcr</code>.  May be negated.  If negated, same as <code>icrnl -inlcr -igncr onlcr -ocrnl -onlret</code>.</td></tr>
<tr><td>ek</td><td>Reset the <code>erase</code> and <code>kill</code> special characters to their default values.</td></tr>
<tr><td>sane</td><td>Sets all special characters to their default values and: <pre>cread -ignbrk brkint -inlcr -igncr icrnl -ixoff -iuclc -ixany imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke</pre></td></tr>
<tr><td>cooked</td><td>Same as <code>brkint ignpar istrip icrnl ixon opost isig icanon</code>, plus sets the <code>eof</code> and <code>eol</code> characters to their default values if they are the same as the <code>min</code> and <code>time</code> characters.  May be negated.  If negated, same as <code>raw</code>.</td></tr>
<tr><td>raw</td><td>Same as: <pre>-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon -xcase min 1 time 0</pre> May be negated.  If negated, same as <code>cooked</code>.</td></tr>
<tr><td>cbreak</td><td>Same as <code>-icanon</code>.  May be negated.  If negated, same as <code>icanon</code>.</td></tr>
<tr><td>pass8</td><td>Same as <code>-parenb -istrip cs8</code>.  May be negated.  If negated, same as <code>parenb istrip cs7</code>.</td></tr>
<tr><td>litout</td><td>Same as <code>-parenb -istrip -opost cs8</code>.  May be negated.  If negated, same as <code>parenb istrip opost cs7</code>.</td></tr>
<tr><td>decctlq</td><td>Same as <code>-ixany</code>.  Non-POSIX.  May be negated.</td></tr>
<tr><td>tabs</td><td>Same as <code>tab0</code>.  Non-POSIX.  May be negated.  If negated, same as <code>tab3</code>.</td></tr>
<tr><td>lcase, LCASE</td><td>Same as <code>xcase iuclc olcuc</code>.  Non-POSIX.  May be negated.</td></tr>
<tr><td>crt</td><td>Same as <code>echoe echoctl echoke</code>.</td></tr>
<tr><td>dec</td><td>Same as <code>echoe echoctl echoke -ixany intr ^C erase ^? kill C-u</code>.</td></tr>
</tbody></table>

<h3>Special characters</h3>
<p>The special characters' default values vary from system to system. They are set with the syntax <code>name value</code>, where the names are listed below and the value can be given either literally, in hat notation (<code>^C</code>), or as an integer which may start with <code>0x</code> to indicate hexadecimal, <code>0</code> to indicate octal, or any other digit to indicate decimal.</p>
<p>For GNU stty, giving a value of <code>^-</code> or <code>undef</code> disables that special character.  (This is incompatible with Ultrix <code>stty</code>, which uses  a value of <code>u</code> to disable a special character.  GNU <code>stty</code> treats a value <code>u</code> like any other, namely to set that special character to .)</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>intr</var></td><td>Send an interrupt signal.</td></tr>
<tr><td><var>quit</var></td><td>Send a quit signal.</td></tr>
<tr><td><var>erase</var></td><td>Erase the last character typed.</td></tr>
<tr><td><var>kill</var></td><td>Erase the current line.</td></tr>
<tr><td><var>eof</var></td><td>Send an end of file (terminate the input).</td></tr>
<tr><td><var>eol</var></td><td>End the line.</td></tr>
<tr><td><var>eol2</var></td><td>Alternate character to end the line.  Non-POSIX.</td></tr>
<tr><td><var>swtch</var></td><td>Switch to a different shell layer.  Non-POSIX.</td></tr>
<tr><td><var>start</var></td><td>Restart the output after stopping it.</td></tr>
<tr><td><var>stop</var></td><td>Stop the output.</td></tr>
<tr><td><var>susp</var></td><td>Send a terminal stop signal.</td></tr>
<tr><td><var>dsusp</var></td><td>Send a terminal stop signal after flushing the input.  Non-POSIX.</td></tr>
<tr><td><var>rprnt</var></td><td>Redraw the current line.  Non-POSIX.</td></tr>
<tr><td><var>werase</var></td><td>Erase the last word typed.  Non-POSIX.</td></tr>
<tr><td><var>lnext</var></td><td>Enter the next character typed literally, even if it is a special character.  Non-POSIX.</td></tr>
</tbody></table>


<h3>Special settings</h3>
<ul>
<li><var>min N</var> - Set the minimum number of characters that will satisfy a read until the time value has expired, when <code>-icanon</code> is set.</li>
<li><var>time N</var> - Set the number of tenths of a second before reads time out if the minimum number of characters have not been read, when <code>-icanon</code> is set.</li>
<li><var>ispeed N</var> - Set the input speed to N.</li>
<li><var>ospeed N</var> - Set the output speed to N.</li>
<li><var>rows N</var> - Tell the tty kernel driver that the terminal has N rows. Non-POSIX.</li>
<li><var>cols N</var>, <var>columns N</var> - Tell the kernel that the terminal has N columns.  Non-POSIX.</li>
<li><var>size</var> - Print the number of rows and columns that the kernel thinks the terminal has.  (Systems that don't support rows and columns in the kernel typically use the environment variables <code>LINES</code> and <code>COLUMNS</code> instead; however, GNU <code>stty</code> does not know anything about them.)  Non-POSIX.</li>
<li><var>line N</var> - Use line discipline N.  Non-POSIX.</li>
<li><var>speed</var> - Print the terminal speed.</li>
<li><var>N</var> - Set the input and output speeds to N.  N can be one of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 <code>exta</code> <code>extb</code>.  <code>exta</code> is the same as 19200; <code>extb</code> is the same as 38400.  0 hangs up the line if <code>-clocal</code> is set.</li>
</ul>


<h2>Color Terminals</h2>
<pre>color256 ()
{
    local L=$(sed &#039;s/[0-9]//g; s/./#/g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS - 10))`);
    for i in `seq 0 $(tput colors)`;
    do printf " %.3d `tput setab $i`${L}${R} %.3d `tput setab 0;tput setaf 7`\n" $i $i | tr &#039;#&#039; &#039; &#039;;
    done
}</pre>

<pre>for F in `find ~/.terminfo/ -type f | sed &#039;s/^.*\///&#039; | xargs -P0 -I&#039;TT&#039; sh -c &#039;echo "$(tput -T TT colors): TT"&#039;|sed &#039;/^-/d&#039;| grep ^16:|cut -d: -f2`; do
echo -e "\n\n";
pm $F; export TERM=$F; tput -T $F initc; color256; done</pre>

<pre>find ~/.terminfo/ -type f | sed &#039;s/^.*\///&#039; | xargs -I&#039;TT&#039; sh -c &#039;echo "$(tput -T TT colors): TT"&#039;|sed &#039;/^-/d&#039;</pre>

<h3>Terminals with 16 Colors</h3>
<ul>
<li><var>aixterm-16color</var></li>
<li><var>amiga-vnc</var></li>
<li><var>hp2397</var></li>
<li><var>hp2397a</var></li>
<li><var>hp+color</var></li>
<li><var>ibm+16color</var></li>
<li><var>konsole-16color</var></li>
<li><var>nsterm-16color</var></li>
<li><var>nsterm-7-c</var></li>
<li><var>nsterm-7-c-s</var></li>
<li><var>nsterm-acs-c</var></li>
<li><var>nsterm-acs-c-s</var></li>
<li><var>nsterm-c</var></li>
<li><var>nsterm+c</var></li>
<li><var>nsterm-c-7</var></li>
<li><var>nsterm-c-acs</var></li>
<li><var>nsterm-c-s</var></li>
<li><var>nsterm-c-s-7</var></li>
<li><var>nsterm-c-s-acs</var></li>
<li><var>rxvt-16color</var></li>
<li><var>screen-16color</var></li>
<li><var>screen-16color-bce</var></li>
<li><var>screen-16color-bce-s</var></li>
<li><var>screen-16color-s</var></li>
<li><var>xterm-16color</var></li>
</ul>

<h3>Terminals with 52 Colors</h3>
<ul>
<li><var>d430c-dg-ccc</var></li>
<li><var>d430c-unix-25-ccc</var></li>
<li><var>d430c-unix-ccc</var></li>
<li><var>d430c-unix-s-ccc</var></li>
<li><var>d430c-unix-sr-ccc</var></li>
<li><var>d430c-unix-w-ccc</var></li>
<li><var>d430-dg-ccc</var></li>
<li><var>d430-unix-25-ccc</var></li>
<li><var>d430-unix-ccc</var></li>
<li><var>d430-unix-s-ccc</var></li>
<li><var>d430-unix-sr-ccc</var></li>
<li><var>d430-unix-w-ccc</var></li>
<li><var>dg+ccc</var></li>
<li><var>dgunix+ccc</var></li>
</ul>

<h3>Terminals with 64 Colors</h3>
<ul>
<li><var>hpterm-color</var></li>
<li><var>wy370</var></li>
<li><var>wy370-101k</var></li>
<li><var>wy370-105k</var></li>
<li><var>wy370-EPC</var></li>
<li><var>wy370-nk</var></li>
<li><var>wy370-rv</var></li>
<li><var>wy370-vb</var></li>
<li><var>wy370-w</var></li>
<li><var>wy370-wvb</var></li>
<li><var>wyse370</var></li>
<li><var>Eterm-88color</var></li>
<li><var>rxvt-88color</var></li>
<li><var>xterm-88color</var></li>
<li><var>xterm+88color</var></li>
</ul>

<h3>Terminals with 256 colors</h3>
<ul>
<li><var>Eterm-256color</var></li>
<li><var>gnome-256color</var></li>
<li><var>konsole-256color</var></li>
<li><var>putty-256color</var></li>
<li><var>rxvt-256color</var></li>
<li><var>screen-256color</var></li>
<li><var>screen-256color-bce</var></li>
<li><var>screen-256color-bce-s</var></li>
<li><var>screen-256color-s</var></li>
<li><var>xterm-256color</var></li>
<li><var>xterm+256color</var></li>
</ul>


<h3>View All tput capabilities</h3>
<p><a href="http://blogs.msdn.com/adioltean/articles/271063.aspx">http://blogs.msdn.com/adioltean/articles/271063.aspx</a></p>
<pre>function tputs(){ infocmp -1|sed &#039;s/^[   ]*//; /=/!d; s/=.*//g; /[#\|]/d&#039;; }</pre>

<p>Some  common  terminfo  parameter sequences, their termcap equivalents, and some terminal types which commonly have such sequences, are:</p>
<pre>terminfo                    termcap   Representative Terminals
---------------------------------------------------------------
%p1%c                       %.        adm
%p1%d                       %d        hp, ANSI standard, vt100
%p1%+%c                 %+x       concept
%i                          %iq       ANSI standard, vt100
%p1%?%&gt;%t%p1%+%;    %&gt;xy      concept
%p2 is printed before %p1   %r        hp</pre>



<h2>Installing your Own Terminfo</h2>
<p><a href="http://nion.modprobe.de/mostlike.txt">MostLike</a>, or if that is offline I uploaded a copy: <a href="http://uploads.askapache.com/2010/03/mostlike.txt">mostlike - manpages with color looking like most</a></p>
<pre>rm -rvf ~/.terminfo
mkdir -pv ~/.terminfo
curl -o terminfo.master http://nion.modprobe.de/mostlike.txt; curl -Ss ftp://invisible-island.net/ncurses/terminfo.src.gz
export TERMINFO=~/.terminfo;
sudo tic -e screen-256color,screen-256color-s,screen-256color-bce,screen-256color-bce-s,xterm+256color,xterm,xterm-pcolor terminfo.src</pre>


<h2>256 Colors in Terminal</h2>
<h3>256 Colors (Background)</h3>
<pre>W=`tput setaf 7` RC="\E[0;0;0m" L=$(sed &#039;s/[0-9]//g; s/./ /g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS/2))`);
&nbsp;
for i in `seq 0 256`;
do
  printf "${W}\n%.3d `tput setab $i`${L}${RC}" $i;
done</pre>



<h3>256 Colors (Foreground)</h3>
<pre>W=`tput setaf 7` WB=`tput setab 0` RC="\E[0;0;0m" L=$(sed &#039;s/[0-9]//g; s/./#/g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS/2))`);
for i in `seq 0 256`;
do
  printf "${WB}\n%.3d `tput setaf $i`${L}${RC}" $i;
done</pre>



<h2>Terminal Capabilities - Infocmp</h2>
<pre>infocmp -1Lq|grep -v "$TERM\|#"|tr -d &#039;  &#039;</pre>

<h3>DEC/ANSI special sequences</h3>
<p>List of the DEC/ANSI special sequences recognized:</p>
<table class="bordered">
<tbody>
<tr class="header">
<th>Action</th>
<th>Meaning</th>
</tr>
<tr><td><code>%%</code></td>
        <td>The percent sign</td></tr>
<tr class="odd"><td><code>%t</code></td>
        <td>The time the request was received in Universal Coordinated Time
        since the epoch (Jan. 1, 1970) measured in microseconds. The value
        is preceded by <code>t=</code>.</td></tr>
<tr><td><code>%D</code></td>
        <td>The time from when the request was received to the time the
        headers are sent on the wire. This is a measure of the duration
        of the request. The value is preceded by <code>D=</code>.
        The value is measured in microseconds.</td></tr>
<tr class="odd"><td><code>%{VARNAME}e</code></td>
        <td>The contents of the <a href="../env.html">environment
        variable</a> <code>VARNAME</code>.</td></tr>
<tr><td><code>%{VARNAME}s</code></td>
        <td>The contents of the <a href="mod_ssl.html#envvars">SSL environment
        variable</a> <code>VARNAME</code>, if <code>&lt;a href="../mod/mod_ssl.html"&gt;mod_ssl&lt;/a&gt;</code> is enabled.</td></tr>

-----------------------------------------
<tr><td><code>RIS         </code></td><td>full reset</td></tr>
<tr><td><code>SC          </code></td><td>save cursor</td></tr>
<tr><td><code>RC          </code></td><td>restore cursor</td></tr>
<tr><td><code>LL          </code></td><td>home-down</td></tr>
<tr><td><code>RSR         </code></td><td>reset scroll region</td></tr>
-----------------------------------------
<tr><td><code>DECSTR      </code></td><td>soft reset (VT320)</td></tr>
<tr><td><code>S7C1T       </code></td><td>7-bit controls (VT220)</td></tr>
-----------------------------------------
<tr><td><code>ISO DEC G0  </code></td><td>enable DEC graphics for G0</td></tr>
<tr><td><code>ISO UK G0   </code></td><td>enable UK chars for G0</td></tr>
<tr><td><code>ISO US G0   </code></td><td>enable US chars for G0</td></tr>
<tr><td><code>ISO DEC G1  </code></td><td>enable DEC graphics for G1</td></tr>
<tr><td><code>ISO UK G1   </code></td><td>enable UK chars for G1</td></tr>
<tr><td><code>ISO US G1   </code></td><td>enable US chars for G1</td></tr>
-----------------------------------------
<tr><td><code>DECPAM      </code></td><td>application keypad mode</td></tr>
<tr><td><code>DECPNM      </code></td><td>normal keypad mode</td></tr>
<tr><td><code>DECANSI     </code></td><td>enter ANSI mode</td></tr>
-----------------------------------------
<tr><td><code>ECMA[+-]AM  </code></td><td>keyboard action mode</td></tr>
<tr><td><code>ECMA[+-]IRM </code></td><td>insert replace mode</td></tr>
<tr><td><code>ECMA[+-]SRM </code></td><td>send receive mode</td></tr>
<tr><td><code>ECMA[+-]LNM </code></td><td>linefeed mode</td></tr>
-----------------------------------------
<tr><td><code>DEC[+-]CKM  </code></td><td>application cursor keys</td></tr>
<tr><td><code>DEC[+-]ANM  </code></td><td>set VT52 mode</td></tr>
<tr><td><code>DEC[+-]COLM </code></td><td>132-column mode</td></tr>
<tr><td><code>DEC[+-]SCLM </code></td><td>smooth scroll</td></tr>
<tr><td><code>DEC[+-]SCNM </code></td><td>reverse video mode</td></tr>
<tr><td><code>DEC[+-]OM   </code></td><td>origin mode</td></tr>
<tr><td><code>DEC[+-]AWM  </code></td><td>wraparound mode</td></tr>
<tr><td><code>DEC[+-]ARM  </code></td><td>auto-repeat mode</td></tr>
</tbody>
</table>




<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><a id="acs_chars">acs_chars</a></td><td><code>``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,</code></td></tr>
<tr><td><a id="back_tab">back_tab</a></td><td><code>\E[Z,</code></td></tr>
<tr><td><a id="bell">bell</a></td><td><code>^G,</code></td></tr>
<tr><td><a id="carriage_return">carriage_return</a></td><td><code>^M,</code></td></tr>
<tr><td><a id="change_scroll_region">change_scroll_region</a></td><td><code>\E[%i%p1%d;%p2%dr,</code></td></tr>
<tr><td><a id="clear_all_tabs">clear_all_tabs</a></td><td><code>\E[3g,</code></td></tr>
<tr><td><a id="clear_screen">clear_screen</a></td><td><code>\E[H\E[2J,</code></td></tr>
<tr><td><a id="clr_bol">clr_bol</a></td><td><code>\E[1K,</code></td></tr>
<tr><td><a id="clr_eol">clr_eol</a></td><td><code>\E[K,</code></td></tr>
<tr><td><a id="clr_eos">clr_eos</a></td><td><code>\E[J,</code></td></tr>
<tr><td><a id="column_address">column_address</a></td><td><code>\E[%i%p1%dG,</code></td></tr>
<tr><td><a id="cursor_address">cursor_address</a></td><td><code>\E[%i%p1%d;%p2%dH,</code></td></tr>
<tr><td><a id="cursor_down">cursor_down</a></td><td><code>^J,</code></td></tr>
<tr><td><a id="cursor_home">cursor_home</a></td><td><code>\E[H,</code></td></tr>
<tr><td><a id="cursor_invisible">cursor_invisible</a></td><td><code>\E[?25l,</code></td></tr>
<tr><td><a id="cursor_left">cursor_left</a></td><td><code>^H,</code></td></tr>
<tr><td><a id="cursor_normal">cursor_normal</a></td><td><code>\E[?12l\E[?25h,</code></td></tr>
<tr><td><a id="cursor_right">cursor_right</a></td><td><code>\E[C,</code></td></tr>
<tr><td><a id="cursor_up">cursor_up</a></td><td><code>\E[A,</code></td></tr>
<tr><td><a id="cursor_visible">cursor_visible</a></td><td><code>\E[?12;25h,</code></td></tr>
<tr><td><a id="delete_character">delete_character</a></td><td><code>\E[P,</code></td></tr>
<tr><td><a id="delete_line">delete_line</a></td><td><code>\E[M,</code></td></tr>
<tr><td><a id="enter_alt_charset_mode">enter_alt_charset_mode</a></td><td><code>\E(0,</code></td></tr>
<tr><td><a id="enter_am_mode">enter_am_mode</a></td><td><code>\E[?7h,</code></td></tr>
<tr><td><a id="enter_blink_mode">enter_blink_mode</a></td><td><code>\E[5m,</code></td></tr>
<tr><td><a id="enter_bold_mode">enter_bold_mode</a></td><td><code>\E[1m,</code></td></tr>
<tr><td><a id="enter_ca_mode">enter_ca_mode</a></td><td><code>\E[?1049h,</code></td></tr>
<tr><td><a id="enter_insert_mode">enter_insert_mode</a></td><td><code>\E[4h,</code></td></tr>
<tr><td><a id="enter_reverse_mode">enter_reverse_mode</a></td><td><code>\E[7m,</code></td></tr>
<tr><td><a id="enter_secure_mode">enter_secure_mode</a></td><td><code>\E[8m,</code></td></tr>
<tr><td><a id="enter_standout_mode">enter_standout_mode</a></td><td><code>\E[7m,</code></td></tr>
<tr><td><a id="enter_underline_mode">enter_underline_mode</a></td><td><code>\E[4m,</code></td></tr>
<tr><td><a id="erase_chars">erase_chars</a></td><td><code>\E[%p1%dX,</code></td></tr>
<tr><td><a id="exit_alt_charset_mode">exit_alt_charset_mode</a></td><td><code>\E(B,</code></td></tr>
<tr><td><a id="exit_am_mode">exit_am_mode</a></td><td><code>\E[?7l,</code></td></tr>
<tr><td><a id="exit_attribute_mode">exit_attribute_mode</a></td><td><code>\E(B\E[m,</code></td></tr>
<tr><td><a id="exit_ca_mode">exit_ca_mode</a></td><td><code>\E[?1049l,</code></td></tr>
<tr><td><a id="exit_insert_mode">exit_insert_mode</a></td><td><code>\E[4l,</code></td></tr>
<tr><td><a id="exit_standout_mode">exit_standout_mode</a></td><td><code>\E[27m,</code></td></tr>
<tr><td><a id="exit_underline_mode">exit_underline_mode</a></td><td><code>\E[24m,</code></td></tr>
<tr><td><a id="flash_screen">flash_screen</a></td><td><code>\E[?5h$&lt;100/&gt;\E[?5l,</code></td></tr>
<tr><td><a id="init_2string">init_2string</a></td><td><code>\E[\041p\E[?3;4l\E[4l\E&gt;,</code></td></tr>
<tr><td><a id="initialize_color">initialize_color</a></td><td><code>\E]4;%p1%d;rgb\072%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\,</code></td></tr>
<tr><td><a id="insert_line">insert_line</a></td><td><code>\E[L,</code></td></tr>
<tr><td><a id="key_b2">key_b2</a></td><td><code>\EOE,</code></td></tr>
<tr><td><a id="key_backspace">key_backspace</a></td><td><code>\177,</code></td></tr>
<tr><td><a id="key_btab">key_btab</a></td><td><code>\E[Z,</code></td></tr>
<tr><td><a id="key_dc">key_dc</a></td><td><code>\E[3~,</code></td></tr>
<tr><td><a id="key_down">key_down</a></td><td><code>\EOB,</code></td></tr>
<tr><td><a id="key_end">key_end</a></td><td><code>\EOF,</code></td></tr>
<tr><td><a id="key_enter">key_enter</a></td><td><code>\EOM,</code></td></tr>
<tr><td><a id="key_f1">key_f1</a></td><td><code>\EOP,</code></td></tr>
<tr><td><a id="key_f10">key_f10</a></td><td><code>\E[21~,</code></td></tr>
<tr><td><a id="key_f11">key_f11</a></td><td><code>\E[23~,</code></td></tr>
<tr><td><a id="key_f12">key_f12</a></td><td><code>\E[24~,</code></td></tr>
<tr><td><a id="key_f13">key_f13</a></td><td><code>\EO2P,</code></td></tr>
<tr><td><a id="key_f14">key_f14</a></td><td><code>\EO2Q,</code></td></tr>
<tr><td><a id="key_f15">key_f15</a></td><td><code>\EO2R,</code></td></tr>
<tr><td><a id="key_f16">key_f16</a></td><td><code>\EO2S,</code></td></tr>
<tr><td><a id="key_f17">key_f17</a></td><td><code>\E[15;2~,</code></td></tr>
<tr><td><a id="key_f18">key_f18</a></td><td><code>\E[17;2~,</code></td></tr>
<tr><td><a id="key_f19">key_f19</a></td><td><code>\E[18;2~,</code></td></tr>
<tr><td><a id="key_f2">key_f2</a></td><td><code>\EOQ,</code></td></tr>
<tr><td><a id="key_f20">key_f20</a></td><td><code>\E[19;2~,</code></td></tr>
<tr><td><a id="key_f21">key_f21</a></td><td><code>\E[20;2~,</code></td></tr>
<tr><td><a id="key_f22">key_f22</a></td><td><code>\E[21;2~,</code></td></tr>
<tr><td><a id="key_f23">key_f23</a></td><td><code>\E[23;2~,</code></td></tr>
<tr><td><a id="key_f24">key_f24</a></td><td><code>\E[24;2~,</code></td></tr>
<tr><td><a id="key_f25">key_f25</a></td><td><code>\EO5P,</code></td></tr>
<tr><td><a id="key_f26">key_f26</a></td><td><code>\EO5Q,</code></td></tr>
<tr><td><a id="key_f27">key_f27</a></td><td><code>\EO5R,</code></td></tr>
<tr><td><a id="key_f28">key_f28</a></td><td><code>\EO5S,</code></td></tr>
<tr><td><a id="key_f29">key_f29</a></td><td><code>\E[15;5~,</code></td></tr>
<tr><td><a id="key_f3">key_f3</a></td><td><code>\EOR,</code></td></tr>
<tr><td><a id="key_f30">key_f30</a></td><td><code>\E[17;5~,</code></td></tr>
<tr><td><a id="key_f31">key_f31</a></td><td><code>\E[18;5~,</code></td></tr>
<tr><td><a id="key_f32">key_f32</a></td><td><code>\E[19;5~,</code></td></tr>
<tr><td><a id="key_f33">key_f33</a></td><td><code>\E[20;5~,</code></td></tr>
<tr><td><a id="key_f34">key_f34</a></td><td><code>\E[21;5~,</code></td></tr>
<tr><td><a id="key_f35">key_f35</a></td><td><code>\E[23;5~,</code></td></tr>
<tr><td><a id="key_f36">key_f36</a></td><td><code>\E[24;5~,</code></td></tr>
<tr><td><a id="key_f37">key_f37</a></td><td><code>\EO6P,</code></td></tr>
<tr><td><a id="key_f38">key_f38</a></td><td><code>\EO6Q,</code></td></tr>
<tr><td><a id="key_f39">key_f39</a></td><td><code>\EO6R,</code></td></tr>
<tr><td><a id="key_f4">key_f4</a></td><td><code>\EOS,</code></td></tr>
<tr><td><a id="key_f40">key_f40</a></td><td><code>\EO6S,</code></td></tr>
<tr><td><a id="key_f41">key_f41</a></td><td><code>\E[15;6~,</code></td></tr>
<tr><td><a id="key_f42">key_f42</a></td><td><code>\E[17;6~,</code></td></tr>
<tr><td><a id="key_f43">key_f43</a></td><td><code>\E[18;6~,</code></td></tr>
<tr><td><a id="key_f44">key_f44</a></td><td><code>\E[19;6~,</code></td></tr>
<tr><td><a id="key_f45">key_f45</a></td><td><code>\E[20;6~,</code></td></tr>
<tr><td><a id="key_f46">key_f46</a></td><td><code>\E[21;6~,</code></td></tr>
<tr><td><a id="key_f47">key_f47</a></td><td><code>\E[23;6~,</code></td></tr>
<tr><td><a id="key_f48">key_f48</a></td><td><code>\E[24;6~,</code></td></tr>
<tr><td><a id="key_f49">key_f49</a></td><td><code>\EO3P,</code></td></tr>
<tr><td><a id="key_f5">key_f5</a></td><td><code>\E[15~,</code></td></tr>
<tr><td><a id="key_f50">key_f50</a></td><td><code>\EO3Q,</code></td></tr>
<tr><td><a id="key_f51">key_f51</a></td><td><code>\EO3R,</code></td></tr>
<tr><td><a id="key_f52">key_f52</a></td><td><code>\EO3S,</code></td></tr>
<tr><td><a id="key_f53">key_f53</a></td><td><code>\E[15;3~,</code></td></tr>
<tr><td><a id="key_f54">key_f54</a></td><td><code>\E[17;3~,</code></td></tr>
<tr><td><a id="key_f55">key_f55</a></td><td><code>\E[18;3~,</code></td></tr>
<tr><td><a id="key_f56">key_f56</a></td><td><code>\E[19;3~,</code></td></tr>
<tr><td><a id="key_f57">key_f57</a></td><td><code>\E[20;3~,</code></td></tr>
<tr><td><a id="key_f58">key_f58</a></td><td><code>\E[21;3~,</code></td></tr>
<tr><td><a id="key_f59">key_f59</a></td><td><code>\E[23;3~,</code></td></tr>
<tr><td><a id="key_f6">key_f6</a></td><td><code>\E[17~,</code></td></tr>
<tr><td><a id="key_f60">key_f60</a></td><td><code>\E[24;3~,</code></td></tr>
<tr><td><a id="key_f61">key_f61</a></td><td><code>\EO4P,</code></td></tr>
<tr><td><a id="key_f62">key_f62</a></td><td><code>\EO4Q,</code></td></tr>
<tr><td><a id="key_f63">key_f63</a></td><td><code>\EO4R,</code></td></tr>
<tr><td><a id="key_f7">key_f7</a></td><td><code>\E[18~,</code></td></tr>
<tr><td><a id="key_f8">key_f8</a></td><td><code>\E[19~,</code></td></tr>
<tr><td><a id="key_f9">key_f9</a></td><td><code>\E[20~,</code></td></tr>
<tr><td><a id="key_home">key_home</a></td><td><code>\EOH,</code></td></tr>
<tr><td><a id="key_ic">key_ic</a></td><td><code>\E[2~,</code></td></tr>
<tr><td><a id="key_left">key_left</a></td><td><code>\EOD,</code></td></tr>
<tr><td><a id="key_mouse">key_mouse</a></td><td><code>\E[M,</code></td></tr>
<tr><td><a id="key_npage">key_npage</a></td><td><code>\E[6~,</code></td></tr>
<tr><td><a id="key_ppage">key_ppage</a></td><td><code>\E[5~,</code></td></tr>
<tr><td><a id="key_right">key_right</a></td><td><code>\EOC,</code></td></tr>
<tr><td><a id="key_sdc">key_sdc</a></td><td><code>\E[3;2~,</code></td></tr>
<tr><td><a id="key_send">key_send</a></td><td><code>\E[1;2F,</code></td></tr>
<tr><td><a id="key_sf">key_sf</a></td><td><code>\E[1;2B,</code></td></tr>
<tr><td><a id="key_shome">key_shome</a></td><td><code>\E[1;2H,</code></td></tr>
<tr><td><a id="key_sic">key_sic</a></td><td><code>\E[2;2~,</code></td></tr>
<tr><td><a id="key_sleft">key_sleft</a></td><td><code>\E[1;2D,</code></td></tr>
<tr><td><a id="key_snext">key_snext</a></td><td><code>\E[6;2~,</code></td></tr>
<tr><td><a id="key_sprevious">key_sprevious</a></td><td><code>\E[5;2~,</code></td></tr>
<tr><td><a id="key_sr">key_sr</a></td><td><code>\E[1;2A,</code></td></tr>
<tr><td><a id="key_sright">key_sright</a></td><td><code>\E[1;2C,</code></td></tr>
<tr><td><a id="key_up">key_up</a></td><td><code>\EOA,</code></td></tr>
<tr><td><a id="keypad_local">keypad_local</a></td><td><code>\E[?1l\E&gt;,</code></td></tr>
<tr><td><a id="keypad_xmit">\E[?1h\E</a></td><td><code>,</code></td></tr>
<tr><td><a id="memory_lock">memory_lock</a></td><td><code>\El,</code></td></tr>
<tr><td><a id="memory_unlock">memory_unlock</a></td><td><code>\Em,</code></td></tr>
<tr><td><a id="orig_pair">orig_pair</a></td><td><code>\E[39;49m,</code></td></tr>
<tr><td><a id="parm_dch">parm_dch</a></td><td><code>\E[%p1%dP,</code></td></tr>
<tr><td><a id="parm_delete_line">parm_delete_line</a></td><td><code>\E[%p1%dM,</code></td></tr>
<tr><td><a id="parm_down_cursor">parm_down_cursor</a></td><td><code>\E[%p1%dB,</code></td></tr>
<tr><td><a id="parm_ich">parm_ich</a></td><td><code>\E[%p1%d@,</code></td></tr>
<tr><td><a id="parm_index">parm_index</a></td><td><code>\E[%p1%dS,</code></td></tr>
<tr><td><a id="parm_insert_line">parm_insert_line</a></td><td><code>\E[%p1%dL,</code></td></tr>
<tr><td><a id="parm_left_cursor">parm_left_cursor</a></td><td><code>\E[%p1%dD,</code></td></tr>
<tr><td><a id="parm_right_cursor">parm_right_cursor</a></td><td><code>\E[%p1%dC,</code></td></tr>
<tr><td><a id="parm_rindex">parm_rindex</a></td><td><code>\E[%p1%dT,</code></td></tr>
<tr><td><a id="parm_up_cursor">parm_up_cursor</a></td><td><code>\E[%p1%dA,</code></td></tr>
<tr><td><a id="print_screen">print_screen</a></td><td><code>\E[i,</code></td></tr>
<tr><td><a id="prtr_off">prtr_off</a></td><td><code>\E[4i,</code></td></tr>
<tr><td><a id="prtr_on">prtr_on</a></td><td><code>\E[5i,</code></td></tr>
<tr><td><a id="reset_1string">reset_1string</a></td><td><code>\Ec,</code></td></tr>
<tr><td><a id="reset_2string">reset_2string</a></td><td><code>\E[\041p\E[?3;4l\E[4l\E&gt;,</code></td></tr>
<tr><td><a id="restore_cursor">restore_cursor</a></td><td><code>\E8,</code></td></tr>
<tr><td><a id="row_address">row_address</a></td><td><code>\E[%i%p1%dd,</code></td></tr>
<tr><td><a id="save_cursor">save_cursor</a></td><td><code>\E7,</code></td></tr>
<tr><td><a id="scroll_forward">scroll_forward</a></td><td><code>^J,</code></td></tr>
<tr><td><a id="scroll_reverse">scroll_reverse</a></td><td><code>\EM,</code></td></tr>
<tr><td><a id="set_a_background">set_a_background</a></td><td><code>\E[%?%p1%{8}%</code></td></tr>
</tbody></table>




<h2>Term Sorted</h2>
<pre>./MKtermsort.sh |sed &#039;s/.*\/\*  \(.*\)  \*\//\1/g&#039;|sort -u|grep ^[a-zA-Z]|sortwc|grep -v ^static|sort -d|tr " " &#039;,&#039;|sed &#039;s/\([^,]\{1,\}\),/&lt;var&gt;\1&lt;\/var&gt;,/g&#039;</pre>
<p><var>AB</var>,<var>ac</var>,<var>acs_btee</var>,<var>acsc</var>,<var>acs_chars</var>,<var>acs_hline</var>,<var>acs_llcorner</var>,<var>acs_lrcorner</var>,<var>acs_ltee</var>,<var>acs_plus</var>,<var>acs_rtee</var>,<var>acs_ttee</var>,<var>acs_ulcorner</var>,<var>acs_urcorner</var>,<var>acs_vline</var>,<var>ae</var>,<var>AF</var>,<var>al</var>,<var>AL</var>,<var>alt_scancode_esc</var>,<var>am</var>,<var>apstr</var>,<var>arrow_key_map</var>,<var>as</var>,<var>auto_left_margin</var>,<var>auto_right_margin</var>,<var>back_color_erase</var>,<var>backspace_delay</var>,<var>backspace_if_not_bs</var>,<var>backspaces_with_bs</var>,<var>back_tab</var>,<var>batt1</var>,<var>batt2</var>,<var>bc</var>,<var>bce</var>,<var>bel</var>,<var>bell</var>,<var>bicr</var>,<var>binel</var>,<var>birep</var>,<var>bit_image_carriage_return</var>,<var>bit_image_entwining</var>,<var>bit_image_newline</var>,<var>bit_image_repeat</var>,<var>bit_image_type</var>,<var>bitwin</var>,<var>bitype</var>,<var>bl</var>,<var>blink</var>,<var>bold</var>,<var>box1</var>,<var>box2</var>,<var>box_chars_1</var>,<var>bs</var>,<var>bt</var>,<var>BT</var>,<var>btml</var>,<var>btns</var>,<var>buffer_capacity</var>,<var>bufsz</var>,<var>buttons</var>,<var>bw</var>,<var>bx</var>,<var>can_change</var>,<var>carriage_return</var>,<var>carriage_return_delay</var>,<var>cb</var>,<var>cbt</var>,<var>cc</var>,<var>CC</var>,<var>ccc</var>,<var>cd</var>,<var>ce</var>,<var>ceol_standout_glitch</var>,<var>ch</var>,<var>change_char_pitch</var>,<var>change_line_pitch</var>,<var>change_res_horz</var>,<var>change_res_vert</var>,<var>change_scroll_region</var>,<var>char_padding</var>,<var>char_set_names</var>,<var>chr</var>,<var>chts</var>,<var>ci</var>,<var>civis</var>,<var>cl</var>,<var>clear</var>,<var>clear_all_tabs</var>,<var>clear_margins</var>,<var>clear_screen</var>,<var>clr_bol</var>,<var>clr_eol</var>,<var>clr_eos</var>,<var>cm</var>,<var>CM</var>,<var>cmdch</var>,<var>cnorm</var>,<var>co</var>,<var>Co</var>,<var>code_set_init</var>,<var>col_addr_glitch</var>,<var>colb0</var>,<var>colb1</var>,<var>colb2</var>,<var>colb3</var>,<var>colb4</var>,<var>colb5</var>,<var>colb6</var>,<var>colb7</var>,<var>colf0</var>,<var>colf1</var>,<var>colf2</var>,<var>colf3</var>,<var>colf4</var>,<var>colf5</var>,<var>colf6</var>,<var>colf7</var>,<var>color_names</var>,<var>colornm</var>,<var>colors</var>,<var>cols</var>,<var>column_address</var>,<var>columns</var>,<var>command_character</var>,<var>cpi</var>,<var>cpi_changes_res</var>,<var>cpix</var>,<var>cps</var>,<var>cr</var>,<var>cr_cancels_micro_mode</var>,<var>create_window</var>,<var>crt_no_scrolling</var>,<var>crxm</var>,<var>cs</var>,<var>csin</var>,<var>csnm</var>,<var>csr</var>,<var>ct</var>,<var>cub</var>,<var>cub1</var>,<var>cud</var>,<var>cud1</var>,<var>cuf</var>,<var>cuf1</var>,<var>cup</var>,<var>cursor_address</var>,<var>cursor_down</var>,<var>cursor_home</var>,<var>cursor_invisible</var>,<var>cursor_left</var>,<var>cursor_mem_address</var>,<var>cursor_normal</var>,<var>cursor_right</var>,<var>cursor_to_ll</var>,<var>cursor_up</var>,<var>cursor_visible</var>,<var>cuu</var>,<var>cuu1</var>,<var>cv</var>,<var>cvr</var>,<var>cvvis</var>,<var>CW</var>,<var>cwin</var>,<var>da</var>,<var>daisy</var>,<var>db</var>,<var>dB</var>,<var>dc</var>,<var>dC</var>,<var>DC</var>,<var>dch</var>,<var>dch1</var>,<var>dclk</var>,<var>defbi</var>,<var>defc</var>,<var>define_bit_image_region</var>,<var>define_char</var>,<var>delete_character</var>,<var>delete_line</var>,<var>dest_tabs_magic_smso</var>,<var>device_type</var>,<var>devt</var>,<var>DI</var>,<var>dial</var>,<var>dial_phone</var>,<var>dim</var>,<var>dispc</var>,<var>display_clock</var>,<var>display_pc_char</var>,<var>dis_status_line</var>,<var>DK</var>,<var>dl</var>,<var>DL</var>,<var>dl1</var>,<var>dm</var>,<var>dN</var>,<var>do</var>,<var>DO</var>,<var>docr</var>,<var>dot_horz_spacing</var>,<var>dot_vert_spacing</var>,<var>down_half_line</var>,<var>ds</var>,<var>dsl</var>,<var>dT</var>,<var>dv</var>,<var>eA</var>,<var>eat_newline_glitch</var>,<var>ec</var>,<var>ech</var>,<var>ed</var>,<var>ehhlm</var>,<var>ei</var>,<var>el</var>,<var>el1</var>,<var>elhlm</var>,<var>elohlm</var>,<var>ena_acs</var>,<var>enacs</var>,<var>endbi</var>,<var>end_bit_image_region</var>,<var>enter_alt_charset_mode</var>,<var>enter_am_mode</var>,<var>enter_blink_mode</var>,<var>enter_bold_mode</var>,<var>enter_ca_mode</var>,<var>enter_delete_mode</var>,<var>enter_dim_mode</var>,<var>enter_doublewide_mode</var>,<var>enter_draft_quality</var>,<var>enter_horizontal_hl_mode</var>,<var>enter_insert_mode</var>,<var>enter_italics_mode</var>,<var>enter_left_hl_mode</var>,<var>enter_leftward_mode</var>,<var>enter_low_hl_mode</var>,<var>enter_micro_mode</var>,<var>enter_near_letter_quality</var>,<var>enter_normal_quality</var>,<var>enter_pc_charset_mode</var>,<var>enter_protected_mode</var>,<var>enter_reverse_mode</var>,<var>enter_right_hl_mode</var>,<var>enter_scancode_mode</var>,<var>enter_secure_mode</var>,<var>enter_shadow_mode</var>,<var>enter_standout_mode</var>,<var>enter_subscript_mode</var>,<var>enter_superscript_mode</var>,<var>enter_top_hl_mode</var>,<var>enter_underline_mode</var>,<var>enter_upward_mode</var>,<var>enter_vertical_hl_mode</var>,<var>enter_xon_mode</var>,<var>eo</var>,<var>erase_chars</var>,<var>erase_overstrike</var>,<var>erhlm</var>,<var>es</var>,<var>eslok</var>,<var>ethlm</var>,<var>evhlm</var>,<var>exit_alt_charset_mode</var>,<var>exit_am_mode</var>,<var>exit_attribute_mode</var>,<var>exit_ca_mode</var>,<var>exit_delete_mode</var>,<var>exit_doublewide_mode</var>,<var>exit_insert_mode</var>,<var>exit_italics_mode</var>,<var>exit_leftward_mode</var>,<var>exit_micro_mode</var>,<var>exit_pc_charset_mode</var>,<var>exit_scancode_mode</var>,<var>exit_shadow_mode</var>,<var>exit_standout_mode</var>,<var>exit_subscript_mode</var>,<var>exit_superscript_mode</var>,<var>exit_underline_mode</var>,<var>exit_upward_mode</var>,<var>exit_xon_mode</var>,<var>F1</var>,<var>F2</var>,<var>F3</var>,<var>F4</var>,<var>F5</var>,<var>F6</var>,<var>F7</var>,<var>F8</var>,<var>F9</var>,<var>Fa</var>,<var>FA</var>,<var>Fb</var>,<var>FB</var>,<var>Fc</var>,<var>FC</var>,<var>Fd</var>,<var>FD</var>,<var>Fe</var>,<var>FE</var>,<var>ff</var>,<var>Ff</var>,<var>FF</var>,<var>Fg</var>,<var>FG</var>,<var>fh</var>,<var>Fh</var>,<var>FH</var>,<var>Fi</var>,<var>FI</var>,<var>fixed_pause</var>,<var>Fj</var>,<var>FJ</var>,<var>Fk</var>,<var>FK</var>,<var>Fl</var>,<var>FL</var>,<var>flash</var>,<var>flash_hook</var>,<var>flash_screen</var>,<var>fln</var>,<var>Fm</var>,<var>FM</var>,<var>Fn</var>,<var>FN</var>,<var>Fo</var>,<var>FO</var>,<var>font0</var>,<var>font1</var>,<var>font2</var>,<var>font3</var>,<var>font4</var>,<var>font5</var>,<var>font6</var>,<var>font7</var>,<var>form_feed</var>,<var>Fp</var>,<var>FP</var>,<var>Fq</var>,<var>FQ</var>,<var>Fr</var>,<var>FR</var>,<var>from_status_line</var>,<var>fs</var>,<var>FS</var>,<var>fsl</var>,<var>FT</var>,<var>FU</var>,<var>FV</var>,<var>FW</var>,<var>FX</var>,<var>FY</var>,<var>FZ</var>,<var>G1</var>,<var>G2</var>,<var>G3</var>,<var>G4</var>,<var>GC</var>,<var>GD</var>,<var>generic_type</var>,<var>getm</var>,<var>get_mouse</var>,<var>GH</var>,<var>GL</var>,<var>Gm</var>,<var>gn</var>,<var>gnu_has_meta_key</var>,<var>goto_window</var>,<var>GR</var>,<var>GU</var>,<var>GV</var>,<var>hangup</var>,<var>hard_copy</var>,<var>hard_cursor</var>,<var>has_hardware_tabs</var>,<var>has_meta_key</var>,<var>has_print_wheel</var>,<var>has_status_line</var>,<var>hc</var>,<var>HC</var>,<var>hd</var>,<var>hl</var>,<var>hls</var>,<var>ho</var>,<var>home</var>,<var>hook</var>,<var>horizontal_tab_delay</var>,<var>hpa</var>,<var>hs</var>,<var>ht</var>,<var>hts</var>,<var>hu</var>,<var>HU</var>,<var>hue_lightness_saturation</var>,<var>hup</var>,<var>hz</var>,<var>i1</var>,<var>i2</var>,<var>i3</var>,<var>ic</var>,<var>Ic</var>,<var>IC</var>,<var>ich</var>,<var>ich1</var>,<var>if</var>,<var>il</var>,<var>il1</var>,<var>im</var>,<var>in</var>,<var>ind</var>,<var>indn</var>,<var>init_1string</var>,<var>init_2string</var>,<var>init_3string</var>,<var>initc</var>,<var>init_file</var>,<var>initialize_color</var>,<var>initial
ize_pair</var>,<var>initp</var>,<var>init_prog</var>,<var>init_tabs</var>,<var>insert_character</var>,<var>insert_line</var>,<var>insert_null_glitch</var>,<var>insert_padding</var>,<var>invis</var>,<var>ip</var>,<var>iP</var>,<var>Ip</var>,<var>iprog</var>,<var>is</var>,<var>is1</var>,<var>is2</var>,<var>is3</var>,<var>it</var>,<var>k;</var>,<var>k0</var>,<var>k1</var>,<var>K1</var>,<var>k2</var>,<var>K2</var>,<var>k3</var>,<var>K3</var>,<var>k4</var>,<var>K4</var>,<var>k5</var>,<var>K5</var>,<var>k6</var>,<var>k7</var>,<var>k8</var>,<var>k9</var>,<var>ka</var>,<var>kA</var>,<var>ka1</var>,<var>ka3</var>,<var>kact</var>,<var>kb</var>,<var>kB</var>,<var>kb2</var>,<var>kbeg</var>,<var>kBEG</var>,<var>kbs</var>,<var>kbtab</var>,<var>kC</var>,<var>kc1</var>,<var>kc3</var>,<var>kcan</var>,<var>kCAN</var>,<var>kcbt</var>,<var>kclo</var>,<var>kclr</var>,<var>kcmd</var>,<var>kCMD</var>,<var>kcpn</var>,<var>kcpy</var>,<var>kCPY</var>,<var>kcrt</var>,<var>kCRT</var>,<var>kctab</var>,<var>kcub1</var>,<var>kcud1</var>,<var>kcuf1</var>,<var>kcuu1</var>,<var>kd</var>,<var>kD</var>,<var>kDC</var>,<var>kdch1</var>,<var>kDL</var>,<var>kdl1</var>,<var>kdo</var>,<var>ke</var>,<var>kE</var>,<var>ked</var>,<var>kel</var>,<var>kend</var>,<var>kEND</var>,<var>kent</var>,<var>kEOL</var>,<var>kext</var>,<var>kEXT</var>,<var>key_a1</var>,<var>key_a3</var>,<var>key_b2</var>,<var>key_backspace</var>,<var>key_beg</var>,<var>key_btab</var>,<var>key_c1</var>,<var>key_c3</var>,<var>key_cancel</var>,<var>key_catab</var>,<var>key_clear</var>,<var>key_close</var>,<var>key_command</var>,<var>key_copy</var>,<var>key_create</var>,<var>key_ctab</var>,<var>key_dc</var>,<var>key_dl</var>,<var>key_down</var>,<var>key_eic</var>,<var>key_end</var>,<var>key_enter</var>,<var>key_eol</var>,<var>key_eos</var>,<var>key_exit</var>,<var>key_f0</var>,<var>key_f1</var>,<var>key_f10</var>,<var>key_f11</var>,<var>key_f12</var>,<var>key_f13</var>,<var>key_f14</var>,<var>key_f15</var>,<var>key_f16</var>,<var>key_f17</var>,<var>key_f18</var>,<var>key_f19</var>,<var>key_f2</var>,<var>key_f20</var>,<var>key_f21</var>,<var>key_f22</var>,<var>key_f23</var>,<var>key_f24</var>,<var>key_f25</var>,<var>key_f26</var>,<var>key_f27</var>,<var>key_f28</var>,<var>key_f29</var>,<var>key_f3</var>,<var>key_f30</var>,<var>key_f31</var>,<var>key_f32</var>,<var>key_f33</var>,<var>key_f34</var>,<var>key_f35</var>,<var>key_f36</var>,<var>key_f37</var>,<var>key_f38</var>,<var>key_f39</var>,<var>key_f4</var>,<var>key_f40</var>,<var>key_f41</var>,<var>key_f42</var>,<var>key_f43</var>,<var>key_f44</var>,<var>key_f45</var>,<var>key_f46</var>,<var>key_f47</var>,<var>key_f48</var>,<var>key_f49</var>,<var>key_f5</var>,<var>key_f50</var>,<var>key_f51</var>,<var>key_f52</var>,<var>key_f53</var>,<var>key_f54</var>,<var>key_f55</var>,<var>key_f56</var>,<var>key_f57</var>,<var>key_f58</var>,<var>key_f59</var>,<var>key_f6</var>,<var>key_f60</var>,<var>key_f61</var>,<var>key_f62</var>,<var>key_f63</var>,<var>key_f7</var>,<var>key_f8</var>,<var>key_f9</var>,<var>key_find</var>,<var>key_help</var>,<var>key_home</var>,<var>key_ic</var>,<var>key_il</var>,<var>key_left</var>,<var>key_ll</var>,<var>key_mark</var>,<var>key_message</var>,<var>key_mouse</var>,<var>key_move</var>,<var>key_next</var>,<var>key_npage</var>,<var>key_open</var>,<var>key_options</var>,<var>keypad_local</var>,<var>keypad_xmit</var>,<var>key_ppage</var>,<var>key_previous</var>,<var>key_print</var>,<var>key_redo</var>,<var>key_reference</var>,<var>key_refresh</var>,<var>key_replace</var>,<var>key_restart</var>,<var>key_resume</var>,<var>key_right</var>,<var>key_save</var>,<var>key_sbeg</var>,<var>key_scancel</var>,<var>key_scommand</var>,<var>key_scopy</var>,<var>key_screate</var>,<var>key_sdc</var>,<var>key_sdl</var>,<var>key_select</var>,<var>key_send</var>,<var>key_seol</var>,<var>key_sexit</var>,<var>key_sf</var>,<var>key_sfind</var>,<var>key_shelp</var>,<var>key_shome</var>,<var>key_sic</var>,<var>key_sleft</var>,<var>key_smessage</var>,<var>key_smove</var>,<var>key_snext</var>,<var>key_soptions</var>,<var>key_sprevious</var>,<var>key_sprint</var>,<var>key_sr</var>,<var>key_sredo</var>,<var>key_sreplace</var>,<var>key_sright</var>,<var>key_srsume</var>,<var>key_ssave</var>,<var>key_ssuspend</var>,<var>key_stab</var>,<var>key_sundo</var>,<var>key_suspend</var>,<var>key_undo</var>,<var>key_up</var>,<var>kF</var>,<var>kf0</var>,<var>kf1</var>,<var>kf10</var>,<var>kf11</var>,<var>kf12</var>,<var>kf13</var>,<var>kf14</var>,<var>kf15</var>,<var>kf16</var>,<var>kf17</var>,<var>kf18</var>,<var>kf19</var>,<var>kf2</var>,<var>kf20</var>,<var>kf21</var>,<var>kf22</var>,<var>kf23</var>,<var>kf24</var>,<var>kf25</var>,<var>kf26</var>,<var>kf27</var>,<var>kf28</var>,<var>kf29</var>,<var>kf3</var>,<var>kf30</var>,<var>kf31</var>,<var>kf32</var>,<var>kf33</var>,<var>kf34</var>,<var>kf35</var>,<var>kf36</var>,<var>kf37</var>,<var>kf38</var>,<var>kf39</var>,<var>kf4</var>,<var>kf40</var>,<var>kf41</var>,<var>kf42</var>,<var>kf43</var>,<var>kf44</var>,<var>kf45</var>,<var>kf46</var>,<var>kf47</var>,<var>kf48</var>,<var>kf49</var>,<var>kf5</var>,<var>kf50</var>,<var>kf51</var>,<var>kf52</var>,<var>kf53</var>,<var>kf54</var>,<var>kf55</var>,<var>kf56</var>,<var>kf57</var>,<var>kf58</var>,<var>kf59</var>,<var>kf6</var>,<var>kf60</var>,<var>kf61</var>,<var>kf62</var>,<var>kf63</var>,<var>kf7</var>,<var>kf8</var>,<var>kf9</var>,<var>kfnd</var>,<var>kFND</var>,<var>kh</var>,<var>kH</var>,<var>khlp</var>,<var>kHLP</var>,<var>kHOM</var>,<var>khome</var>,<var>khts</var>,<var>kI</var>,<var>kIC</var>,<var>kich1</var>,<var>kil1</var>,<var>kind</var>,<var>kl</var>,<var>kL</var>,<var>kLFT</var>,<var>kll</var>,<var>km</var>,<var>kM</var>,<var>Km</var>,<var>kmous</var>,<var>kmov</var>,<var>kMOV</var>,<var>kmpf1</var>,<var>kmpf2</var>,<var>kmpf3</var>,<var>kmpf4</var>,<var>kmpf5</var>,<var>kmpf6</var>,<var>kmpf7</var>,<var>kmpf8</var>,<var>kmpf9</var>,<var>kmpt1</var>,<var>kmpt2</var>,<var>kmpt3</var>,<var>kmpt4</var>,<var>kmpt5</var>,<var>kmpt6</var>,<var>kmpt7</var>,<var>kmpt8</var>,<var>kmpt9</var>,<var>kmrk</var>,<var>kmsg</var>,<var>kMSG</var>,<var>kn</var>,<var>kN</var>,<var>knl</var>,<var>knp</var>,<var>knpn</var>,<var>knxt</var>,<var>kNXT</var>,<var>ko</var>,<var>kopn</var>,<var>kopt</var>,<var>kOPT</var>,<var>kP</var>,<var>kpp</var>,<var>kppn</var>,<var>kprt</var>,<var>kPRT</var>,<var>kprv</var>,<var>kPRV</var>,<var>kquit</var>,<var>kr</var>,<var>kR</var>,<var>krdo</var>,<var>kRDO</var>,<var>kref</var>,<var>kres</var>,<var>kRES</var>,<var>krfr</var>,<var>kri</var>,<var>kRIT</var>,<var>krmir</var>,<var>krpl</var>,<var>kRPL</var>,<var>krst</var>,<var>ks</var>,<var>kS</var>,<var>ksav</var>,<var>kSAV</var>,<var>kscl</var>,<var>kscr</var>,<var>ksel</var>,<var>ksf1</var>,<var>ksf10</var>,<var>ksf2</var>,<var>ksf3</var>,<var>ksf4</var>,<var>ksf5</var>,<var>ksf6</var>,<var>ksf7</var>,<var>ksf8</var>,<var>ksf9</var>,<var>kslt</var>,<var>kspd</var>,<var>kSPD</var>,<var>kt</var>,<var>kT</var>,<var>ktab</var>,<var>ktbc</var>,<var>ku</var>,<var>kund</var>,<var>kUND</var>,<var>l0</var>,<var>l1</var>,<var>l2</var>,<var>l3</var>,<var>l4</var>,<var>l5</var>,<var>l6</var>,<var>l7</var>,<var>l8</var>,<var>l9</var>,<var>la</var>,<var>label_format</var>,<var>label_height</var>,<var>label_off</var>,<var>label_on</var>,<var>label_width</var>,<var>lab_f0</var>,<var>lab_f1</var>,<var>lab_f10</var>,<var>lab_f2</var>,<var>lab_f3</var>,<var>lab_f4</var>,<var>lab_f5</var>,<var>lab_f6</var>,<var>lab_f7</var>,<var>lab_f8</var>,<var>lab_f9</var>,<var>le</var>,<var>LE</var>,<var>Lf</var>,<var>LF</var>,<var>lf0</var>,<var>lf1</var>,<var>lf10</var>,<var>lf2</var>,<var>lf3</var>,<var>lf4</var>,<var>lf5</var>,<var>lf6</var>,<var>lf7</var>,<var>lf8</var>,<var>lf9</var>,<var>lh</var>,<var>li</var>,<var>linefeed_if_not_lf</var>,<var>linefeed_is_newline</var>,<var>lines</var>,<var>lines_of_memory</var>,<var>ll</var>,<var>lm</var>,<var>LO</var>,<var>lpi</var>,<var>lpi_changes_res</var>,<var>lpix</var>,<var>lvert</var>,<var>lw</var>,<var>ma</var>,<var>maddr</var>,<var>magic_cookie_glitch</var>,<var>magic_cookie_glitch_ul</var>,<var>max_attributes</var>,<var>max_colors</var>,<var>maximum_windows</var>,<var>max_micro_address</va
r>,<var>max_micro_jump</var>,<var>max_pairs</var>,<var>mb</var>,<var>MC</var>,<var>mc0</var>,<var>mc4</var>,<var>mc5</var>,<var>mc5i</var>,<var>mc5p</var>,<var>mcs</var>,<var>mcub</var>,<var>mcub1</var>,<var>mcud</var>,<var>mcud1</var>,<var>mcuf</var>,<var>mcuf1</var>,<var>mcuu</var>,<var>mcuu1</var>,<var>md</var>,<var>me</var>,<var>meml</var>,<var>memory_above</var>,<var>memory_below</var>,<var>memory_lock</var>,<var>memory_unlock</var>,<var>memu</var>,<var>meta_off</var>,<var>meta_on</var>,<var>mgc</var>,<var>mh</var>,<var>mhpa</var>,<var>mi</var>,<var>Mi</var>,<var>micro_col_size</var>,<var>micro_column_address</var>,<var>micro_down</var>,<var>micro_left</var>,<var>micro_line_size</var>,<var>micro_right</var>,<var>micro_row_address</var>,<var>micro_up</var>,<var>minfo</var>,<var>mir</var>,<var>mjump</var>,<var>mk</var>,<var>ml</var>,<var>ML</var>,<var>mls</var>,<var>mm</var>,<var>mo</var>,<var>mouse_info</var>,<var>move_insert_mode</var>,<var>move_standout_mode</var>,<var>mp</var>,<var>mr</var>,<var>MR</var>,<var>mrcup</var>,<var>ms</var>,<var>msgr</var>,<var>MT</var>,<var>mu</var>,<var>mvpa</var>,<var>MW</var>,<var>nc</var>,<var>NC</var>,<var>ncv</var>,<var>nd</var>,<var>ND</var>,<var>ndscr</var>,<var>needs_xon_xoff</var>,<var>nel</var>,<var>newline</var>,<var>new_line_delay</var>,<var>nl</var>,<var>Nl</var>,<var>NL</var>,<var>nlab</var>,<var>no_color_video</var>,<var>no_correctly_working_cr</var>,<var>no_esc_ctlc</var>,<var>non_dest_scroll_region</var>,<var>non_rev_rmcup</var>,<var>no_pad_char</var>,<var>NP</var>,<var>npc</var>,<var>npins</var>,<var>NR</var>,<var>nrrmc</var>,<var>ns</var>,<var>number_of_function_keys</var>,<var>number_of_pins</var>,<var>num_labels</var>,<var>nw</var>,<var>nx</var>,<var>nxon</var>,<var>oc</var>,<var>op</var>,<var>orc</var>,<var>order_of_pins</var>,<var>orhi</var>,<var>orig_colors</var>,<var>orig_pair</var>,<var>orl</var>,<var>orvi</var>,<var>os</var>,<var>OTbc</var>,<var>OTbs</var>,<var>OTdB</var>,<var>OTdC</var>,<var>OTdN</var>,<var>OTdT</var>,<var>OTG1</var>,<var>OTG2</var>,<var>OTG3</var>,<var>OTG4</var>,<var>OTGC</var>,<var>OTGD</var>,<var>OTGH</var>,<var>OTGL</var>,<var>OTGR</var>,<var>OTGU</var>,<var>OTGV</var>,<var>other_non_function_keys</var>,<var>OTi2</var>,<var>OTkn</var>,<var>OTko</var>,<var>OTma</var>,<var>OTMT</var>,<var>OTnc</var>,<var>OTnl</var>,<var>OTNL</var>,<var>OTns</var>,<var>OTpt</var>,<var>OTrs</var>,<var>OTug</var>,<var>OTxr</var>,<var>output_res_char</var>,<var>output_res_horz_inch</var>,<var>output_res_line</var>,<var>output_res_vert_inch</var>,<var>over_strike</var>,<var>pa</var>,<var>PA</var>,<var>pad</var>,<var>pad_char</var>,<var>padding_baud_rate</var>,<var>pairs</var>,<var>parm_dch</var>,<var>parm_delete_line</var>,<var>parm_down_cursor</var>,<var>parm_down_micro</var>,<var>parm_ich</var>,<var>parm_index</var>,<var>parm_insert_line</var>,<var>parm_left_cursor</var>,<var>parm_left_micro</var>,<var>parm_right_cursor</var>,<var>parm_right_micro</var>,<var>parm_rindex</var>,<var>parm_up_cursor</var>,<var>parm_up_micro</var>,<var>pause</var>,<var>pb</var>,<var>pc</var>,<var>pc_term_options</var>,<var>pctrm</var>,<var>pf</var>,<var>pfkey</var>,<var>pfloc</var>,<var>pfx</var>,<var>pfxl</var>,<var>pk</var>,<var>pkey_key</var>,<var>pkey_local</var>,<var>pkey_plab</var>,<var>pkey_xmit</var>,<var>pl</var>,<var>plab_norm</var>,<var>pln</var>,<var>pn</var>,<var>po</var>,<var>pO</var>,<var>porder</var>,<var>print_rate</var>,<var>print_screen</var>,<var>prot</var>,<var>prtr_non</var>,<var>prtr_off</var>,<var>prtr_on</var>,<var>prtr_silent</var>,<var>ps</var>,<var>pt</var>,<var>PU</var>,<var>pulse</var>,<var>px</var>,<var>QD</var>,<var>qdial</var>,<var>quick_dial</var>,<var>r1</var>,<var>r2</var>,<var>r3</var>,<var>RA</var>,<var>rbim</var>,<var>rc</var>,<var>RC</var>,<var>rcsd</var>,<var>remove_clock</var>,<var>rep</var>,<var>repeat_char</var>,<var>req_for_input</var>,<var>req_mouse_pos</var>,<var>reqmp</var>,<var>reset_1string</var>,<var>reset_2string</var>,<var>reset_3string</var>,<var>reset_file</var>,<var>restore_cursor</var>,<var>return_does_clr_eol</var>,<var>rev</var>,<var>rf</var>,<var>RF</var>,<var>rfi</var>,<var>ri</var>,<var>RI</var>,<var>rin</var>,<var>ritm</var>,<var>rlm</var>,<var>rmacs</var>,<var>rmam</var>,<var>rmclk</var>,<var>rmcup</var>,<var>rmdc</var>,<var>rmicm</var>,<var>rmir</var>,<var>rmkx</var>,<var>rmln</var>,<var>rmm</var>,<var>rmp</var>,<var>rmpch</var>,<var>rmsc</var>,<var>rmso</var>,<var>rmul</var>,<var>rmxon</var>,<var>row_address</var>,<var>row_addr_glitch</var>,<var>rp</var>,<var>rP</var>,<var>RQ</var>,<var>rs</var>,<var>rs1</var>,<var>rs2</var>,<var>rs3</var>,<var>rshm</var>,<var>rsubm</var>,<var>rsupm</var>,<var>rum</var>,<var>rvert</var>,<var>rwidm</var>,<var>RX</var>,<var>s0</var>,<var>s0ds</var>,<var>s1</var>,<var>S1</var>,<var>s1ds</var>,<var>s2</var>,<var>S2</var>,<var>s2ds</var>,<var>s3</var>,<var>S3</var>,<var>s3ds</var>,<var>S4</var>,<var>S5</var>,<var>S6</var>,<var>S7</var>,<var>S8</var>,<var>sa</var>,<var>sA</var>,<var>SA</var>,<var>sam</var>,<var>save_cursor</var>,<var>Sb</var>,<var>sbim</var>,<var>sc</var>,<var>SC</var>,<var>scancode_escape</var>,<var>scesa</var>,<var>scesc</var>,<var>sclk</var>,<var>scp</var>,<var>scroll_forward</var>,<var>scroll_reverse</var>,<var>scs</var>,<var>scsd</var>,<var>sdrfq</var>,<var>se</var>,<var>select_char_set</var>,<var>semi_auto_right_margin</var>,<var>set0_des_seq</var>,<var>set1_des_seq</var>,<var>set2_des_seq</var>,<var>set3_des_seq</var>,<var>set_a_attributes</var>,<var>setab</var>,<var>set_a_background</var>,<var>setaf</var>,<var>set_a_foreground</var>,<var>set_attributes</var>,<var>setb</var>,<var>set_background</var>,<var>set_bottom_margin</var>,<var>set_bottom_margin_parm</var>,<var>set_clock</var>,<var>setcolor</var>,<var>set_color_band</var>,<var>set_color_pair</var>,<var>setf</var>,<var>set_foreground</var>,<var>set_left_margin</var>,<var>set_left_margin_parm</var>,<var>set_lr_margin</var>,<var>set_page_length</var>,<var>set_pglen_inch</var>,<var>set_right_margin</var>,<var>set_right_margin_parm</var>,<var>set_tab</var>,<var>set_tb_margin</var>,<var>set_top_margin</var>,<var>set_top_margin_parm</var>,<var>set_window</var>,<var>sf</var>,<var>Sf</var>,<var>SF</var>,<var>sg</var>,<var>sgr</var>,<var>sgr0</var>,<var>sgr1</var>,<var>sitm</var>,<var>sL</var>,<var>slength</var>,<var>slines</var>,<var>slm</var>,<var>smacs</var>,<var>smam</var>,<var>smcup</var>,<var>smdc</var>,<var>smgb</var>,<var>smgbp</var>,<var>smgl</var>,<var>smglp</var>,<var>smglr</var>,<var>smgr</var>,<var>smgrp</var>,<var>smgt</var>,<var>smgtb</var>,<var>smgtp</var>,<var>smicm</var>,<var>smir</var>,<var>smkx</var>,<var>smln</var>,<var>smm</var>,<var>smpch</var>,<var>smsc</var>,<var>smso</var>,<var>smul</var>,<var>smxon</var>,<var>snlq</var>,<var>snrmq</var>,<var>so</var>,<var>sp</var>,<var>spinh</var>,<var>spinv</var>,<var>sr</var>,<var>SR</var>,<var>sshm</var>,<var>ssubm</var>,<var>ssupm</var>,<var>st</var>,<var>start_bit_image</var>,<var>start_char_set_def</var>,<var>status_line_esc_ok</var>,<var>stop_bit_image</var>,<var>stop_char_set_def</var>,<var>subcs</var>,<var>subscript_characters</var>,<var>sum</var>,<var>supcs</var>,<var>superscript_characters</var>,<var>swidm</var>,<var>SX</var>,<var>ta</var>,<var>tab</var>,<var>tbc</var>,<var>te</var>,<var>termcap_init2</var>,<var>termcap_reset</var>,<var>these_cause_cr</var>,<var>ti</var>,<var>tilde_glitch</var>,<var>TO</var>,<var>tone</var>,<var>topl</var>,<var>to_status_line</var>,<var>transparent_underline</var>,<var>ts</var>,<var>tsl</var>,<var>u0</var>,<var>u1</var>,<var>u2</var>,<var>u3</var>,<var>u4</var>,<var>u5</var>,<var>u6</var>,<var>u7</var>,<var>u8</var>,<var>u9</var>,<var>uc</var>,<var>ue</var>,<var>ug</var>,<var>ul</var>,<var>underline_char</var>,<var>up</var>,<var>UP</var>,<var>up_half_line</var>,<var>us</var>,<var>user0</var>,<var>user1</var>,<var>user2</var>,<var>user3</var>,<var>user4</var>,<var>user5</var>,<var>user6</var>,<var>user7</var>,<var>user8</var>,<var>user9</var>,<var>ut</var>,<var>vb</var>,<var>ve</var>,<var>vi</var>,<var>virtual_terminal</var>,<var>vpa</var>,<var>vs</var>,<var>vt</var>,<var>WA</var>,<var>wait</var>,<var>wait_tone</var>,<var>WG</va
r>,<var>wi</var>,<var>widcs</var>,<var>wide_char_size</var>,<var>width_status_line</var>,<var>wind</var>,<var>wingo</var>,<var>wnum</var>,<var>ws</var>,<var>wsl</var>,<var>xb</var>,<var>xenl</var>,<var>XF</var>,<var>Xh</var>,<var>xhp</var>,<var>xhpa</var>,<var>xl</var>,<var>Xl</var>,<var>xmc</var>,<var>xn</var>,<var>XN</var>,<var>xo</var>,<var>Xo</var>,<var>xoffc</var>,<var>xoff_character</var>,<var>xon</var>,<var>xonc</var>,<var>xon_character</var>,<var>xon_xoff</var>,<var>xr</var>,<var>Xr</var>,<var>xs</var>,<var>xsb</var>,<var>xt</var>,<var>Xt</var>,<var>Xv</var>,<var>xvpa</var>,<var>Xy</var>,<var>Ya</var>,<var>YA</var>,<var>Yb</var>,<var>YB</var>,<var>Yc</var>,<var>YC</var>,<var>Yd</var>,<var>YD</var>,<var>Ye</var>,<var>YE</var>,<var>Yf</var>,<var>YF</var>,<var>Yg</var>,<var>YG</var>,<var>Yh</var>,<var>Yi</var>,<var>Yj</var>,<var>Yk</var>,<var>Yl</var>,<var>Ym</var>,<var>Yn</var>,<var>Yo</var>,<var>Yp</var>,<var>Yv</var>,<var>Yw</var>,<var>Yx</var>,<var>Yy</var>,<var>Yz</var>,<var>YZ</var>,<var>Za</var>,<var>ZA</var>,<var>Zb</var>,<var>ZB</var>,<var>Zc</var>,<var>ZC</var>,<var>Zd</var>,<var>ZD</var>,<var>Ze</var>,<var>ZE</var>,<var>zerom</var>,<var>zero_motion</var>,<var>Zf</var>,<var>ZF</var>,<var>Zg</var>,<var>ZG</var>,<var>Zh</var>,<var>ZH</var>,<var>Zi</var>,<var>ZI</var>,<var>Zj</var>,<var>ZJ</var>,<var>Zk</var>,<var>ZK</var>,<var>Zl</var>,<var>ZL</var>,<var>Zm</var>,<var>ZM</var>,<var>Zn</var>,<var>ZN</var>,<var>Zo</var>,<var>ZO</var>,<var>Zp</var>,<var>ZP</var>,<var>Zq</var>,<var>ZQ</var>,<var>Zr</var>,<var>ZR</var>,<var>Zs</var>,<var>ZS</var>,<var>Zt</var>,<var>ZT</var>,<var>Zu</var>,<var>ZU</var>,<var>Zv</var>,<var>ZV</var>,<var>Zw</var>,<var>ZW</var>,<var>Zx</var>,<var>ZX</var>,<var>Zy</var>,<var>ZY</var>,<var>Zz</var>,<var>ZZ</var></p>


<h2>TERMINAL TYPE DESCRIPTIONS SOURCE FILE</h2>
<pre>ANSI, UNIX CONSOLE, AND SPECIAL TYPES
Specials
ANSI.SYS/ISO 6429/ECMA-48 Capabilities
ANSI/ECMA-48 terminals and terminal emulators
DOS ANSI.SYS variants
ANSI console types
BeOS
Linux consoles
Mach
OSF Unix
QNX
NetBSD consoles
FreeBSD console entries
386BSD and BSD/OS Consoles
DEC VT52
DEC VT100 and compatibles
VT100 emulations
X terminal emulators
MGR
UNIX VIRTUAL TERMINALS, VIRTUAL CONSOLES, AND TELNET CLIENTS
Pilot Pro Palm-Top
COMMERCIAL WORKSTATION CONSOLES
Alpha consoles
Sun consoles
Iris consoles
NeWS consoles
NeXT consoles
Sony NEWS workstations
Common Desktop Environment
Non-Unix Consoles
COMMON TERMINAL TYPES
Altos
Hewlett-Packard (hp)
Honeywell-Bull
Lear-Siegler (adm)
Prime
Qume (qvt)
Televideo (tvi)
Visual (vi)
Wyse (wy)
Kermit terminal emulations
NON-ANSI TERMINAL EMULATIONS
Avatar
RBcomm
LCD DISPLAYS
Matrix Orbital
OLDER TERMINAL TYPES
AT&amp;amp;T (att, tty)
Ampex (Dialogue)
Ann Arbor (aa)
Applied Digital Data Systems (adds)
C. Itoh Electronics
Control Data (cdc)
Getronics
Human Designed Systems (Concept)
Contel Business Systems.
Data General (dg)
Datamedia (dm)
Falco</pre>






<p>Just something sorta cool for you to check out</p>
<pre>{
 local t=`tputm &#039;clear&#039; &#039;setaf 75&#039;` l a b f=/tmp/ps IFS=&#039; &#039;;
exec 6&lt;&gt;$f;ps L|tr -s &#039; &#039; &amp;&gt;$f;
while read -u6 l;do a=${l/% */} b=${l/* /};
figlet -rtw $((${COLUMNS} /2 )) -f big "$l";
tput sgr0;
command ps wwo pid:6,user:8,vsize:8,comm:20,$a:50 k -$a -A;cont;
done;
};</pre><p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"></a><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html">Terminal Escape Code Zen</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/zen-terminal-escape-codes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Htaccess Rewrites &#8211; Rewrite Tricks and Tips</title>
		<link>http://www.askapache.com/htaccess/modrewrite-tips-tricks.html</link>
		<comments>http://www.askapache.com/htaccess/modrewrite-tips-tricks.html#comments</comments>
		<pubDate>Sun, 10 Apr 2011 14:05:00 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Htaccess]]></category>

		<guid isPermaLink="false">http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html</guid>
		<description><![CDATA[<p><strong>htaccess rewrite</strong> / Mod_Rewrite Tips and Tricks is as glamorous as it sounds!  htaccess rewrite mod_rewrite is just possibly one of the most useful Apache modules and features.  The ability to rewrite requests internally as well as externally is extremely powerful.</p>
<p><a class="hs hs13" href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html"></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/htaccess/modrewrite-tips-tricks.html"></a><a href="http://www.askapache.com/htaccess/modrewrite-tips-tricks.html"><cite>AskApache.com</cite></a></p><p><strong>Htaccess Rewrites</strong> are enabled by using the Apache module <a href="http://www.askapache.com/servers/mod_rewrite.c.html">mod_rewrite</a>, which is one of the most powerful Apache modules and features availale.  Htaccess Rewrites through mod_rewrite provide the special ability to <strong>Rewrite requests internally</strong> as well as <em>Redirect request externally</em>.<br class="C" /></p>
<p><a class="hs hs13" href="http://www.askapache.com/servers/mod_rewrite.c.html"></a></p>

<p>When the url in your browser's location bar stays the same for a request it is an internal rewrite, when the url changes an external redirection is taking place.  This is one of the first, and one of the biggest mental-blocks people have when learning about mod_rewrite...  But I have a secret weapon for you to use, a new discovery from years of research that makes learning mod_rewrite drastically quicker and easier.  It truly does or I wouldn't be saying so in the introduction of this article.</p>

<blockquote><p>Despite the tons of examples and docs, <strong>mod_rewrite is voodoo</strong>.
Damned cool voodoo, but still voodoo.<br />-- <cite>Brian Moore</cite></p></blockquote>

<p class="anote"><strong>Note:</strong>  After years of fighting to learn my way through rewriting urls with mod_rewrite, I finally had a breakthrough and found a way to outsmart the difficulty of mod_rewrite that I just couldn't seem to master.  The <a href="http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html">Mod_Rewrite RewriteCond/RewriteRule Variable Value Cheatsheet</a> is the one-of-a-kind tool that changed the game for me and made mod_rewriting no-harder than anything else.</p>

<p>So keep that mod_rewrite reference bookmarked and you will be able to figure out any RewriteRule or RewriteCond, an amazing feat considering it took me a LONG time to figure this stuff out on my own.  But that was before <a href="http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html">the craziness</a>, one of the most challenging and productive .htaccess experiments I've done... An experiment so <strong>ILL</strong> it's sick like a diamond disease on your wrist! $$$.  That mod_rewrite experiment/tutorial was the culmination of many different advanced mod_rewrite experiments I had done in the past and included most of my very best .htaccess tricks.  With the cheatsheet it's no longer Voodoo.. Its just what you do.  Now lets dig in!</p>


<!--
<h2>Htaccess rewrites TOC</h2>
        <ul>
            <li><a href="#default-mod-rewrite-hint" title=".htaccess mod rewrite should use Options +FollowSymLinks">.htaccess rewrite examples should begin with:</a></li>
            <li><a href="#require-the-www-in-htaccess" title="Use mod_rewrite in Apache htaccess to Require the www for SEO">Require the www</a></li>
            <li><a href="#require-no-www-in-htaccess" title="Use mod_rewrite in Apache htaccess to Require no www for SEO">Require no www</a></li>
            <li><a href="#check-for-key-in-query-string" title="Search for a key in the query string">Check for a key in QUERY_STRING</a></li>
            <li><a href="#delete-query-string" title="Remove the query string from url">Removes the QUERY_STRING from the URL</a></li>
            <li><a href="#fix-infinite-loop-redirects" title="Stop internal redirect looping">Fix for infinite loops</a></li>
            <li><a href="#external-redirect-php-files-to-html" title="Redirecting .php file extensions to .html">Redirect .php files to .html files (SEO friendly)</a></li>
            <li><a href="#internal-redirect-php-files-to-html" title="Redirecting .html file extensions to .php">Redirect .html files to actual .php files (SEO friendly)</a></li>
            <li><a href="#time-based-access" title="Deny access with Apache htaccess during certain hours of the day">block access to files during certain hours of the day</a></li>
            <li><a href="#convert-underscore-hyphen" title="Change underscores to hyphens for SEO URL">Rewrite underscores to hyphens for SEO URL</a></li>
            <li><a href="#require-www-no-hardcoding" title="mod_rewrite example of SEO 301 redirecting non-www to www">Require the www without hardcoding</a></li>
            <li><a href="#require-no-subdomain-1" title="mod_rewrite subdomain usage example of SEO 301 redirecting">Require no subdomain</a></li>
            <li><a href="#require-no-subdomain-2" title="Apache htaccess htaccess rewrite ~without slash">Require no subdomain</a></li>
            <li><a href="#redirect-wordpress-feed" title="Rewriting WordPress RSS feeds to Feedburner in SEO friendly method">Redirecting WordPress Feeds to Feedburner</a></li>
            <li><a href="#only-allow-get-and-put-requests" title="Deny Request Methods other than GET or PUT">Only allow GET and PUT request methods</a></li>
            <li><a href="#prevent-hotlinking" title="hotlinking and bandwidth stealing with mod_rewrite, hotlinking example">Prevent Files image/file hotlinking and bandwidth stealing</a></li>
            <li><a href="#stop-browser-prefetching" title="Fix prefetching in browsers">Stop browser prefetching</a></li>
        </ul>

<hr />
-->
<p>If you really want to take a look, check out the <a href="http://www.askapache.com/servers/mod_rewrite.c.html">mod_rewrite.c</a> and <a href="http://www.askapache.com/servers/mod_rewrite.h.html">mod_rewrite.h</a> files.</p>

<p>Be aware that mod_rewrite (<em>RewriteRule, RewriteBase, and RewriteCond</em>) code is executed for each and every HTTP request that accesses a file in or below the directory where the code resides, so it's always good to limit the code to certain circumstances if readily identifiable.</p>
<p><strong>For example</strong>, to limit the next 5 RewriteRules to only be applied to .html and .php files, you can use the following code, which tests if the url does not end in .html or .php and if it doesn't, it will skip the next 5 RewriteRules.</p><hr />
<pre>
RewriteRule !\.(html|php)$ - [S=5]
RewriteRule ^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]
</pre>

<h2><a href="#default-mod-rewrite-hint" name="default-mod-rewrite-hint" id="default-mod-rewrite-hint" title="Mostly .htaccess rewrite examples should begin with:" class="acd">.htaccess rewrite examples should begin with:</a></h2>
<pre>
Options +FollowSymLinks
&nbsp;
RewriteEngine On
RewriteBase /
</pre>


<h2><a href="#require-the-www-in-htaccess" name="require-the-www-in-htaccess" id="require-the-www-in-htaccess" title="Require the www" class="acd">Require the www</a></h2>
<pre>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]
</pre>


<h2>Loop Stopping Code</h2>
<p>Sometimes your rewrites cause infinite loops, stop it with one of these rewrite code snippets.</p>
<pre>
RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule .* - [L]
&nbsp;
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
</pre>

<h2>Cache-Friendly File Names</h2>
<p>This is probably my favorite, and I use it on every site I work on.  It allows me to update my javascript and css files in my visitors cache's simply by naming them differently in the html, on the server they stay the same name.  This rewrites all files for <code>/zap/j/anything-anynumber.js to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css</code></p>
<pre>
RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]
</pre>




<h2>SEO friendly link for non-flash browsers</h2>
<p>When you use flash on your site and you properly supply a link to download flash that shows up for non-flash aware browsers, it is nice to use a shortcut to keep your code clean and your external links to a minimum.  This code allows me to link to <code>site.com/getflash/</code> for non-flash aware browsers.</p>
<pre>
RewriteRule ^getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash [NC,L,R=307]
</pre>

<h2>Removing the Query_String</h2>
<p>On many sites, the page will be displayed for both page.html and page.html?anything=anything, which hurts your SEO with duplicate content.  An easy way to fix this issue is to redirect external requests containing a query string to the same uri without the query_string.</p>
<pre>
RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://www.askapache.com%{REQUEST_URI}? [R=301,L]
</pre>


<h2>Sending requests to a php script</h2>
<p>This .htaccess rewrite example invisibly rewrites requests for all Adobe pdf files to be handled by <code>/cgi-bin/pdf-script.php</code></p>
<pre>
RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]
</pre>


<h2>Setting the language variable based on Client</h2>
<p>For sites using multiviews or with multiple language capabilities, it is nice to be able to send the correct language automatically based on the clients preferred language.</p>
<pre>
RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]
RewriteRule ^(.*)$ - [env=prefer-language:%1]
</pre>



<h2>Deny Access To Everyone Except PHP fopen</h2>
<p>This allows access to all files by php fopen, but denies anyone else.</p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.+$ [NC]
RewriteRule .* - [F,L]
</pre>


<p class="cnote">If you are looking for ways to block or deny specific requests/visitors, then you should definately read <a href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache’s mod_rewrite">Blacklist with mod_rewrite</a>.  I give it a 10/10</p>


<h2>Deny access to anything in a subfolder except php fopen</h2>
<p>This can be very handy if you want to serve media files or special downloads but only through a php proxy script.</p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]
RewriteRule .* - [F,L]
</pre>





<h2><a href="#require-no-www-in-htaccess" name="require-no-www-in-htaccess" id="require-no-www-in-htaccess" title="Require no www" class="acd">Require no www</a></h2>
<pre>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^askapache\.com$ [NC]
RewriteRule ^(.*)$ http://askapache.com/$1 [R=301,L]
</pre>


<h2><a href="#check-for-key-in-query-string" name="check-for-key-in-query-string" id="check-for-key-in-query-string" title="Search for a key in the query string" class="acd">Check for a key in QUERY_STRING</a></h2>
<p>Uses a <a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewritecond" title="RewriteCond Directive Use in htaccess">RewriteCond</a> Directive to check QUERY_STRING for passkey, if it doesn't find it it redirects all requests for anything in the /logged-in/ directory to the /login.php script.</p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !passkey
RewriteRule ^/logged-in/(.*)$ /login.php [L]
</pre>


<h2><a href="#delete-query-string" name="delete-query-string" id="delete-query-string" title="Remove the query string from url" class="acd">Removes the QUERY_STRING from the URL</a></h2>
<p>If the QUERY_STRING has any value at all besides blank than the<code>?</code>at the end of /login.php? tells mod_rewrite to remove the QUERY_STRING from login.php and redirect.</p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} .
RewriteRule ^login.php /login.php? [L]
</pre>


<h2><a href="#fix-infinite-loop-redirects" name="fix-infinite-loop-redirects" id="fix-infinite-loop-redirects" title="Fix for infinite loops" class="acd">Fix for infinite loops</a></h2>
<p>An error message related to this is<code>Request exceeded the limit of 10 internal redirects due to probable configuration error. Use &#039;LimitInternalRecursion&#039; to increase the limit if necessary. Use &#039;LogLevel debug&#039; to get a backtrace.</code>or you may see<code>Request exceeded the limit</code>,<code>probable configuration error</code>,<code>Use &#039;LogLevel debug&#039; to get a backtrace</code>, or<code>Use &#039;LimitInternalRecursion&#039; to increase the limit if necessary</code></p>
<pre>
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
</pre>


<h2><a href="#external-redirect-php-files-to-html" name="external-redirect-php-files-to-html" id="external-redirect-php-files-to-html" title="External Redirect .php files to .html files (SEO friendly)" class="acd">External Redirect .php files to .html files (SEO friendly)</a></h2>
<pre>
RewriteRule ^(.*)\.php$ /$1.html [R=301,L]
</pre>


<h2><a href="#internal-redirect-php-files-to-html" name="internal-redirect-php-files-to-html" id="internal-redirect-php-files-to-html" title="Internal Redirect .php files to .html files (SEO friendly)" class="acd">Internal Redirect .php files to .html files (SEO friendly)</a></h2>
<p>Redirects all files that end in .html to be served from filename.php  so it looks like all your pages are .html but really they are .php</p>
<pre>
RewriteRule ^(.*)\.html$ $1.php [R=301,L]
</pre>


<h2><a href="#time-based-access" name="time-based-access" id="time-based-access" title="block access to files during certain hours of the day" class="acd">block access to files during certain hours of the day</a></h2>
<pre>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# If the hour is 16 (4 PM) Then deny all access
RewriteCond %{TIME_HOUR} ^16$
RewriteRule ^.*$ - [F,L]
</pre>


<h2><a href="#convert-underscore-hyphen" name="convert-underscore-hyphen" id="convert-underscore-hyphen" title="Change underscores to hyphens for SEO URL" class="acd">Rewrite underscores to hyphens for SEO URL</a></h2>
<p>Converts all underscores "_" in urls to hyphens "-" for SEO benefits...  See the <a href="http://www.askapache.com/htaccess/rewrite-underscores-to-hyphens-for-seo-url.html">full article</a> for more info.</p>
<pre>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
&nbsp;
RewriteRule !\.(html|php)$ - [S=4]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]
&nbsp;
RewriteCond %{ENV:uscor} ^Yes$
RewriteRule (.*) http://d.com/$1 [R=301,L]
</pre>


<h2><a href="#require-www-no-hardcoding" name="require-www-no-hardcoding" id="require-www-no-hardcoding" title="Require the www without hardcoding" class="acd">Require the www without hardcoding</a></h2>
<pre>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$     [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]
</pre>


<h2><a href="#require-no-subdomain-1" name="require-no-subdomain-1" id="require-no-subdomain-1" title="Require no subdomain" class="acd">Require no subdomain</a></h2>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]
</pre>


<h2><a href="#require-no-subdomain-2" name="require-no-subdomain-2" id="require-no-subdomain-2" title="Require no subdomain" class="acd">Require no subdomain</a></h2>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([^\.]+\.[^\.0-9]+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</pre>


<h2><a href="#redirect-wordpress-feed" name="redirect-wordpress-feed" id="redirect-wordpress-feed" title="Redirecting WordPress Feeds to Feedburner" class="acd">Redirecting WordPress Feeds to Feedburner</a></h2>
<p>Full article:<a href="http://www.askapache.com/htaccess/redirecting-wordpress-feeds-to-feedburner.html" title="Redirecting WordPress Feeds to Feedburner">Redirecting WordPress Feeds to Feedburner</a></p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/feed\.gif$
RewriteRule .* - [L]
&nbsp;
RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]
&nbsp;
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</pre>


<h2><a href="#only-allow-get-and-put-requests" name="only-allow-get-and-put-requests" id="only-allow-get-and-put-requests" title="Only allow GET and PUT request methods" class="acd">Only allow GET and PUT Request Methods</a></h2>
<p>Article: <a class="acd" href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#http-methods-recognized" title="List of Apache Recognized Request Methods">Request Methods</a></p>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !^(GET|PUT)
RewriteRule .* - [F]
</pre>


<h2><a href="#prevent-hotlinking" name="prevent-hotlinking" id="prevent-hotlinking" title="Prevent Files image/file hotlinking and bandwidth stealing" class="acd">Prevent Files image/file hotlinking and bandwidth stealing</a></h2>
<pre>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
</pre>


<h2><a href="#stop-browser-prefetching" name="stop-browser-prefetching" id="stop-browser-prefetching" title="Stop browser prefetching" class="acd">Stop browser prefetching</a></h2>
<pre>
RewriteEngine On
SetEnvIfNoCase X-Forwarded-For .+ proxy=yes
SetEnvIfNoCase X-moz prefetch no_access=yes
&nbsp;
# block pre-fetch requests with X-moz headers
RewriteCond %{ENV:no_access} yes
RewriteRule .* - [F,L]
</pre>



<blockquote cite="http://askapache.info/trunk/mod/mod_rewrite.html#rewritebase">
<p>This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps. Even external database lookups in various formats can be used to achieve highly granular URL matching.</p>
<p>This module operates on the full URLs (including the path-info part) both in per-server context (<code>httpd.conf</code>) and per-directory context (<code>.htaccess</code>) and can generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput.</p>
<p>Further details, discussion, and examples, are provided in the <a href="http://askapache.info/trunk/rewrite/index.html">detailed mod_rewrite documentation</a>.</p>
</blockquote>
<h2>Directives</h2>
<ul>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewritebase">RewriteBase</a></li>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewritecond">RewriteCond</a></li>
    <li><a href="http://askapache.info/2.2/mod/mod_rewrite.html#rewriteengine">RewriteEngine</a></li>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewritelock">RewriteLock</a></li>
    <li><a href="http://askapache.info/2.0/mod/mod_rewrite.html#rewritelog">RewriteLog</a></li>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></li>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewritemap">RewriteMap</a></li>
    <li><a href="http://askapache.info/1.3/mod/mod_rewrite.html#rewriteoptions">RewriteOptions</a></li>
    <li><a href="http://askapache.info/trunk/mod/mod_rewrite.html#rewriterule">RewriteRule</a></li>
</ul>



<p>If you aren't already comfortable using mod_rewrite then I recommend this <a href="http://check-these.info/mod_rewrite-basic.html">excellent mod_rewrite guide</a> by one of my favorite mod_rewrite gurus that I've met.</p>



<hr />
<h2>htaccess Guide Sections</h2>
<ul class="ou">
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/htaccess-for-webmasters.html" title="Apache HTTP Web Server htaccess tips and tricks">htaccess tricks for Webmasters</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html" title="Creating and using HTTP Headers with htaccess">HTTP Header control with htaccess</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/php-htaccess-tips-and-tricks.html" title="mod_php or php as a cgi with htaccess tips, htaccess php tricks">PHP on Apache tips and tricks</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html" title="SEO-Friendly 301 Redirects without mod_rewrite">SEO Redirects without mod_rewrite</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html" title="mod_rewrite tips and tricks with RewriteEngine, RewriteBase, RewriteRule, and RewriteCond">mod_rewrite examples, tips, and tricks</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html" title="Caching, cache-control, cache, expires, and optimizing htaccess">HTTP Caching and Site Speedups</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html" title="htaccess and Apache authentication with htpasswd, 401, and 403">Authentication on Apache</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/security-with-htaccess.html" title="Security, hacking, and anti-hacking tips and tricks for htaccess">htaccess Security Tricks and Tips</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html" title="Apache SSL examples">SSL tips and examples</a></li>
    <li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/apache-variable-fun-in-htaccess.html" title="Apache variables info, tricks, and tips">Variable Fun (mod_env) Section</a></li><li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/mod_security-htaccess-tricks.html" title="mod_security Guide and sample mod_Security diretive usage in .htaccess">.htaccess Security with MOD_SECURITY</a></li><li><a rel="chapter bookmark" href="http://www.askapache.com/htaccess/setenvif.html" title="SetEnvIf and SetEnvIfNoCase Examples for conditionally setting variables in Apache .htaccess">SetEnvIf and SetEnvIfNoCase Examples</a></li>
</ul>


<p class="ment"><a rel="prev" href="http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html" title="Use htaccess to create SEO-Friendly 301 Redirects without mod_rewrite">&laquo;  Search Engine Friendly Redirects</a> | <a href="http://www.askapache.com/htaccess/htaccess.html" class="acd1" rel="Contents Index Start" title=".htaccess tutorial">.htaccess Tutorial Index</a> | <a rel="next" href="http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html" title="The Apache method for speeding up sites with Caching, cache-control, cache, expires, and optimizing htaccess">&raquo;  Speed up your site with Caching and cache-control</a></p><p><a href="http://www.askapache.com/htaccess/modrewrite-tips-tricks.html"></a><a href="http://www.askapache.com/htaccess/modrewrite-tips-tricks.html">Htaccess Rewrites &#8211; Rewrite Tricks and Tips</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/modrewrite-tips-tricks.html/feed</wfw:commentRss>
		<slash:comments>130</slash:comments>
		</item>
		<item>
		<title>Advanced Linux Debugging using a Bootloader (GRUB)</title>
		<link>http://www.askapache.com/linux/advanced-linux-grub.html</link>
		<comments>http://www.askapache.com/linux/advanced-linux-grub.html#comments</comments>
		<pubDate>Thu, 07 Apr 2011 16:35:41 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4846</guid>
		<description><![CDATA[<p>As an example, here is the boot line that I am using at the moment on an older Dell Desktop, just to illustrate module parameters and environment vars.  </p>
<pre>title  Arch Linux X-256
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootwait pause_on_oops=5 panic=60 i915.modeset=1 no_console_suspend ipv6.disable=1 TERM=xterm-256color quiet 5
initrd /kernel26.img</pre>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/advanced-linux-grub.html"></a><a href="http://www.askapache.com/linux/advanced-linux-grub.html"><cite>AskApache.com</cite></a></p><p>This is part of the <a href="https://wiki.archlinux.org/index.php/GRUB">GRUB article on the Arch Linux wiki that I contributed</a>.   As of now, just a copy.</p>

<p>The grub <code>menu.lst</code> provides for a convenient way to add a number of entries with <a href="http://www.kernel.org/doc/Documentation/kernel-parameters.txt" class="external text" rel="nofollow">extended kernel parameters</a> to configure all sorts of advanced settings to enable you to quickly and conveniently boot into your existing system with varying levels of debugging output.  It's very easy and useful to create several levels of debugging just by adding additional entries to your grub configuration. And if you ever have issues or problems down the road due to a power-failure or hardware failure, it can save you hours of trouble, and of course nothing can beat debugging output when it comes to learning about your system.</p>

<h2><span class="mw-headline" id="Useful_Menu.lst_Entries">Useful Menu.lst Entries</span></h2>
<p>If you are interested in debugging, then you deserve some grub entries for powerusers, here are a few that I like (just add to your <code>menu.lst</code>).</p>

<pre>title Shutdown the Computer
halt
&nbsp;
title Reboot the Computer
reboot
&nbsp;
title Command Line
commandline
&nbsp;
title Install GRUB to hd0 MBR
root (hd0,0)
setup (hd0)
&nbsp;
title Matrix
color green/black light-green/green
&nbsp;
title Scan for /boot/grub/menu.lst
find --set-root --ignore-floppies /boot/grub/menu.lst
configfile /boot/grub/menu.lst
&nbsp;
title Scan for /boot/menu.lst
find --set-root --ignore-floppies /menu.lst
configfile /boot/menu.lst
&nbsp;
# http://www.vortex.prodigynet.co.uk/x86test/
title    Run x86test (CPU Info)
kernel /boot/x86test_zImage.bin
#wget http://www.vortex.prodigynet.co.uk/x86test/x86test_zImage.bin
&nbsp;
# http://www.memtest.org/
title    Run memtest86+ (Memory Testing)
kernel /boot/memtest86+-1.70.bin</pre>

<h2> <span class="mw-headline" id="Light_Debug">Light Debug</span></h2>
<p>A quick way to see more verbose messages on your console is to bootup your normal grub entry after appending <strong>verbose</strong> to the kernel line.  This simple word added to your kernel line turns on more logging thanks to the <code>/etc/rc.sysinit</code> file, which at the top of the file runs:</p>
<pre>if /bin/grep -q " verbose" /proc/cmdline; then /bin/dmesg -n 8; fi</pre>
<p>Very simple way to get a bit more messages and debug output in your logs.</p>
<pre>title  Arch Linux DEBUG Light
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootwait verbose
initrd /kernel26.img</pre>

<h2> <span class="mw-headline" id="Medium_Debug">Medium Debug</span></h2>
<p>This example <code>menu.lst</code> entry turns on real logging that is set by the kernel and not in an init script.  Adding the <strong>debug</strong> kernel parameter to your kernel line is recognized by a lot of linux internals and enables quite a bit of debugging compared to the default. </p>

<pre>title Arch Linux DEBUG Medium
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootdelay=5 panic=10 debug
initrd /kernel26.img</pre>

<h2> <span class="mw-headline" id="Heavy_Debug">Heavy Debug</span></h2>
<p>An even more impressive kernel parameter is the <strong>ignore_loglevel</strong>, which causes the system to ignore any loglevel and keeps the internal loglevel at the maximum debugging level, basically rendering dmesg unable to lower the debug level.</p>
<pre>title Arch Linux DEBUG Heavy
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootdelay=5 panic=10 debug ignore_loglevel
initrd /kernel26.img</pre>

<h2> <span class="mw-headline" id="Extreme_Debug">Extreme Debug</span></h2>
<p>If the "Heavy Debug" seemed like a lot of output, thats about 1/2 of the logging that occurs with this example.  This does a couple things, it uses the <strong>earlyprintk</strong> parameter to setup your kernel for "early" "printing" of messages to your "vga" screen.  The <strong>,keep</strong> just lets it stay on the screen longer.  This will let you see logs that normally are hidden due to the boot-up process.
This also changes the log buffer length to 10MB, and also instructs that any fatal signals be printed with <strong>print_fatal_signals</strong>.  The last one, <strong>sched_debug</strong>, you can look up in the very excellent kernel documentation on <a href="http://www.kernel.org/doc/Documentation/kernel-parameters.txt" class="external text" rel="nofollow">kernel parameters</a>.</p>

<pre>title Arch Linux DEBUG Extreme
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro debug ignore_loglevel log_buf_len=10M print_fatal_signals=1 LOGLEVEL=8 earlyprintk=vga,keep sched_debug
initrd /kernel26.img</pre>

<h2> <span class="mw-headline" id="Insane_Debug">Insane Debug</span></h2>
<p>The first few debugging examples showed some really nice kernel parameters to turn on really verbose debugging.  This kind of debugging is absolutely critical if you want to max out your system or just learn more about what is going on behind the scenes.  But there is a final trick that is my favorite, it's the ability to set both environment variables, and more importantly, module parameters at boot.</p>

<p>As an example, here is the boot line that I am using at the moment on an older Dell Desktop, just to illustrate module parameters and environment vars.  </p>
<pre>title  Arch Linux X-256
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootwait pause_on_oops=5 panic=60 i915.modeset=1 no_console_suspend ipv6.disable=1 TERM=xterm-256color quiet 5
initrd /kernel26.img</pre>
<p>Since it's low on both memory and CPU, I disable ipv6. I also turn on kernel modesetting for the i915 video card, set my terminal to be xterm-256color, and boot straight into <a href="https://wiki.archlinux.org/index.php/Xorg" title="Xorg">X</a>.  This lets me use a very optimized arch-linux configuration, amazing how fast thanks to using <a href="https://wiki.archlinux.org/index.php/SLiM" title="SLiM">slim</a> as the login manager, <a href="https://wiki.archlinux.org/index.php/Ratpoison" title="Ratpoison">ratpoison</a> as my <a href="https://wiki.archlinux.org/index.php/Display_Manager" title="Display Manager">window manager</a>, and terminal with <a href="https://wiki.archlinux.org/index.php/Tmux" title="Tmux">tmux</a> as my login shell, all from boot, as the pstree shows (plus <a href="https://wiki.archlinux.org/index.php/Synergy" title="Synergy">Synergy</a>!).</p>
<pre>init,1
  |-slim,3096
  |   |-X,3098 -nolisten tcp vt07 -auth /var/run/slim.auth
  |   `-ratpoison,3107,askapache
  |       |-terminal,5341 -x sh -c exec /usr/bin/tmux -2 -l -u -q attach -d -t tmux-askapache
  |       |   |-bash,11165
  |       |   |-tmux,5345 -2 -l -u -q attach -d -t tmux-askapache
  |       |   `-{terminal},5346
  |       `-xscreensaver,3113 -no-splash
  |-synergyc,6121,galileo -f --name galileo-fire --restart 10.66.66.2:26666
  |
  `-tmux,5348,askapache -2 -l -u -q attach -d -t tmux-askapache
      |-bash,5351
      |   `-ssh,9969 lug@askapache.com
      `-bash,5868
         `-vim,11149 -p sda1/grub/menu.lst /boot/grub/menu.lst</pre>
<p>That kind of optimized system is only possible if you first can figure out your system, by debugging both the kernel as previously illustrated, debugging the init process, and most importantly, by debugging the modules enabled for your system's hardware/firmware/software.  Debugging modules is challenging but worth the effort, and then you are able to do some truly insane debugging from grub like the following example, note that the actual grub entry is all on one line, but I split it into 4 lines so you could see it all.  This basically turns on every module on this little Dell desktop to be at the absolute max debug level.  There is so much logging when I boot this that the system grinds to a halt and is slower than a TI-89 calculator (See <a href="https://wiki.archlinux.org/index.php/Improve_Boot_Performance" title="Improve Boot Performance">Improve Boot Performance</a>).</p>
<pre>title  Arch Linux DEBUG INSANE
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootwait ignore_loglevel debug debug_locks_verbose=1 sched_debug initcall_debug mminit_loglevel=4 udev.log_priority=8
       loglevel=8 earlyprintk=vga,keep log_buf_len=10M print_fatal_signals=1 apm.debug=Y i8042.debug=Y drm.debug=1 scsi_logging_level=1 usbserial.debug=Y
       option.debug=Y pl2303.debug=Y firewire_ohci.debug=1 hid.debug=1 pci_hotplug.debug=Y pci_hotplug.debug_acpi=Y shpchp.shpchp_debug=Y apic=debug
       show_lapic=all hpet=verbose lmb=debug pause_on_oops=5 panic=10 sysrq_always_enabled
initrd /kernel26.img</pre>
<p>A couple key items from that grub entry are <strong>sysrq_always_enabled</strong> which forces on the sysrq magic, which really is a lifesaver when debugging at this level as your machine will freeze/stop-responding sometimes and it's nice to use sysrq to kill all tasks, change the loglevel, unmount all filesystems, or do a hard reboot.  Another key parameter is the <strong>initcall_debug</strong>, which debugs the init process in excruciating detail.  Very useful at times.  The last parametery I find very useful is the <strong>udev.log_priority=8</strong> to turn on <a href="https://wiki.archlinux.org/index.php/Udev" title="Udev">udev</a> logging.  </p>


<h2><span class="mw-headline" id="Break_Into_Init">Break Into Init</span></h2>
<p>For instance, If you add <strong>break=y</strong> to your kernel cmdline, init will pause early in the <a href="https://wiki.archlinux.org/index.php/Arch_Boot_Process" title="Arch Boot Process">boot process</a> (after loading modules) and launch an interactive sh shell which can be used for troubleshooting purposes. (Normal boot continues after logout.)  This is very similar to the shell that shows up if your computer gets turned off before it is able to shutdown properly.  But using this parameter lets you enter into this mode differently at will.</p>
<pre>title  Arch Linux Init Break
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro rootwait break=y
initrd /kernel26.img</pre>

<h2><span class="mw-headline" id="Debugging_init">Debugging init</span></h2>

<p>This awesome parameter <strong>udev.log_priority=8</strong> does the same thing as editing the file <code>/etc/udev/udev.conf</code> except it executes earlier, turning on debugging output for <a href="https://wiki.archlinux.org/index.php/Udev" title="Udev">udev</a>.  If you want to know your hardware, that is the key parameter right there.  Another trick is if you change the <code>/etc/udev/udev.conf</code> to be verbose, then you can make your initrd image include that file to turn on verbose udeb debugging by adding it to your {{Filename|/etc/mkinitcpio.conf} like:</p>
<pre>FILES="/etc/modprobe.d/modprobe.conf /etc/udev/udev.conf"</pre>
<p>, which on arch is as easy as </p>
<pre># mkinitcpio -p kernel26</pre>
<p>Debugging <a href="https://wiki.archlinux.org/index.php/Udev" title="Udev">udev</a> is key because the <a href="https://wiki.archlinux.org/index.php/Initrd" title="Initrd">initrd</a> performs a <a href="https://wiki.archlinux.org/index.php/Change_Root" title="Change Root">root change</a> at the end of its run to usually launch a program like /sbin/init as part of a chroot, and unless the new file system has a valid /dev directory, udev must be initialized before invoking chroot in order to provide <code>/dev/console</code>.  </p>
<pre>exec chroot . /sbin/init &lt;dev/console &gt;dev/console 2&gt;&amp;1</pre>
<p>So basically, you aren't able to view the logs that are generated before /dev/console is initialized by udev or by a special initrd you compiled yourself.  One method the kernel developers use to be able to still get the log messages generated before /dev/console is available is to provide an alternative console that you can enable or disable from grub.</p>



<h2><span class="mw-headline" id="Net_Console">Net Console</span></h2>
<p>If you read through the kernel documentation regarding debugging, you will hear about Netconsole, which can be loaded from the kernel line in GRUB, compiled into your kernel, or loaded at runtime as a module.  Having a netconsole entry in your <code>menu.lst</code> is most excellent for debugging slower computers like old laptops or thin-clients.  It's easy to use.  Just setup a 2nd computer (running arch) to accept syslog requests on a remote port, very fast and quick to do on arch-linux, 1 line to syslog.conf.  Then you could use a log-color-parser like ccze to view all syslog logs, or just tail your everything.log. Then on your laptop, boot up and select the netconsole entry from the grub menu, and you will start seeing as much logging as you want on your syslog system.  This logging lets you view even earlier log output than is available with the earlyprintk=vga kernel parameter, as netconsole is used by kernel hackers and developers, so it's very powerful.</p>
<pre>title  Arch Linux DEBUG Netconsole
kernel /vmlinuz26 root=/dev/disk/by-label/ROOT ro netconsole=514@10.0.0.2/12:34:56:78:9a:bc debug ignore_loglevel
initrd /kernel26.img</pre>

<h2><span class="mw-headline" id="Hijacking_cmdline">Hijacking cmdline</span></h2>
<p>If you do not have access to GRUB or the kernel boottime cmdline, like on a server or virtual machine, as long as you have root permissions you can still enable this kind of simplistic verbose logging using a neat hack.  While you cannot modify the <code>/proc/cmdline</code> even as root, you can place your own cmdline file on top of /proc/cmdline, so that accessing /proc/cmdline actually accesses your file.</p>
<p>For example if I <strong>cat /proc/cmdline</strong>, I have the following:</p>
<pre>root=/dev/disk/by-label/ROOT ro console=tty1 logo.nologo quiet</pre>
<p>So I use a simple sed command to replace <strong>quiet</strong> with <strong>verbose</strong> like:</p>
<pre>sed &#039;s/ quiet/ verbose/&#039; /proc/cmdline &gt; /root/cmdline</pre>
<p>Then I bind mount /root/cmdline so that it becomes /proc/cmdline, using the <strong>-n</strong> option to mount so that this mount won't be recorded in the systems mtab.</p>
<pre>mount -n --bind -o ro /root/cmdline /proc/cmdline</pre>
<p>Now if I <strong>cat /proc/cmdline</strong>, I have the following:</p>
<pre>root=/dev/disk/by-label/ROOT ro console=tty1 logo.nologo verbose</pre><p><a href="http://www.askapache.com/linux/advanced-linux-grub.html"></a><a href="http://www.askapache.com/linux/advanced-linux-grub.html">Advanced Linux Debugging using a Bootloader (GRUB)</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/advanced-linux-grub.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

