<?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>SpaLinux.com &#187; Console</title>
	<atom:link href="http://spalinux.com/category/console/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>Resources for Relaxing Linux System Administrators</description>
	<lastBuildDate>Mon, 26 Jul 2010 09:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>วิธีการใช้คำสั่ง wget</title>
		<link>http://spalinux.com/2010/01/using_wget</link>
		<comments>http://spalinux.com/2010/01/using_wget#comments</comments>
		<pubDate>Fri, 22 Jan 2010 08:04:48 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Console]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1047</guid>
		<description><![CDATA[wget เป็นโปรแกรมที่ใช้เพื่อดาวน์โหลดไฟล์จากเว็บไซต์ได้ ในรูปแบบ text console วิธีการใช้งานก็ง่ายคือรันคำสั่ง wget ตามด้วย URL ที่ต้องการดาวน์โหลด ผลลัพธ์ที่ได้จะถูกบันทึกเป็นไฟล์ของเว็บเพจหน้านั้นๆ รูปแบบการใช้งาน $ wget [option]... [URL]... ตัวอย่างเช่น ต้องการดาวน์โหลดเว็บเพจหน้าแรกของ www.google.co.th $ wget 'http://www.google.co.th' --13:52:23--  http://www.google.co.th/            =&#62; `index.html' Resolving www.google.co.th... 72.14.203.147, 72.14.203.103, 72.14.203.104, ... Connecting to www.google.co.th&#124;72.14.203.147&#124;:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html]     [  &#60;=&#62;                                                                                ] 6,726         11.96K/s 13:52:24 (11.96 [...]]]></description>
			<content:encoded><![CDATA[<p>wget เป็นโปรแกรมที่ใช้เพื่อดาวน์โหลดไฟล์จากเว็บไซต์ได้ ในรูปแบบ text console วิธีการใช้งานก็ง่ายคือรันคำสั่ง wget ตามด้วย URL ที่ต้องการดาวน์โหลด ผลลัพธ์ที่ได้จะถูกบันทึกเป็นไฟล์ของเว็บเพจหน้านั้นๆ</p>
<p><span id="more-1047"></span></p>
<h4>รูปแบบการใช้งาน</h4>
<pre>$ <strong>wget</strong> [option]... [URL]...</pre>
<p>ตัวอย่างเช่น ต้องการดาวน์โหลดเว็บเพจหน้าแรกของ www.google.co.th</p>
<pre>$ <strong>wget 'http://www.google.co.th'
</strong>--13:52:23--  http://www.google.co.th/
           =&gt; `index.html'
Resolving www.google.co.th... 72.14.203.147, 72.14.203.103, 72.14.203.104, ...
Connecting to www.google.co.th|72.14.203.147|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]</pre>
<pre>    [  &lt;=&gt;                                                                                ] 6,726         11.96K/s</pre>
<pre>13:52:24 (11.96 KB/s) - `<span style="color: #0000ff;">index.html</span>' saved [6726]</pre>
<p>จากตัวอย่าง ผลลัพธ์ที่ได้จะถูกบันทึกเป็นชื่อ index.html</p>
<p>หมายเหตุ แนะนำให้ใส่เครื่องหมายคำพูด &#8216;  คลอบ URL เพราะบางตัวอักษรอาจมีความหมายใน SHELL</p>
<pre>$ <strong>cat index.html
</strong>&lt;!doctype html&gt;&lt;html&gt;&lt;head&gt;&lt;meta http-equiv="content-type" content="text/html; charset=windows-874"&gt;&lt;title&gt;Google&lt;/title&gt;
...</pre>
<p>ระบุออปชั่น &#8216;&#8211;help&#8217; เพื่อดูวิธีการใช้งาน พร้อมทั้งออปชั่นต่างๆ</p>
<pre>$ <strong>wget --help
</strong>GNU Wget 1.10.2 (Red Hat modified), a non-interactive network retriever.
Usage: wget [OPTION]... [URL]...</pre>
<pre>Mandatory arguments to long options are mandatory for short options too.</pre>
<pre>Startup:
  -V,  --version           display the version of Wget and exit.
  -h,  --help              print this help.
  -b,  --background        go to background after startup.
  -e,  --execute=COMMAND   execute a `.wgetrc'-style command.</pre>
<p>ในบทความนี้ขอแนะนำการใช้ออปชั่นที่ผู้เขียนใช้บ่อยๆ</p>
<h4>ดูรายละเอียดการโหลด (debug)</h4>
<p>ระบุออปชั่น &#8216;-d&#8217; เพื่อดูรายละเอียดการดาวน์โหลด เช่นดู HTTP Header, Protocol, Cookie ที่เกิดขึ้นในการดาวน์โหลด</p>
<pre>$ <strong>wget -d 'http://www.google.co.th'
</strong>DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.</pre>
<pre>--14:16:24--  http://www.google.co.th/
           =&gt; `index.html'
Resolving www.google.co.th... 72.14.203.105, 72.14.203.106, 72.14.203.99, ...
Caching www.google.co.th =&gt; 72.14.203.105 72.14.203.106 72.14.203.99 72.14.203.104 72.14.203.103 72.14.203.147
Connecting to www.google.co.th|72.14.203.105|:80... connected.
Created socket 3.
Releasing 0x000000000083d390 (new refcount 1).</pre>
<pre>---request begin---
GET / HTTP/1.0
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Host: www.google.co.th
Connection: Keep-Alive</pre>
<pre>---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.0 200 OK
Date: Fri, 22 Jan 2010 07:16:29 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=windows-874
Set-Cookie: PREF=ID=79a6955a36392a2d:TM=1264144589:LM=1264144589:S=c99kK7cOeBwCp4KG; expires=Sun, 22-Jan-2012 07:16:29 GMT; path                                             =/;</pre>
<pre>domain=.google.co.th
Set-Cookie: NID=31=h8-gos7iGB-MXzlXOo4C1_CRqzSNE6wu5Os2WBu6C-jm7tPhrlj4kJp1aiENCM66f388IScBzce4Q-6x7rwbfxUUbp2DGAIcxXu1zwSGy6zKH                                            </pre>
<pre>cjUQ2_59hiym_wuaRt2; expires=Sat, 24-Jul-2010 07:16:29 GMT; path=/; domain=.google.co.th; HttpOnly
Server: gws
X-XSS-Protection: 0</pre>
<pre>---response end---
200 OK
cdm: 1 2 3 4 5 6 7 8
Stored cookie google.co.th -1 (ANY) / &lt;permanent&gt; &lt;insecure&gt; [expiry 2012-01-22 14:16:29] PREF ID=79a6955a36392a2d:TM=1264144589                                            </pre>
<pre>:LM=1264144589:S=c99kK7cOeBwCp4KG
cdm: 1 2 3 4 5 6 7 8
Stored cookie google.co.th -1 (ANY) / &lt;permanent&gt; &lt;insecure&gt; [expiry 2010-07-24 14:16:29] NID 31=h8-gos7iGB-MXzlXOo4C1_CRqzSNE6w                                            </pre>
<pre>u5Os2WBu6C-jm7tPhrlj4kJp1aiENCM66f388IScBzce4Q-6x7rwbfxUUbp2DGAIcxXu1zwSGy6zKHcjUQ2_59hiym_wuaRt2
Length: unspecified [text/html]</pre>
<pre>    [  &lt;=&gt;                                                                                ] 6,702          6.21K/s</pre>
<pre>Closed fd 3
14:16:31 (6.20 KB/s) - `index.html' saved [6702]</pre>
<h4>ดาวน์โหลดต่อไฟล์ (continue)</h4>
<p>สามารถดาวน์โหลดไฟล์ต่อจากที่ดาวน์โหลดยังไม่ครบได้</p>
<p>เช่นต้องการดาวน์โหลดไฟล์ iso ที่มีขนาดใหญ่มาก แล้วดาวน์โหลดครั้งแรกยังไม่ครบ</p>
<pre>$ <strong>wget 'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--14:09:51--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
           =&gt; `Fedora-11-x86_64-Live.iso'
Resolving <a href="http://www.mirror.in.th/">www.mirror.in.th</a>... 61.7.253.242
Connecting to www.mirror.in.th|61.7.253.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 724,097,024 (691M) [application/octet-stream]</pre>
<pre> 0% [                                                                                     ] 1,090,066     87.82K/s  ETA 2:13:52</pre>
<p>หมายเหตุ ในระหว่างการดาวน์โหลด หากต้องการยกเลิกให้กด [Ctrl-C]</p>
<p>ครั้งแรกดาวน์โหลดไฟล์ได้แค่ 1 Meg กว่าๆ</p>
<pre>$ <strong>ls -l
</strong>total 1080
-rw-r--r-- 1 user1  users  1098754 2010-01-22 14:10 Fedora-11-x86_64-Live.iso</pre>
<p>ถ้าต้องการดาวน์โหลดต่อ ต้องระบุออปชั่น &#8216;-c&#8217;</p>
<pre>$ <strong>wget -c 'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--14:11:46--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
           =&gt; `Fedora-11-x86_64-Live.iso'
Resolving www.mirror.in.th... 61.7.253.242
Connecting to www.mirror.in.th|61.7.253.242|:80... connected.
HTTP request sent, awaiting response... 206 <span style="color: #0000ff;">Partial Content</span>
Length: 724,097,024 (691M), 722,998,270 (690M) remaining [application/octet-stream]</pre>
<pre> 0% [                                                                                     ] 1,401,045     94.59K/s  ETA 2:04:50</pre>
<pre>$ <strong>ls -l
</strong>total 1384
-rw-r--r-- 1 user1  users  1409733 2010-01-22 14:11 Fedora-11-x86_64-Live.iso</pre>
<h4>จำกัดความเร็วการโหลด</h4>
<p>ต้องการโหลดไฟล์แต่ไม่ต้องการเบียดบังความเร็วการใช้อินเตอร์เน็ตจากคนอื่นมากเกินไป เราสามารถจำกัดความเร็วในการโหลดของเราได้ ด้วยออปชั่น &#8216;&#8211;limit-rate&#8217;</p>
<p>เช่นต้องการจำกัดไว้ที่ 10 KBytes/s</p>
<pre>$ <strong>wget --limit-rate 10000 'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--14:25:14--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
           =&gt; `Fedora-11-x86_64-Live.iso'
Resolving www.mirror.in.th... 61.7.253.242
Connecting to www.mirror.in.th|61.7.253.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 724,097,024 (691M) [application/octet-stream]</pre>
<pre> 0% [                                                                                     ] 62,618         9.77K/s ETA 20:07:01</pre>
<p>หมายเหตุ หน่วยของออปชั่น &#8216;&#8211;limit-rate&#8217; เป็น bytes per second</p>
<h4>โหลดผ่าน proxy</h4>
<p>หากต้องใช้ proxy ในการโหลด ต้องมีการระบุตัวแปร &#8216;http_proxy&#8217; ไว้ใน shell ก่อนรันคำสั่ง เช่น IP ของ proxy คือ 192.168.1.1 และพอร์ต proxy คือ 3128 ถ้าใช้ BASH สามารถทำได้โดย</p>
<pre>$ <strong>export http_proxy=http://192.168.1.1:3128</strong></pre>
<p>ใช้คำสั่ง wget พร้อมระบุออปชั่น &#8216;&#8211;proxy&#8217; เพื่อให้โหลดผ่าน proxy</p>
<pre>$ <strong>wget --proxy 'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--2010-01-22 14:30:26--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
Connecting to 192.168.1.1:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 724097024 (691M) [application/octet-stream]
Saving to: `Fedora-11-x86_64-Live.iso'</pre>
<pre> 0% [                                                                                     ] 63,434      96.4K/s</pre>
<p>แต่ถ้า proxy ต้องระบุ user, password ด้วย จะขึ้น error ดังนี้</p>
<pre>$ <strong>wget --proxy  'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--2010-01-22 14:31:06--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
Connecting to 192.168.1.1:3128... connected.
Proxy request sent, awaiting response... 407 Proxy Authentication Required
2010-01-22 14:31:06 ERROR 407: Proxy Authentication Required.</pre>
<pre>ใช้ออปชั่น '--proxy-user' และ '--proxy-password' เพื่อระบุ user, password ในการใช้ proxy</pre>
<pre>$ <strong>wget --proxy-user=prxuser --proxy-password=prx1234  'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--2010-01-22 14:30:26--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
Connecting to 192.168.1.1:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 724097024 (691M) [application/octet-stream]
Saving to: `Fedora-11-x86_64-Live.iso'</pre>
<pre> 0% [                                                                                     ] 63,434      96.4K/s</pre>
<h4>ไฟล์คอนฟิก .wgetrc</h4>
<p>แทนที่จะต้องระบุออปชั่น proxy ทุกครั้ง สามารถสร้างเป็นไฟล์คอนฟิกสำหรับใช้คำสั่ง wget โดยสร้างไฟล์ชื่อ .wgetrc (มีเครื่องหมายจุดนำหน้าชื่อไฟล์ด้วย) ไว้ใน HOME ของผู้ใช้งาน</p>
<pre>$ <strong>cat ~/.wgetrc
</strong>http_proxy=http://192.168.1.1:3128/
proxy_user=prxuser
proxy_password=prx1234</pre>
<p>หลังจากสร้างไฟล์คอนฟิก .wgetrc แล้ว เวลาใช้คำสั่ง wget ก็ไม่ต้องระบุออปชั่นใดๆ อีก</p>
<pre>$ <strong>wget  'http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso'
</strong>--2010-01-22 14:37:46--  http://www.mirror.in.th/osarchive/fedora/releases/11/Live/x86_64/Fedora-11-x86_64-Live.iso
Connecting to 192.168.1.1:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 724097024 (691M) [application/octet-stream]
Saving to: `Fedora-11-x86_64-Live.iso.1'</pre>
<pre> 0% [                                                                                     ] 80,810      95.8K/s</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://www.gnu.org/software/wget/" target="_blank">GNU Wget</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/01/using_wget/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ปรับแต่งเครื่องหลังจากติดตั้ง Fedora 9 &#8211; แก้ไขคอนโซล (Text Console)</title>
		<link>http://spalinux.com/2008/09/fedora_9_post_installation_configure_console</link>
		<comments>http://spalinux.com/2008/09/fedora_9_post_installation_configure_console#comments</comments>
		<pubDate>Mon, 08 Sep 2008 16:56:30 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Console]]></category>
		<category><![CDATA[Linux Installation]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=140</guid>
		<description><![CDATA[หลายคนเมื่อติดตั้งลินุกซ์เรียบร้อยแล้ว เกิดคำถามว่าทำอะไรต่อดี เริ่มต้นคอนฟิกอย่างไร  ในบทความนี้ขอเริ่มแนะนำคอนฟิกเพื่อการปรับแต่งคอนโซลของเครื่องลินุกซ์ ซึ่งจะมีทั้งปรับแต่งเพื่อความปลอดภัย และประหยัด Memory ที่ใช้ หมายเหตุ คอนโซล ในที่นี้หมายถึง text console ที่แสดงผลในรูปแบบตัวอักษร ไม่ใช่ X Window ยกเลิกการแสดงเวอร์ชั่นของลินุกซ์ผ่านทางหน้าจอคอนโซล (Console) โดยดีฟอลต์แล้วหลังจากการติดตั้ง หน้าจอคอนโซล (Console) ที่รอรับการ login จะแสดงเวอร์ชั่นของลินุกซ์ที่ติดตั้งด้วย โดยข้อความที่แสดงจะนำมาจากไฟล์ /etc/issue ตัวอย่างไฟล์ /etc/issue ที่ติดตั้งมากับ Fedora 9 [root@server ~]# cat /etc/issue Fedora release 9 (Sulphur) Kernel r on an m (l) ตัวอย่างหน้าจอคอนโซลของ Fedora 9 Fedora release 9 (Sulphur) Kernel 2.6.25-14.fc9.i686 [...]]]></description>
			<content:encoded><![CDATA[<p>หลายคนเมื่อติดตั้งลินุกซ์เรียบร้อยแล้ว เกิดคำถามว่าทำอะไรต่อดี เริ่มต้นคอนฟิกอย่างไร  ในบทความนี้ขอเริ่มแนะนำคอนฟิกเพื่อการปรับแต่งคอนโซลของเครื่องลินุกซ์ ซึ่งจะมีทั้งปรับแต่งเพื่อความปลอดภัย และประหยัด Memory ที่ใช้</p>
<p>หมายเหตุ คอนโซล ในที่นี้หมายถึง text console ที่แสดงผลในรูปแบบตัวอักษร ไม่ใช่ X Window</p>
<p><span id="more-140"></span></p>
<h4>ยกเลิกการแสดงเวอร์ชั่นของลินุกซ์ผ่านทางหน้าจอคอนโซล (Console)</h4>
<p>โดยดีฟอลต์แล้วหลังจากการติดตั้ง หน้าจอคอนโซล (Console) ที่รอรับการ login จะแสดงเวอร์ชั่นของลินุกซ์ที่ติดตั้งด้วย โดยข้อความที่แสดงจะนำมาจากไฟล์ /etc/issue</p>
<p>ตัวอย่างไฟล์ /etc/issue ที่ติดตั้งมากับ Fedora 9</p>
<pre>[root@server ~]# <strong>cat /etc/issue
</strong>Fedora release 9 (Sulphur)
Kernel r on an m (l)</pre>
<p>ตัวอย่างหน้าจอคอนโซลของ Fedora 9</p>
<pre>Fedora release 9 (Sulphur)
Kernel 2.6.25-14.fc9.i686 on an i686 (tty1)</pre>
<pre>server login:</pre>
<p>เพื่อความปลอดภัย แนะนำให้แก้ไขข้อความที่แสดงเวอร์ชั่น หรือลบออกไปเลยก็ได้ เมื่อแก้ไขไฟล์เสร็จแล้ว ที่หน้าจอคอนโซล กด [Ctrl – L ] เพื่อให้คอนฟิกใหม่มีผล</p>
<hr />
<h4>ยกเลิกการรันหน้าจอคอนโซลที่ 2 &#8211; 6</h4>
<p>หน้าจอคอนโซลที่ติดตั้งมากับลินุกซ์ตั้งแต่เวอร์ชั่นแรกๆ ตั้งแต่ยังไม่มี X Window จนถึงปัจจุบันนี้ จะมีหน้าจอคอนโซลที่สามารถทำงานพร้อมๆ กันได้ 6 หน้าจอ โดยกดปุ่ม [Alt-Fx] สลับไปมา ระหว่างหน้าจอคอนโซล เช่นต้องการไปหน้าจอที่ 5 ก็กดปุ่ม [Alt-F5]</p>
<p>ในการใช้งานจริงปัจจุบันนี้ ส่วนใหญ่จะทำงานผ่าน X Window ไม่ว่าจะใช้ GNOME หรือ KDE  หรือไม่ก็ใช้การรีโมตเข้าไปเช่นใช้ Secure Shell เป็นต้น ดังนั้นหน้าจอ Console แทบไม่มีความจำเป็นต้องใช้เลย</p>
<p>ดังนั้นแนะนำให้ยกเลิกหน้าจอคอนโซลที่ 2 ถึง 6 ให้เหลือไว้แต่หน้าจอคอนโซลที่ 1 ซึ่งไว้สำหรับการ แก้ไขปัญหา การบู๊ตเครื่องเป็นต้น</p>
<p>ประโยชน์ของการยกเลิกหน้าจอ ก็เพื่อประหยัด Memory ของเครื่องที่ต้องรันโปรแกรมรองรับการ login ผ่านหน้าจอคอนโซลนั่นเอง ถึงแม้จะดูว่ากินเพียงเล็กน้อยเท่านั้น แต่ถ้าไม่ต้องใช้ก็ไม่จำเป็นต้องรัน</p>
<p>ตรวจสอบโปรแกรมที่รันสำหรับรองรับการ login ผ่านคอนโซล<br />
โปรแกรมที่ลินุกซ์ส่วนใหญ่ใช้รันเพื่อรองรับการ login ผ่านหน้าจอคอนโซลนั้น คือ /sbin/mingetty ซึ่งโดยดีฟอลต์แล้วจะรันขึ้นมาทั้งหมด 6 หน้าจอ สามารถใช้คำสั่ง ps เพื่อแสดงปริมาณ Memory ที่ใช้ได้ดังนี้</p>
<pre>[root@server ~]# <strong>ps auxw | egrep "(USER|min)"
</strong>USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1592  0.0  0.0   1812   428 tty4     Ss+  00:31   0:00 /sbin/mingetty tty4
root      1593  0.0  0.0   1812   424 tty5     Ss+  00:31   0:00 /sbin/mingetty tty5
root      1594  0.0  0.0   1812   428 tty2     Ss+  00:31   0:00 /sbin/mingetty tty2
root      1595  0.0  0.0   1812   424 tty3     Ss+  00:31   0:00 /sbin/mingetty tty3
root      1596  0.0  0.0   1812   424 tty1     Ss+  00:31   0:00 /sbin/mingetty tty1
root      1597  0.0  0.0   1812   424 tty6     Ss+  00:31   0:00 /sbin/mingetty tty6</pre>
<p>สำหรับไฟล์คอนฟิกที่ใช้ในการควบคุมโปรแกรม /sbin/mingetty อีกทีนั้น จะมีอยู่สองแบบขึ้นอยู่กับเวอร์ชั่นของลินุกซ์ที่ติดตั้ง สำหรับ Fedora นั้น ก่อน Fedora 9 จะใช้ไฟล์คอนฟิก /etc/inittab ในการควบคุม แต่ถ้าเป็นเวอร์ชั่น 9 เป็นต้นมา จะแยกเป็นคอนฟิกไฟล์ย่อยๆ อยู่ใน /etc/event.d/</p>
<h5>การยกเลิกคอนโซล 2-6 สำหรับ Fedora ก่อนเวอร์ชั่น 9</h5>
<p>ต้องเข้าไปแก้ไขไฟล์ /etc/inittab</p>
<p>ตัวอย่างไฟล์ /etc/inittab ในส่วนควบคุม /sbin/mingetty ที่ติดตั้งมากับ Fedora ก่อนเวอร์ชั่น 9</p>
<pre># Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6</pre>
<p>วิธีการแก้ไขให้ใส่เครื่องหมาย # ก่อนหน้าบรรทัดของโปรแกรม /sbin/mingetty ตั้งแต่เลข 2 ถึงเลข 6 หรือจะลบบรรทัดเหล่านี้ทิ้งไปเลยก็ได้ ให้เหลือแต่บรรทัดที่มีเลข 1 นำหน้า</p>
<p>ตัวอย่างไฟล์ /etc/inittab หลังการแก้ไข</p>
<pre># Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6</pre>
<p>เมื่อแก้ไขไฟล์ /etc/inittab เสร็จแล้ว ให้รันคำสั่ง init q เพื่อให้โปรเซส init อ่านไฟล์ /etc/inittab ใหม่ ซึ่งจำทำให้คอนโซลที่ 2 – 6 ใช้งานไม่ได้อีกต่อไป</p>
<h5>การยกเลิกคอนโซล 2-6 สำหรับ Fedora 9</h5>
<p>ตั้งแต่ Fedora 9 ไฟล์คอนฟิกของโปรเซส init จะถูกควบคุมด้วย /etc/event.d/ โดยจะมีไฟล์ย่อยๆ ออกจากกัน เช่นไฟล์คอนฟิกสำหรับรันหน้าจอคอนโซลที่ 2 คือไฟล์ /etc/event.d/tty2</p>
<p>ตัวอย่างไฟล์คอนฟิกสำหรับรันหน้าจอคอนโซลที่ 2</p>
<pre>[root@server event.d]# <strong>cat /etc/event.d/tty2
</strong># tty2 - getty
#
# This service maintains a getty on tty2 from the point the system is
# started until it is shut down again.</pre>
<pre>start on stopped rc2
start on stopped rc3
start on stopped rc4
start on started prefdm</pre>
<pre>stop on runlevel 0
stop on runlevel 1
stop on runlevel 6</pre>
<pre>respawn
exec /sbin/mingetty tty2</pre>
<p>วิธีการที่จะยกเลิกหน้าจอคอนโซลได้นั้น ต้องลบไฟล์คอนฟิกเป็นไฟล์ๆ ไป เช่นยกเลิกหน้าจอที่ 2 ก็ลบไฟล์ /etc/event.d/tty2 ออกไป ดังนั้นถ้าต้องการยกเลิกหน้าจอที่ 2 -  6 สามารถทำได้ดังนี้</p>
<pre>[root@server ~]# rm -f /etc/event.d/tty2
[root@server ~]# rm -f /etc/event.d/tty3
[root@server ~]# rm -f /etc/event.d/tty4
[root@server ~]# rm -f /etc/event.d/tty5
[root@server ~]# rm -f /etc/event.d/tty6</pre>
<p>หลังจากลบไฟล์แล้วต้องใช้คำสั่ง initctl เพื่อให้คอนฟิกใหม่มีผล ซึ่งต้องใช้คำสั่ง initctl เพื่อหยุดการรันโปรแกรมที่ละหน้าจอ</p>
<p>ตัวอย่างการรันคำสั่ง initctl เพื่อหยุดการรันโปรแกรมสำหรับหน้าจอคอนโซลที่ 3</p>
<pre>[root@server ~]# initctl stop tty3
tty3 (stop) running, process 1595
tty3 (stop) pre-stop, (main) process 1595
tty3 (stop) stopping, process 1595
tty3 (stop) killed, process 1595
tty3 (stop) post-stop
tty3 (stop) waiting</pre>
<pre>[root@server ~]# initctl status tty3
initctl: Unknown job: tty3</pre>
<p>ใช้คำสั่ง ps ตรวจสอบอีกครั้งหลังจากการยกเลิกหน้าจอที่ 2-6 จะเห็นได้ว่าเหลือแค่โปรเซสเดียวเท่านั้น ไว้รองรับหน้าจอคอนโซลที่ 1 ซึ่งเป็นดีฟอลต์นั่นเอง</p>
<p>คำเตือน ไม่แนะนำให้ลบนะครับหน้าจอคอนโซลที่ 1</p>
<pre>[root@server ~]# ps auxw | egrep "(USER|min)"
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     11095  0.0  0.0   1812   428 tty1     Ss+  20:16   0:00 /sbin/mingetty tty1</pre>
<hr />
<h4>ยกเลิกการกดปุ่ม [Ctrl-Alt-Del] เพื่อการรีบู๊ตเครื่อง</h4>
<p>หลายคนที่ใช้ Windows บ่อยๆ อาจติดนิสัยกดปุ่ม [Ctrl-Alt-Del] เพื่อทำการล๊อคหน้าจอ หรือเพื่อดู Task Manager ซึ่งถ้าพลาดมากดปุ่มนี้บนหน้าจอคอนโซลของลินุกซ์ โดยดีฟอลต์แล้วจะทำให้เครื่องลินุกซ์ถูกรีบู๊ตไป เป็นอันตรายอย่างยิ่ง ดังนั้นแนะนำให้ยกเลิกคุณสมบัตินี้ออกไป</p>
<p>วิธีการยกเลิกการกดปุ่ม [Ctrl-Alt-Del] เพื่อการรีบู๊ตเครื่องนั้น ทำได้สองวิธีขึ้นอยู่กับเวอร์ชั่นของลินุกซ์ที่ใช้ เช่นเดียวกับการยกเลิกการรันหน้าจอคอนโซล</p>
<h5>ยกเลิกการกดปุ่ม [Ctrl-Alt-Del] เพื่อการรีบู๊ตเครื่อง สำหรับ Fedora ก่อนเวอร์ชั่น 9</h5>
<p>ไฟล์คอนฟิกที่ทำให้เครื่องลินุกซ์ถูกรีบู๊ตเมื่อกดปุ่ม [Ctrl-Alt-Del] จะถูกเก็บอยู่ในไฟล์ /etc/inittab</p>
<p>ตัวอย่างไฟล์คอนฟิก /etc/inittab ในส่วนการกดปุ่ม [Ctrl-Alt-Del]</p>
<pre># Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now</pre>
<p>จากคอนฟิกเมื่อมีการกดปุ่ม [Ctrl-Alt-Del] เครื่องจะรันคำสั่ง shutdown เพื่อรีบู๊ตเครื่อง</p>
<p>การยกเลิกไม่ให้รีบู๊ต ให้แก้ไขไฟล์คอนฟิกนี้ โดยใส่เครื่องหมาย # ก่อนหน้าบรรทัดที่มีคำว่า ca หรือจะลบบรรทัดนี้ทิ้งไปเลยก็ได้เช่นกัน แล้วรันคำสั่ง init q เพื่อให้โปรเซส init อ่านไฟล์ /etc/inittab ใหม่ให้มีผลทันที</p>
<p>ตัวอย่างการแก้ไขไฟล์ /etc/inittab เพื่อไม่ให้รีบู๊ต</p>
<pre># Trap CTRL-ALT-DELETE
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now</pre>
<h5>ยกเลิกการกดปุ่ม [Ctrl-Alt-Del] เพื่อการรีบู๊ตเครื่อง สำหรับ Fedora 9</h5>
<p>ไฟล์คอนฟิกในเวอร์ชั่นนี้จะเก็บแยกเป็นไฟล์ชื่อ /etc/event.d/control-alt-delete</p>
<p>ตัวอย่างไฟล์ /etc/event.d/control-alt-delete</p>
<pre>[root@server event.d]# <strong>cat control-alt-delete
</strong># control-alt-delete - emergency keypress handling
#
# This task is run whenever the Control-Alt-Delete key combination is
# pressed.  Usually used to shut down the machine.</pre>
<pre>start on control-alt-delete</pre>
<pre>exec /sbin/shutdown -r now "Control-Alt-Delete pressed"</pre>
<p>การแก้ไขทำได้โดยลบไฟล์นี้ทิ้งไป และจะมีผลทันที</p>
<pre>[root@server ~]# <strong>initctl status control-alt-delete
</strong>initctl: Unknown job: control-alt-delete</pre>
<p>สามารถทดสอบได้โดยการกดปุ่ม [Ctrl-Alt-Delete] อีกครั้ง เครื่องจะไม่รีบู๊ตอีกต่อไป</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/09/fedora_9_post_installation_configure_console/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
