<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>MEPO Forum - Linux系統管理</title>
        <description></description>
        <link>http://mepopedia.com/forum/list.php?135</link>
        <lastBuildDate>Mon, 27 Apr 2026 20:16:41 +0800</lastBuildDate>
        <generator>Phorum 5.2.7</generator>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,90293,90293#msg-90293</guid>
            <title>DNS設定反查與偵錯：dig指令深入使用 (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,90293,90293#msg-90293</link>
            <description><![CDATA[一、目的<br />
當DNS查詢出現錯誤無法解析出正確IP，經由以下方式，可以查出於整個DNS查詢路徑中，錯誤出在那一階段的DNS主機以及DNS記錄錯誤為何。<br />
<br />
二、原理與流程<br />
以下我們以查詢 www.ntu.edu.tw 之 IP 作為例子說明查詢的原理與流程。<br />
<br />
1. 慣用DNS伺服器：作業系統之DNS查詢首先從詢問「慣用DNS伺服器」開始，一般我們會設定為 Google 的 DNS (8.8.8.8) 或者中華電信的 DNS (168.95.1.1) [1]。並且，可以由以下指令查詢：<br />
<div style="background:#ddd;padding-left:1em;margin-top:0.5em">$ cat /etc/resolv.conf</div>
<br />
2. 決定查詢路徑：作業系統會從網域的「最後段」一路反向查詢到「最前段」。例如，以網域 www.ntu.edu.tw 為例，首先會查詢負責回應 <b>tw</b> 網域DNS記錄的主機為何，再接著查詢負責 <b>edu</b> 網域的主機，而後是負責 <b>ntu</b> 網域的主機。最後，再詢問負責 <b>ntu</b> 網域的主機，網域名稱 <b>www</b> 的主機 IP 為何。也就是查詢路徑為：<br />
<br />
<div style="text-align:center"><b>tw → edu → ntu → www</b></div>
<br />
三、反查指令與步驟<br />
1. DNS 的查詢 (反查) 以 <b>dig</b> 指令進行。首先，我們詢問「慣用DNS伺服器」(例如 8.8.8.8)：網域 tw 的「網域名稱解析主機」(Name Server, NS) 為何？查詢指令 <b>dig</b> 以接近直覺的格式達成上述目的：<br />
<div style="background:#ddd;padding-left:1em;margin-top:0.5em">$ dig @8.8.8.8 tw ns</div>
<br />
其中，指令中的「ns」，指的是查詢種類 (type) 為「Name Server」。還可以查詢的種類包括 MX (電子郵件)、A (IPv4位置)、AAAA (IPv6位置)。查詢結果如下：<br />
<br />
<img src="//mepopedia.com/files/dig tw.jpg"><br />
<br />
2. 由上面的結果我們可以看到，負責回應 <b>tw</b> 網域的主機共有11個 (c.dns.tw, a.dns.tw,..., anytld.apnic.net)。我們接著詢問第一個主機 (c.dns.tw) 網域 <b>gov.tw</b> 的負責主機為何：<br />
<div style="background:#ddd;padding-left:1em;margin-top:0.5em">$ dig @c.dns.tw gov.tw ns</div>
<br />
<img src="//mepopedia.com/files/dig edu.tw.jpg"><br />
<br />
首先我們可以看到負責 <b>edu.tw</b> 網域的名稱主機記錄有 d.twnic.net.tw 等5筆。接著，是上述名稱主機對應的 IP (IPv4 與 IPv6 / A Record 與 AAAA Record)。<br />
<br />
3. 我們再接著詢問名稱主機 d.twnic.net.tw 網域<b>ntu.edu.tw</b> 的負責主機為何：<br />
<div style="background:#ddd;padding-left:1em;margin-top:0.5em">$ dig @d.twnic.net.tw edu.gov.tw ns</div>
<br />
<img src="//mepopedia.com/files/dig ntu.edu.tw.jpg"><br />
<br />
[1] 常用公共網域名稱解析主機<br />
 (1) Cloudflare 1.1.1.1 <br />
 (2) Google 8.8.8.8<br />
 (3) IBM 9.9.9.9<br />
 (4) 中華電信 168.95.1.1 / 168.95.192.1<br />
<br />
線上反查工具 (DNS Delegation)：<br />
https://simpledns.plus/lookup-dg]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Fri, 17 Jan 2020 09:06:01 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,88941,88941#msg-88941</guid>
            <title>Install a LAPP Stack (Apache 2.4/PHP 7/PostgreSQL 10/MariaDB 10) on openSUSE Tumbleweed (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,88941,88941#msg-88941</link>
            <description><![CDATA[Assume the Tumbleweed linux is ready.<br />
<br />
<center>I. Database </center>Install the database first (PostgreSQL 10):<br />
<br />
1.  Install database<br />
<div style="background:#ddd;padding-left:1em">zypper install postgresql10 postgresql10-contrib postgresql10-server</div>
<br />
2. Enable auto-start on boot<br />
<div style="background:#ddd;padding-left:1em">chkconfig -a postgresql</div>
<br />
3. Start PostgreSQL<br />
<div style="background:#ddd;padding-left:1em">systemctl start postgresql.service</div>
<br />
4. Set password for postgres<br />
Switch user to postgres:<br />
<div style="background:#ddd;padding-left:1em">su postgres<br />
psql</div>
In the psql console, set the password:<br />
<div style="background:#ddd;padding-left:1em">\password postgres</div>
<br />
5. Fine-tune performance<br />
(1) Edit postgresql.conf<br />
<div style="background:#ddd;padding-left:1em">vi /var/lib/pgsql/data/postgresql.conf</div>
(2) Set parameters<br />
<div style="background:#ddd;padding-left:1em">shared_buffers = 4GB<br />
work_mem = 32MB <br />
effective_cache_size = 8GB</div>
<br />
<b>shared_buffers</b>: 1/4 of total memory is a reasonable starting value<br />
<b>effective_cache_size</b>: 1/2 of total memory would be a normal setting<br />
<br />
<br />
<div style="text-align:center">II. Web Server</div>
1. Install apache2<br />
<div style="background:#ddd;padding-left:1em">zypper install apache2 apache2-mod_evasive</div>
<br />
2. Add commonly-used modules<br />
Add modules:<br />
<div style="background:#ddd;padding-left:1em">a2enmod php7</div>
<div style="background:#ddd;padding-left:1em">a2enmod rewrite</div>
<div style="background:#ddd;padding-left:1em">a2enmod headers</div>
List apache loaded modules:<br />
<div style="background:#ddd;padding-left:1em">apachectl -M</div>
<br />
3. Enable auto-start on boot<br />
<div style="background:#ddd;padding-left:1em">chkconfig -a apache2</div>
<br />
4. Edit <b>default-server.conf</b> (/etc/apache2)<br />
(1) Edit DocumentRoot to your own default websidte directory (e.g. DocumentRoot "/home/yoursite").<br />
(2) Edit the &lt;Directory> right below DocumentRoot.<br />
(3) Add/Append the following directives:<br />
<div style="background:#ddd;padding-left:1em">ServerName website.com</div>
<div style="background:#ddd;padding-left:1em">ExtendedStatus On</div>
<div style="background:#ddd;padding-left:1em">TraceEnable Off</div>
<div style="background:#ddd;padding-left:1em">AddType image/x-icon .ico</div>
<br />
5. Modify server-tuning.conf (/etc/apache2) <br />
(1) Raise <i>StartServers</i> if necessary<br />
(2) Raise <i>MaxSpareServers</i> if necessary<br />
(3) Raise <i>ServerLimit</i> if necessary<br />
(4) Raise <i>MaxClients</i> if necessary<br />
<br />
<div style="text-align:center">III. Hypertext Preprocessor</div>
1. Install php7<br />
<div style="background:#ddd;padding-left:1em">zypper install php7 php7-pgsql</div>
<br />
2. Install commonly-used modules<br />
<div style="background:#ddd;padding-left:1em">zypper install php7-curl php7-fileinfo php7-gd php7-mbstring php7-openssl php7-zip php7-zlib</div>
<br />
<div style="background:#ddd;padding-left:1em"></div>
<br />
MariaDB<br />
1. Install mariadb<br />
<div style="background:#ddd;padding-left:1em">zypper install mariadb mariadb-tools</div>
<br />
2. Security setting<br />
<div style="background:#ddd;padding-left:1em">mysql_secure_installation</div>
(all "yes" is preferred)<br />
<br />
3. Enable auto-start on boot<br />
<div style="background:#ddd;padding-left:1em">chkconfig -a mysql</div>
<br />
References:<br />
<a href=http://mepopedia.com/forum/read.php?135,76348>Install a LAPP server: openSUSE 42 / Apahce 2.4/PostgreSQL 9.4/ PHP 5.6</a><br />
<a href=https://www.howtoforge.com/tutorial/how-to-install-postgresql-and-phppgadmin-on-opensuse-leap-42.1/>How to Install PostgreSQL and phpPgAdmin on OpenSUSE Leap 42.1</a><br />
<a href=http://httpd.apache.org/docs/2.4/mod/prefork.html>Apache MPM prefork</a><br />
<a href=http://httpd.apache.org/docs/2.4/mod/mpm_common.html>Apache MPM Common Directives</a>]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Sat, 02 Feb 2019 21:12:36 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,76883,76883#msg-76883</guid>
            <title>Make SSH Login without Password and Troubleshot it (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,76883,76883#msg-76883</link>
            <description><![CDATA[1. Generate Key Pair<br />
<b>Shell> ssh-keygen</b><br />
Do not enter the passphrase and your will see:<pre>Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.</pre>
2. Copy the Key to the Remote Client<br />
<b>Shell> ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-domain.com</b><br />
<br />
Basically, it's done.<br />
<br />
3. Troubleshoting<br />
(1) Make sure the Home Directory of the remote client is NOT writable by other users.<br />
(2) Check /var/log/messages for error information.]]></description>
            <dc:creator>mepoadm</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Fri, 03 Jul 2015 23:40:24 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,76348,76348#msg-76348</guid>
            <title>Install a LAPP server: openSUSE 42 / Apahce 2.4/PostgreSQL 9.4/ PHP 5.6 (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,76348,76348#msg-76348</link>
            <description><![CDATA[<div class='message-body' style='float:right; margin: 0; border: none; padding: 0 0 1em 1em; max-width: 216px'><div class='notice' style='padding: 10px 14px'><ol style='font-size: 0.8em; margin:0; padding: 0; list-style-type: none;'><li><a style='text-decoration:none' href=#Network+Settings>1. Network Settings</a><li><a style='text-decoration:none' href=#Disk+Partition>2. Disk Partition</a><li><a style='text-decoration:none' href=#Install+PostgreSQL+9.4>3. Install PostgreSQL 9.4</a><li><a style='text-decoration:none' href=#Services+Autostart+at+Boot>4. Services Autostart at Boot</a><li><a style='text-decoration:none' href=#Security>5. Security</a><li><a style='text-decoration:none' href=#Apache>6. Apache</a><li><a style='text-decoration:none' href=#PHP>7. PHP</a><li><a style='text-decoration:none' href=#Firewall>8. Firewall</a></ol></div></div>The parts of this install article: (1) Disk partiton; (2) Install PostgreSQL 9.4; (3) Auto Start of Services; (4) Security.<br />
<h2 id='Network+Settings'>1. Network Settings</h2><br />
Address:<br />
IP Address: OOO.OOO.OOO.OOO<br />
Subnet Mask: 255.255.255.0<br />
Hostname: www (some thing like that)<br />
<br />
<h2 id='Disk+Partition'>2. Disk Partition</h2><pre>/boot   2GB
/swap   12GB  swap (similar to size of RAM)
/       100GB ext4
/home   1.7TB ext4
/var    120GB ext4 (preferably SSD)</pre>
<h2 id='Install+PostgreSQL+9.4'>3. Install PostgreSQL 9.4</h2>Add http://download.opensuse.org/repositories/server:/database:/postgresql/openSUSE_13.2/ to repositories.<br />
Install through YaST:<pre>  postgresql94
  postgresql94-server</pre>
<br />
<h2 id='Services+Autostart+at+Boot'>4. Services Autostart at Boot</h2>systemctl enable apache2.service<br />
systemctl enable sshd.service<br />
chkconfig --add postgresql<br />
--<br />
Use <b>chkconfig --list</b> to list all available services run-level status<br />
<br />
<h2 id='Security'>5. Security</h2><br />
(1) Disable root ssh access<br />
Edit<br />
<b>/etc/ssh/sshd_config</b><br />
Set and unmark<br />
<b>PermitRootLogin no</b><br />
Restart<br />
<b>systemctl restart sshd.service</b><br />
<br />
(2) Restrict swith user (su)<br />
Add to the gorup of wheel<br />
<b>usermod -a -G wheel username</b><br />
Edit<br />
<b>/etc/pam.d/su</b><br />
Add this line below "auth        sufficient  pam_rootok.so"<br />
<b>auth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;required&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pam_wheel.so use_uid</b><br />
<br />
<h2 id='Apache'>6. Apache</h2><br />
1. Configuration:<br />
/etc/sysconfig/apache (Include Modules)<br />
/etc/apache2/ (configuration)<br />
<br />
2. Edit default conf (/etc/apache2/default-server.conf)<br />
TraceEnable off (Disable HTTP TRACE method)<br />
<br />
3. Service setting<br />
vi /usr/lib/systemd/system/apache2.service<br />
PrivateTmp=false<br />
<br />
<h2 id='PHP'>7. PHP</h2><br />
Edit php.ini (/etc/php5/cli/php.ini) <br />
<br />
short_open_tag = On <br />
output_handler = ob_gzhandler <br />
upload_max_filesize = 8M <br />
memory_limit = 512M <br />
date.timezone = 'Asian/Taipei'<br />
session.cookie_httponly = 1<br />
session.cookie_secure = 1<br />
<br />
<h2 id='Firewall'>8. Firewall</h2><br />
Enable HTTP Server<br />
Custom Rules for SSH]]></description>
            <dc:creator>mepoadm</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Thu, 04 Jun 2015 22:32:15 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,32710,32710#msg-32710</guid>
            <title>Backup and Transfer a LAMP(LAPP) System: Linux/Apache2/PostgreSQL/PHP (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,32710,32710#msg-32710</link>
            <description><![CDATA[<div class='message-body' style='float:right; margin: 0; border: none; padding: 0 0 1em 1em; max-width: 216px'><div class='notice' style='padding: 10px 14px'><ol style='font-size: 0.8em; margin:0; padding: 0; list-style-type: none;'><li><a style='text-decoration:none' href=#Network+Settings>1. Network Settings</a><li><a style='text-decoration:none' href=#Disk+Partition>2. Disk Partition</a><li><a style='text-decoration:none' href=#Install+PostgreSQL+9.4>3. Install PostgreSQL 9.4</a><li><a style='text-decoration:none' href=#Services+Autostart+at+Boot>4. Services Autostart at Boot</a><li><a style='text-decoration:none' href=#Security>5. Security</a><li><a style='text-decoration:none' href=#Apache>6. Apache</a><li><a style='text-decoration:none' href=#PHP>7. PHP</a><li><a style='text-decoration:none' href=#Firewall>8. Firewall</a><li><a style='text-decoration:none' href=#User+accounts>9. User accounts</a><li><a style='text-decoration:none' href=#User+Files+.28.2Fhome.29>10. User Files (/home)</a><li><a style='text-decoration:none' href=#Database+.28PostgreSQL.29>11. Database (PostgreSQL)</a><li><a style='text-decoration:none' href=#Web+Server+.28Apache.29>12. Web Server (Apache)</a><li><a style='text-decoration:none' href=#PHP>13. PHP</a><li><a style='text-decoration:none' href=#crontab>14. crontab</a><li><a style='text-decoration:none' href=#References>15. References</a></ol></div></div>Assume we have an installed Linux system on hand. We have six parts to transfer: (1) User accounts; (2) User files (/home); (3) Database; (4) Apache; (5) PHP; and (6) crontab.<br />
<h2 id='User+accounts'>9. User accounts</h2><br />
Copy and transfer the following user-related files and directories:<br />
<br />
<xmp>．/etc/passwd - File - contains various pieces of information for each user account
．/etc/shadow - File - contains the encrypted password (and aging) information for user's accounts.
．/etc/group - File - defines the groups to which users belong
．/etc/gshadow - group shadow file (contains the encrypted password for group)
．/var/spool/mail - Generally user emails are stored here.
．/home - All Users data is stored here.</xmp>
<br />
Do remember to "preserve (-p)" file info (permisions, owner, etc) in the transfer. <b>Do not copy-and-paste the passwd/shadow files directly.</b> It's recommended to only attach the human-added users into the new system user account files.<br />
<br />
<h2 id='User+Files+.28.2Fhome.29'>10. User Files (/home)</h2><br />
(1) rsync<br />
Transfer a certain user folder:<pre>rsync -av /home/user/ account@domain:/home/user/</pre>
Or<br />
<br />
(2) Tar<br />
cd /<br />
tar -cvpf /archive_folter/home-YYYYMMDD.tar home --exclude=home/exclude_foler<br />
<br />
Untar:<br />
cd /destination_folder<br />
tar -xvpf home-YYYYMMDD.tar<br />
<br />
<h2 id='Database+.28PostgreSQL.29'>11. Database (PostgreSQL)</h2><br />
Backup (export):<br />
Shell> pg_dumpall -U postgres | bzip2 > cluster_YYYYMMDD.bz2<br />
<br />
Transfer (scp) and unzip (bzip2 -d) the database cluster file.<br />
<br />
Restore (import):<br />
Shell> psql -f cluster_YYYYMMDD -U postgres postgres<br />
<br />
Config:<br />
shared_buffers = 2GB (1/4 of the memory is a reasonable starting value)<br />
work_mem = 25MB<br />
effective_cache_size = 4GB ( 1/2 of total memory would be a normal setting)<br />
<br />
Password File:<br />
~/.pgpass<br />
<br />
<h2 id='Web+Server+.28Apache.29'>12. Web Server (Apache)</h2><br />
(1) Configuration:<br />
/etc/apache2/*.conf<br />
/etc/apache2/vhost.conf/*.conf<br />
<br />
(2) Modules:<br />
vi /etc/sysconfig/apache<br />
Add APACHE_MODUELS: php5, headers, rewrite<br />
Set APACHE_SERVER_FLAGS="SSL"<br />
<br />
(3) Remove manual directory:<br />
mv /etc/apache2/conf.d/manual.conf /etc/apache2/conf.d/manual.conf.ori<br />
<br />
<h2 id='PHP'>13. PHP</h2><br />
1. Install the modules:<br />
<div style="background:#ddd;padding-left:1em">zypper install php7-curl php7-gb php7-mbstring php-openssl php7-pgsql</div>
<br />
2. Edit php.ini (/etc/php5/cli/php.ini)<br />
<div style="background:#ddd;padding-left:1em">short_open_tag = On<br />
output_handler = ob_gzhandler<br />
memory_limit = 512M<br />
upload_max_filesize = 8M<br />
date.timezone = 'Asia/Taipei'<br />
session.cookie_secure = 1<br />
session.cookie_httponly = 1</div>
<br />
<h2 id='crontab'>14. crontab</h2><br />
(1) Edit crontab<br />
<div style="background:#ddd;padding-left:1em">crontab -e</div>
(2) Add jobs<br />
<div style="background:#ddd;padding-left:1em">0 0 * * * pg_dump -U postgres database > database_$(date +\%Y\%m\%d\%H).sql</div>
<br />
<h2 id='References'>15. References</h2><br />
User Accounts:<br />
http://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/<br />
http://serverfault.com/questions/19274/how-to-transfer-user-accounts-to-a-new-linux-machine<br />
<br />
Disk Partitioning:<br />
https://help.ubuntu.com/community/DiskSpace<br />
<br />
Database:<br />
https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server]]></description>
            <dc:creator>mepoadm</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Fri, 09 Aug 2013 23:30:43 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,24332,24332#msg-24332</guid>
            <title>Some notes about linux administration (SUSE) (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,24332,24332#msg-24332</link>
            <description><![CDATA[Two ways to create a symbolic link (from link-to-file1 to file1):<br />
1. ln -s file1 link-to-file1<br />
2. cp -s file1 link-to-file1<br />
<br />
The configuration files of syslog-ng:<br />
1. /etc/sysconfig/syslog<br />
2. /etc/syslog-ng/syslog-ng.conf<br />
3. /etc/syslog-ng/syslog-ng.conf.in]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Tue, 07 Aug 2012 02:56:53 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,5748,5748#msg-5748</guid>
            <title>如何禁止從遠端(SSH)以ROOT登入：修改 /etc/ssh/sshd_config (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,5748,5748#msg-5748</link>
            <description><![CDATA[1. 找到檔案 /etc/ssh/sshd_config<br />
<br />
2. 修改其中的<br />
<br />
#PermitRootLogin yes<br />
<br />
改為<br />
<br />
PermitRootLogin no (注意開頭不要有井字號 #)<br />
<br />
3. 重新啟動 SSH<br />
<br />
/etc/rc.d/sshd restart<br />
<br />
或者<br />
<br />
rcsshd restart<br />
<br />
Reference:<br />
1. How do I disable remote SSH login as root from a server?<br />
https://askubuntu.com/questions/27559/how-do-i-disable-remote-ssh-login-as-root-from-a-server<br />
2. How do I restart sshd on my Unix system<br />
https://www.starnet.com/xwin32kb/how-do-i-restart-sshd-on-my-unix-system/]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Sun, 04 Apr 2010 03:48:50 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,4168,4168#msg-4168</guid>
            <title>[HOW TO] Auto Reconnect in ADSL/DSL with Script (Debian/SuSE) (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,4168,4168#msg-4168</link>
            <description><![CDATA[1. The Script: (Just copy it and vi /usr/bin/repppoe)<br />
<br />
<b>Script for Debian:</b><br />
<br />
#!/bin/bash<br />
if !ping -c 3 www.google.com > /dev/null 2>&1<br />
then<br />
#/usr/bin/poff<br />
#/usr/bin/pon dsl-provider<br />
<b>/usr/bin/pon ppp0</b><br />
fi<br />
<br />
The command for starting network in Debian is <b>/usr/bin/pon</b> and <b>/sbin/ifup</b> for SUSE. The device name for DSL may be <b>dsl0</b> in SUSE.<br />
<br />
<b>So, the script for SUSE is like:</b><br />
<br />
#!/bin/bash<br />
if !ping -c 3 www.google.com > /dev/null 2>&1<br />
then<br />
#/usr/bin/poff<br />
#/usr/bin/pon dsl-provider<br />
<b>/sbin/ifup dsl0</b><br />
fi<br />
<br />
2. chmod +x /usr/bin/repppoe<br />
<br />
3. crontab (as root)<br />
<br />
Shell> crontab -e<br />
*/5 * * * * /usr/bin/repppoe<br />
<br />
It means to check the script every 5 minutes. You may set other numbers of minutes for it.<br />
<br />
Reference (in Chinese):<br />
1. <a href=http://plog.longwin.com.tw/programming/2007/08/24/adsl_repppoe_script_2007>Debian Linux: Auto Reconnecting Script  in ADSL PPPoE</a> (2007)<br />
2. <a href=http://linux.chinaunix.net/bbs/archiver/?tid-895502.html>Script to Auto Detect the down link of ADSL</a> (2007)]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Mon, 15 Feb 2010 03:07:20 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,2515,2515#msg-2515</guid>
            <title>[HOW TO] Find the IP Address of Your Linux Server: ifconfig (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,2515,2515#msg-2515</link>
            <description><![CDATA[Basically it's very easy to lookup the IP address of your Linux server even if you are not very familiar with the black-and-white command line. Simply type <b>ifconfig</b> in the command line prompt:<br />
<br />
Shell> ifconfig<br />
<br />
and you will see (e.g. in our current settings in www.mepopedia.com):<br />
<br />
<pre>
dsl0      Link encap: Point-to-Point Protocol  
          [size=large]<b>inet addr:114.32.138.191</b>[/size]  P-t-P:114.44.96.254  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:138722 errors:0 dropped:0 overruns:0 frame:0
          TX packets:172306 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:14210409 (13.5 Mb)  TX bytes:172568336 (164.5 Mb)

eth0      Link encap:Ethernet  HWaddr 00:50:BF:21:5A:7B  
          inet6 addr: fe80::250:bfff:fe21:5a7b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:140766 errors:1 dropped:8192 overruns:1 frame:0
          TX packets:187004 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17385017 (16.5 Mb)  TX bytes:181005262 (172.6 Mb)
          Interrupt:16 Base address:0x8c00 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2269354 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2269354 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:861014845 (821.1 Mb)  TX bytes:861014845 (821.1 Mb)</pre>
<br />
The IP address is in the part of <b>inet addr</b>.<br />
<br />
Another interesting way to "check" IP is to simply go to http://www.ipmango.com/, and you will see what and "where" your IP is.<br />
<br />
Cheers!<br />
<br />
<br />
Reference to ifconfig: http://linux.die.net/man/8/ifconfig (<a href=http://en.wikipedia.org/wiki/Ifconfig>wiki</a>)<br />
Chinese reference of ifconfig: http://linux.vbird.org/linux_server/0140networkcommand.php#ifconfig]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Fri, 30 Oct 2009 14:44:50 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,669,669#msg-669</guid>
            <title>dmidecode：在 Linux 中查詢系統硬體資訊的指令(利用BIOS) (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,669,669#msg-669</link>
            <description><![CDATA[簡要說明：<br /><preview>
Shell> dmidecode -t processor  --> CPU 詳細資訊<br />
Shell> dmidecode -t memory     --> Memoery 資訊<br />
Shell> dmidecode -t/--type    --> 列出所有 type 選項<br /></preview>
<br />
<br />
實例介紹：<br />
我們在很多情況都需要知道 Linux 安裝在什麼樣的伺服器的硬體規格底下，但由於很多時候系統不是自己架的或不是自已經手購買，對詳細的資訊一下也很難查到。<b>dmidecode</b>這個指令幫我們轉譯硬體的BIOS資訊，讓我們能很方便地了解系統詳細的硬體資訊。<br />
<br />
一般而言，我們用下列指令就可以得到系統硬體資訊：<br />
<br /><preview>
Shell> dmidecode --type system/processor/memory/...<br /></preview>
<br />
例如<br />
<code><br />
Shell> dmidecode --type system<br />
<br />
的結果會顯示：<br />
<br />
# dmidecode 2.9<br />
SMBIOS 2.3 present.<br />
<br />
Handle 0x0100, DMI type 1, 25 bytes<br />
System Information<br />
　　<b>Manufacturer: HP<br />
　　Product Name: ProLiant DL380 G4</b><br />
　　Version: Not Specified<br />
         　　Serial Number: SGH526X028      <br />
         　　UUID: 33393539-3736-5347-4835-323658303238<br />
         　　Wake-up Type: Power Switch<br />
<br />
<br />
我們就可以不用到Server旁邊，穿過重重障礙就可以知道 Sever是 HP ProLiant DL 380 G4。<br />
<br />
<br />
而若是輸入<br />
Shell> dmidecode --type processor<br />
<br />
就可以看到以下（節錄）資訊：<br />
<br />
Processor Information<br />
&nbsp;&nbsp;        Socket Designation: Proc 2<br />
&nbsp;&nbsp;        Type: Central Processor<br />
&nbsp;&nbsp;        <b>Family: Xeon</b><br />
&nbsp;&nbsp;        <b>Manufacturer: Intel</b><br />
&nbsp;&nbsp;        ID: 43 0F 00 00 FF FB EB BF<br />
&nbsp;&nbsp;        Signature: Type 0, Family 15, Model 4, Stepping 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;　Version: Not Specified<br />
&nbsp;&nbsp;        Voltage: 1.4 V<br />
&nbsp;&nbsp;        External Clock: 800 MHz<br />
&nbsp;&nbsp;        Max Speed: 4800 MHz<br />
&nbsp;&nbsp;        <b>Current Speed: 3200 MHz</b><br />
&nbsp;&nbsp;        Status: Populated, Idle<br />
</code><br />
<br />
其中我們可以發現 CPU 是 Intel Xeon at 3.5Ghz<br />
<br />
<br />
深入資訊:<br />
<a href=http://www.cyberciti.biz/tips/querying-dumping-bios-from-linux-command-prompt.html>Get Information About Your BIOS / Server Hardware From a Shell Without Opening Chassis ( BIOS Decoder )</a>, cyberciti.biz, July 24, 2008.]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Sat, 30 May 2009 20:40:34 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,420,420#msg-420</guid>
            <title>Linux 常用指令：cat, cd, chmod, chown, cp, cut, date, find, less, ln, locate, ls &amp; more (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,420,420#msg-420</link>
            <description><![CDATA[<div class='message-body' style='float:right; margin: 0; border: none; padding: 0 0 1em 1em; max-width: 216px'><div class='notice' style='padding: 10px 14px'><ol style='font-size: 0.8em; margin:0; padding: 0; list-style-type: none;'><li><a style='text-decoration:none' href=#Network+Settings>1. Network Settings</a><li><a style='text-decoration:none' href=#Disk+Partition>2. Disk Partition</a><li><a style='text-decoration:none' href=#Install+PostgreSQL+9.4>3. Install PostgreSQL 9.4</a><li><a style='text-decoration:none' href=#Services+Autostart+at+Boot>4. Services Autostart at Boot</a><li><a style='text-decoration:none' href=#Security>5. Security</a><li><a style='text-decoration:none' href=#Apache>6. Apache</a><li><a style='text-decoration:none' href=#PHP>7. PHP</a><li><a style='text-decoration:none' href=#Firewall>8. Firewall</a><li><a style='text-decoration:none' href=#User+accounts>9. User accounts</a><li><a style='text-decoration:none' href=#User+Files+.28.2Fhome.29>10. User Files (/home)</a><li><a style='text-decoration:none' href=#Database+.28PostgreSQL.29>11. Database (PostgreSQL)</a><li><a style='text-decoration:none' href=#Web+Server+.28Apache.29>12. Web Server (Apache)</a><li><a style='text-decoration:none' href=#PHP>13. PHP</a><li><a style='text-decoration:none' href=#crontab>14. crontab</a><li><a style='text-decoration:none' href=#References>15. References</a><li><a style='text-decoration:none' href=#cat.EF.BC.9A.E8.BC.B8.E5.87.BA.E6.AA.94.E6.A1.88.E5.85.A7.E5.AE.B9.E8.87.B3.E8.9E.A2.E5.B9.95.E6.88.96.E6.AA.94.E6.A1.88>16. cat：輸出檔案內容至螢幕或檔案</a><li><a style='text-decoration:none' href=#cd.EF.BC.9A.E6.9B.B4.E6.8F.9B.E6.89.80.E5.9C.A8.E7.9B.AE.E9.8C.84.2FChange+Directory>17. cd：更換所在目錄/Change Directory</a><li><a style='text-decoration:none' href=#chmod.EF.BC.9A.E8.A8.AD.E5.AE.9A.E6.AA.94.E6.A1.88.E5.8F.8A.E7.9B.AE.E9.8C.84.E8.AE.80.E5.8F.96.E5.B1.AC.E6.80.A7.E5.8F.8A.E7.8B.80.E6.85.8B.2FChange+Mode+of+File+or+Direcotry>18. chmod：設定檔案及目錄讀取屬性及狀態/Change Mode of File or Direcotry</a><li><a style='text-decoration:none' href=#chown.EF.BC.9A+.E8.A8.AD.E5.AE.9A.E6.AA.94.E6.A1.88.E6.88.96.E7.9B.AE.E9.8C.84.E4.B9.8B.E3.80.8C.E6.93.81.E6.9C.89.E8.80.85.E3.80.8D+.2F+Change+Owner>19. chown： 設定檔案或目錄之「擁有者」 / Change Owner</a><li><a style='text-decoration:none' href=#date.EF.BC.9A.E8.A8.AD.E5.AE.9A.E7.B3.BB.E7.B5.B1.E6.99.82.E9.96.93>20. date：設定系統時間</a><li><a style='text-decoration:none' href=#ln.EF.BC.9A.E5.BB.BA.E7.AB.8B.E5.AF.A6.E9.AB.94.E9.80.A3.E7.B5.90.E8.88.87.E7.AC.A6.E8.99.9F.E9.80.A3.E7.B5.90>21. ln：建立實體連結與符號連結</a></ol></div></div>文章來源：<a href=http://forum.heyzu.com.tw/main.php?Y=TE010400&dizcus=148.LRxQtjna>Linux常用指令</a> (黑族論壇 Linux 基礎指令討論版,  2009/01/21)<style>#phorum h2{font-weight: bold;} #phorum div.message-body br{clear:none;} #phorum h2{text-align:center;}</style><br />
<br />
<br />
<h2 id='cat.EF.BC.9A.E8.BC.B8.E5.87.BA.E6.AA.94.E6.A1.88.E5.85.A7.E5.AE.B9.E8.87.B3.E8.9E.A2.E5.B9.95.E6.88.96.E6.AA.94.E6.A1.88'>16. cat：輸出檔案內容至螢幕或檔案</h2><br />
<br />
語法：<code>cat filename [-n] [-b] [-u] [-s] [-v]</code<br />
<br />
說明：將名為 filename 的檔案連接(con<b>cat</b>enate)或處理後傳到螢幕或另一個檔案<br />
<br />
參數﹕<br />
-n 或 --number﹕由 1 開始對所有輸出的行數編號<br />
-b 或 --number-nonblank﹕和 -n 相似，只不過對於空白行不編號<br />
-s 或 --squeeze-blank ﹕遇到有連續兩行以上的空白行，就代換為一行的空白行<br />
-v 或 --show-nonprinting<br />
<br />
範例﹕<br />
<code>cat -n textfile1 textfile2 把 textfile1 的檔案內容加上行號後輸入 textfile2 這個檔案裡</code><br />
<code>cat -b textfile1 textfile2 textfile3 把 textfile1 和 textfile2 的檔案內容加上行號（空白行不加）之後將內容附加到 textfile3</code><br />
<br />
<br />
<center><h2 id='cd.EF.BC.9A.E6.9B.B4.E6.8F.9B.E6.89.80.E5.9C.A8.E7.9B.AE.E9.8C.84.2FChange+Directory'>17. cd：更換所在目錄/Change Directory</h2></center><br />
<br />
語法：cd [dirName]<br />
<br />
說明 : 變換工作目錄至 dirName。其中 dirName 表示法可為絕對路徑或相對路徑。若目錄名稱省略，則變換至使用者的 home directory (也就是剛 login 時所在的目錄)。<br />
<br />
另外，~ 也表示為 home directory 的意思，. 則是表示目前所在的目錄，.. 則表示目前目錄位置的上一層目錄。<br />
<br />
範例 : 跳到 /usr/bin/ :<br />
cd /usr/bin<br />
<br />
跳到自己的 home directory :<br />
cd ~ (注意：cd 和 ~ 中間有「空白」) <br />
<br />
跳到目前目錄的上上兩層 :<br />
cd ../..<br />
<br />
<br />
<h2 id='chmod.EF.BC.9A.E8.A8.AD.E5.AE.9A.E6.AA.94.E6.A1.88.E5.8F.8A.E7.9B.AE.E9.8C.84.E8.AE.80.E5.8F.96.E5.B1.AC.E6.80.A7.E5.8F.8A.E7.8B.80.E6.85.8B.2FChange+Mode+of+File+or+Direcotry'>18. chmod：設定檔案及目錄讀取屬性及狀態/Change Mode of File or Direcotry</h2><br />
<br />
語法 : chmod [-cfvR] [--help] [--version] mode file...<br />
<br />
說明 : Linux/Unix 的檔案存取權限分為三級 : 檔案擁有者、群組、其他。利用 chmod 可以藉以控製檔案如何被他人所存取。<br />
<br />
參數:<br />
mode : 權限設定字串，格式如下 : [ugoa...][+-=][rwxX]...][,...]，其中u 表示該檔案的擁有者，g 表示與該檔案的擁有者屬於同一個群體(group)者，o 表示其他以外的人，a 表示這三者皆是。<br />
<br />
+ 表示增加權限、- 表示取消權限、= 表示唯一設定權限。<br />
r 表示可讀取，w 表示可寫入，x 表示可執行，X 表示只有當該檔案是個子目錄或者該檔案已經被設定過為可執行。<br />
-c : 若該檔案權限確實已經更改，才顯示其更改動作<br />
-f : 若該檔案權限無法被更改也不要顯示錯誤訊息<br />
-v : 顯示權限變更的詳細資料<br />
-R : 對目前目錄下的所有檔案與子目錄進行相同的權限變更(即以遞回的方式逐個變更)<br />
--help : 顯示輔助說明<br />
--version : 顯示版本<br />
<br />
範例 :將檔案 file1.txt 設為所有人皆可讀取 :<br />
chmod ugo+r file1.txt<br />
<br />
將檔案 file1.txt 設為所有人皆可讀取 :<br />
chmod a+r file1.txt<br />
<br />
將檔案 file1.txt 與 file2.txt 設為該檔案擁有者，與其所屬同一個群體者可寫入，但其他以外的人則不可寫入 :<br />
chmod ug+w,o-w file1.txt file2.txt<br />
<br />
將 ex1.py 設定為只有該檔案擁有者可以執行 :<br />
chmod u+x ex1.py<br />
<br />
將目前目錄下的所有檔案與子目錄皆設為任何人可讀取 :<br />
chmod -R a+r *<br />
<br />
<b>此外 chmod 也可以用數字來表示權限</b><br />
例如: chmod 777 file<br />
<br />
語法為﹕<code>chmod abc file</code><br />
<br />
其中a,b,c各為一個數字，分別表示User、Group、及Other的權限。<br />
<br />
r=4，w=2，x=1<br />
若要rwx屬性則4+2+1=7；<br />
若要rw-屬性則4+2=6；<br />
若要r-x屬性則4+1=7。<br />
<br />
範例﹕<br />
chmod a=rwx file<br />
<br />
和<br />
chmod 777 file<br />
<br />
效果相同<br />
chmod ug=rwx,o=x file<br />
<br />
和<br />
chmod 771 file<br />
<br />
效果相同<br />
<br />
<br />
若用chmod 4755 filename可使此程式具有root的權限<br />
<br />
<b>進階用法：只對「檔案」或只對「目錄」chmod (recursively)</b><br />
find -type d -print0 |xargs -0 chmod 755<br />
find -type f -print0 |xargs -0 chmod 644<br />
<br />
chgrp 或 chown 的用法亦同。<br />
<br />
<br />
<h2 id='chown.EF.BC.9A+.E8.A8.AD.E5.AE.9A.E6.AA.94.E6.A1.88.E6.88.96.E7.9B.AE.E9.8C.84.E4.B9.8B.E3.80.8C.E6.93.81.E6.9C.89.E8.80.85.E3.80.8D+.2F+Change+Owner'>19. chown： 設定檔案或目錄之「擁有者」 / Change Owner</h2><br />
<br />
語法 : chown [-cfhvR] [--help] [--version] user[:group] file...<br />
<br />
說明 :<br />
Linux/Unix 是多人多工作業系統，所有的檔案皆有擁有者。利用 chown 可以將檔案的擁有者加以改變。一般來說，這個指令只有是由系統管理者(root)所使用，一般使用者沒有權限可以改變別人的檔案擁有者，也沒有權限可以自己的檔案擁有者改設為別人。只有系統管理者(root)才有這樣的權限。<br />
<br />
參數 :<br />
user : 新的檔案擁有者的使用者 ID<br />
group : 新的檔案擁有者的使用者群體(group)<br />
<br />
-c : 若該檔案擁有者確實已經更改，才顯示其更改動作-f : 若該檔案擁有者無法被更改也不要顯示錯誤訊息<br />
-h : 只對於連結 (link) 進行變更，而非該 link 真正指向的檔案<br />
-v : 顯示擁有者變更的詳細資料<br />
-R : 對目前目錄下的所有檔案與子目錄進行相同的擁有者變更(即以遞回的方式逐個變更)<br />
--help : 顯示輔助說明<br />
--version : 顯示版本<br />
<br />
範例 :<br />
將檔案 file1.txt 的擁有者設為 users 群體的使用者 jessie :<br />
chown jessie:users file1.txt<br />
<br />
將目前目錄下的所有檔案與子目錄的擁有者皆設為 users 群體的使用者 lamport :<br />
chmod -R lamport:users *<br />
<br />
<br />
名稱﹕cp<br />
使用權限﹕所有使用者<br />
<br />
使用方式﹕<br />
<br />
cp [options] source dest<br />
cp [options] source... directory<br />
<br />
說明﹕將一個檔案拷貝至另一檔案，或將數個檔案拷貝至另一目錄。<br />
<br />
參數 :<br />
-a : 盡可能將檔案狀態、權限等資料都照原狀予以複製。<br />
-r : 若 source 中含有目錄名，則將目錄下之檔案亦皆依序拷貝至目的地。<br />
-f : 若目的地已經有相同檔名的檔案存在，則在複製前先予以刪除再行複製。<br />
<br />
範例 :<br />
將檔案 aaa 複製(已存在)，並命名為 bbb :<br />
cp aaa bbb<br />
<br />
將所有的C語言程式拷貝至 Finished 子目錄中 :<br />
cp *.c Finished<br />
<br />
<br />
<br />
名稱﹕cut<br />
<br />
使用權限﹕所有使用者<br />
<br />
用法﹕cut -cnum1-num2 filename<br />
<br />
說明﹕顯示每行從開頭算起 num1 到 num2 的文字。<br />
<br />
範例﹕<br />
<br />
shell cat example<br />
test2<br />
this is test1<br />
shell cut -c0-6 example ## print 開頭算起前 6 個字元<br />
test2<br />
this i<br />
<br />
<hr/><br />
<br />
<h2 id='date.EF.BC.9A.E8.A8.AD.E5.AE.9A.E7.B3.BB.E7.B5.B1.E6.99.82.E9.96.93'>20. date：設定系統時間</h2><br />
<br />
語法：<code>date MMDDhhmmYYYY</code><br />
<br />
說明：顯示及修改系統時間<br />
<br />
參數：<br />
MM：月份<br />
DD：日期<br />
hh：小時<br />
mm：分鐘<br />
YYYY：西元年<br />
<br />
範例：<br />
<pre>
顯示現在時間：
# date
Thu Jul 28 15:00:00 CST 2012

修改系統時間
# date 072816002012
Thu Jul 28 16:00:00 CST 2011</pre>
<br />
另外，若要顯示或設定 BIOS 的硬體系統時間，則是使用「hwclock [-rw]」。<br />
<br />
顯示BIOS系統時間：#hwclock -r<br />
將當下的軟體時間寫入BIOS：#hwclock -w<br />
<br />
<br />
<hr/><br />
名稱 : find<br />
用法 : find<br />
使用說明 :<br />
<br />
將檔案系統內符合 expression 的檔案列出來。你可以指要檔案的名稱、類別、時間、大小、權限等不同資訊的組合，只有完全相符的才會被列出來。<br />
<br />
find 根據下列規則判斷 path 和 expression，在命令列上第一個 - ( ) , ! 之前的部份為 path，之後的是 expression。如果 path 是空字串則使用目前路徑，如果 expression 是空字串則使用 -print 為預設 expression。<br />
<br />
expression 中可使用的選項有二三十個之多，在此只介紹最常用的部份。<br />
<br />
-mount, -xdev : 只檢查和指定目錄在同一個檔案系統下的檔案，避免列出其它檔案系統中的檔案<br />
-amin n : 在過去 n 分鐘內被讀取過<br />
-anewer file : 比檔案 file 更晚被讀取過的檔案<br />
-atime n : 在過去 n 天過讀取過的檔案<br />
-cmin n : 在過去 n 分鐘內被修改過<br />
-cnewer file :比檔案 file 更新的檔案<br />
-ctime n : 在過去 n 天過修改過的檔案<br />
-empty : 空的檔案-gid n or -group name : gid 是 n 或是 group 名稱是 name<br />
-ipath p, -path p : 路徑名稱符合 p 的檔案，ipath 會忽略大小寫<br />
-name name, -iname name : 檔案名稱符合 name 的檔案。iname 會忽略大小寫<br />
-size n : 檔案大小 是 n 單位，b 代表 512 位元組的區塊，c 表示字元數，k 表示 kilo bytes，w 是二個位元組。-type c : 檔案類型是 c 的檔案。<br />
d: 目錄<br />
c: 字型裝置檔案<br />
b: 區塊裝置檔案<br />
p: 具名貯列<br />
f: 一般檔案<br />
l: 符號連結<br />
s: socket<br />
-pid n : process id 是 n 的檔案<br />
<br />
你可以使用 ( ) 將運算式分隔，並使用下列運算。<br />
exp1 -and exp2<br />
! expr<br />
-not expr<br />
exp1 -or exp2<br />
exp1, exp2<br />
範例:<br />
將目前目錄及其子目錄下所有延伸檔名是 c 的檔案列出來。<br />
# find . -name *.c<br />
<br />
<br />
將目前目錄其其下子目錄中所有一般檔案列出<br />
# find . -ftype f<br />
<br />
<br />
將目前目錄及其子目錄下所有最近 20 分鐘內更新過的檔案列出<br />
# find . -ctime -20<br />
<br />
<br />
<br />
名稱﹕less<br />
<br />
使用權限﹕所有使用者<br />
<br />
使用方式﹕<br />
<br />
less [Option] filename<br />
<br />
說明﹕<br />
less 的作用與 more 十分相似，都可以用來瀏覽文字檔案的內容，不同的是 less 允釣洏峈怍髡^卷動<br />
以瀏覽已經看過的部份，同時因為 less 並未在一開始就讀入整個檔案，因此在遇上大型檔案的開啟時，會比一般的文書編輯器(如 vi)來的快速。<br />
<br />
<br />
範例﹕<br />
<br />
<h2 id='ln.EF.BC.9A.E5.BB.BA.E7.AB.8B.E5.AF.A6.E9.AB.94.E9.80.A3.E7.B5.90.E8.88.87.E7.AC.A6.E8.99.9F.E9.80.A3.E7.B5.90'>21. ln：建立實體連結與符號連結</h2><br />
<br />
指令名稱 : ln<br />
使用權限 : 所有使用者<br />
<br />
使用方式 : ln [options] source dist，其中 option 的格式為 :<br />
<br />
[-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}]<br />
[--help] [--version] [--]<br />
說明 : Linux/Unix 檔案系統中，有所謂的連結(link)，我們可以將其視為檔案的別名，而連結又可分為兩種 : 硬連結(hard link)與軟連結(symbolic link)，硬連結的意思是一個檔案可以有多個名稱，而軟連結的方式則是產生一個特殊的檔案，該檔案的內容是指向另一個檔案的位置。硬連結是存在同一個檔案系統中，而軟連結卻可以跨越不同的檔案系統。<br />
ln source dist 是產生一個連結(dist)到 source，至於使用硬連結或軟鏈結則由參數決定。<br />
<br />
不論是硬連結或軟鏈結都不會將原本的檔案複製一份，只會佔用非常少量的磁碟空間。<br />
<br />
參數﹕<br />
-f : 鏈結時先將與 dist 同檔名的檔案刪除<br />
-d : 允釣t統管理者硬鏈結自己的目錄<br />
-i : 在刪除與 dist 同檔名的檔案時先進行詢問<br />
-n : 在進行軟連結時，將 dist 視為一般的檔案<br />
-s : 進行軟鏈結(symbolic link)<br />
-v : 在連結之前顯示其檔名<br />
-b : 將在鏈結時會被覆寫或刪除的檔案進行備份<br />
-S SUFFIX : 將備份的檔案都加上 SUFFIX 的字尾<br />
-V METHOD : 指定備份的方式<br />
--help : 顯示輔助說明<br />
--version : 顯示版本<br />
<br />
範例 :<br />
將檔案 yy 產生一個 symbolic link : zz<br />
ln -s yy zz<br />
<br />
將檔案 yy 產生一個 hard link : zz<br />
ln yy xx<br />
<br />
<br />
<br />
名稱 : locate<br />
使用權限﹕所有使用者<br />
<br />
語法 : locate [-q] [-d ] [--database=]<br />
locate [-r ] [--regexp=]<br />
locate [-qv] [-o ] [--output=]<br />
locate [-e ] [-f ] [-l ] [-c]<br />
[-U ] [-u]<br />
locate [-Vh] [--version] [--help]<br />
<br />
說明 : <br />
locate 讓使用者可以很快速的搜尋檔案系統內是否有指定的檔案。其方法是先建立一個包括系統內所有檔案名稱及路徑的資料庫，之後當尋找時就只需查詢這個資料庫，而不必實際深入檔案系統之中了。<br />
<br />
在一般的 distribution 之中，資料庫的建立都被放在 contab 中自動執行。一般使用者在使用時只要用<br />
<br />
# locate your_file_name<br />
<br />
的型式就可以了。 參數﹕<br />
-u<br />
-U<br />
<br />
建立資料庫，-u 會由根目錄開始，-U 則可以指定開始的位置。<br />
<br />
-e<br />
<br />
將<br />
排除在尋找的範圍之外。<br />
<br />
-l<br />
如果 是 1．則啟動安全模式。在安全模式下，使用者不會看到權限無法看到的檔案。這會始速度減慢，因為 locate 必須至實際的檔案系統中取得檔案的權限資料。<br />
<br />
-f<br />
將特定的檔案系統排除在外，例如我們沒有到理要把 proc 檔案系統中的檔案放在資料庫中。<br />
<br />
-q<br />
安靜模式，不會顯示任何錯誤訊息。<br />
<br />
-n<br />
至多顯示 個輸出。<br />
<br />
-r<br />
使用正規運算式 做尋找的條件。<br />
<br />
-o<br />
指定資料庫存的名稱。<br />
<br />
-d<br />
<br />
指定資料庫的路徑<br />
<br />
-h<br />
顯示輔助訊息<br />
<br />
-v<br />
顯示更多的訊息<br />
<br />
-V<br />
顯示程式的版本訊息 範例﹕<br />
<br />
locate chdrv : 尋找所有叫 chdrv 的檔案<br />
locate -n 100 a.out : 尋找所有叫 a.out 的檔案，但最多只顯示 100 個<br />
locate -u : 建立資料庫<br />
<br />
<br />
名稱 : ls<br />
使用權限 : 所有使用者<br />
<br />
使用方式 : ls [-alrtAFR] [name...]<br />
<br />
說明 : 顯示指定工作目錄下之內容（列出目前工作目錄所含之檔案及子目錄)。<br />
<br />
<br />
-a 顯示所有檔案及目錄 (ls內定將檔案名或目錄名稱開頭為.的視為隱藏檔，不會列出)<br />
-l 除檔案名稱外，亦將檔案型態、權限、擁有者、檔案大小等資訊詳細列出<br />
-r 將檔案以相反次序顯示(原定依英文字母次序)<br />
-t 將檔案依建立時間之先後次序列出<br />
-A 同 -a ，但不列出 . (目前目錄) 及 .. (父目錄)<br />
-F 在列出的檔案名稱後加一符號；例如可執行檔則加 *, 目錄則加 /<br />
-R 若目錄下有檔案，則以下之檔案亦皆依序列出<br />
<br />
範例﹕<br />
列出目前工作目錄下所有名稱是 s 開頭的檔案，愈新的排愈後面 :<br />
ls -ltr s*<br />
<br />
將 /bin 目錄以下所有目錄及檔案詳細資料列出 :<br />
ls -lR /bin<br />
<br />
列出目前工作目錄下所有檔案及目錄；目錄於名稱後加 /, 可執行檔於名稱後加 * :<br />
ls -AF<br />
<br />
名稱﹕more<br />
使用權限﹕所有使用者<br />
<br />
語法 : more [-dlfpcsu] [-num] [+/pattern] [+linenum] [fileNames..]<br />
<br />
說明 :<br />
類似 cat ，不過會以一頁一頁的顯示方便使用者逐頁嬝炕A而最基本的指令就是按空白鍵（space）就往下一頁顯示，按 b 鍵就會往回（back）一頁顯示，而且還有搜尋字串的弁遄]與 vi 相似），使用中的說明文件，請按 h 。<br />
<br />
參數 :<br />
-num 一次顯示的行數<br />
-d : 提示使用者，在畫面下方顯示 [Press space to continue, q to quit.] ，如果使用者按錯鍵，則會顯示 [Press h for instructions.] 而不是 嗶 聲<br />
-l : 取消遇見特殊字元 ^L（送紙字元）時會暫停的弁]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Wed, 04 Mar 2009 14:52:35 +0800</pubDate>
        </item>
        <item>
            <guid>http://mepopedia.com/forum/read.php?135,416,416#msg-416</guid>
            <title>Apache 內建的Web壓力測試工具 ApacheBench (ab, ab2) (no replies)</title>
            <link>http://mepopedia.com/forum/read.php?135,416,416#msg-416</link>
            <description><![CDATA[官方使用說明：<a href=http://httpd.apache.org/docs/2.2/programs/ab.html>ab - Apache HTTP server benchmarking tool</a> (Apache 2.2)<br />
<br />
簡易說明：<br />
<br />
ApacheBench 的使用很簡單，基本上有裝 Apahce 就會有，直接以 ab 或 ab2 作為指令使用就可以了。(注意有些 Linux 版本的指令是 ab<b>2</b>)<br />
<br />
情況一：公司要測試網站能否達到「首頁同時1,000人連線，平圴反應時間 5 秒以下。」<br />
<br />
此時使用以下指令即可：<br />
<pre>
Shell> ab -k -c 1000 -n 1000 http://yoursite.com/index.html</pre>
<br />
參數：<br />
-k 是 HTTP 2.0 的 Keep Alive，在短時間的測試下 connection 有無 Keep Alive 差別不是很大。<br />
-c 是指 concurrent，顧名思義其後的數字是「同時連線」的 connection 數。<br />
-n 是指整個 test 的 request number，此處設為和 -c 一樣是指同時1000個人連線測完一次就中止。<br />
<br />
底下是範例結果，「粗黑體」的數字 (1687 ms) 就是「平均反應時間」。這邊是 1.687 秒的意思。基本上如果是「純 HTML」的頁面，伺服器又不會太爛，concurrency 1000 的反應時間都不會太久(也許就像此處的 2 秒以下)。<br />
<br />
當然，要注意「同時1000個連線」這件事理論上是很難模擬的，此處只是「盡力」。1~2 秒間能後送出 1,000 個 requests 就很厲害了。<br />
<br />
<pre>
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      353  375  16.1    386     391
Processing:  1240 1312  52.1   1339    1369
Waiting:      449  472  16.2    476     499
Total:       1593 <b>1687</b>  67.7   1730    1756</pre>
<br />
--<br />
<br />
底下節錄的文章來源: <a href=http://nickdenardis.com/2007/06/27/stress_testing_a_site_with/>Stress testing a site with Apache’s ab tool, part 1</a> (很不錯的介紹)<br />
<br />
<br />
以下節錄有關「送出表格」方面的壓力測試：<br />
<br />
What if the site is behind a login that is an http form and not an htaccess form? That is where POST variables come into play, it is a little trickier but doable. Here is the command I use to hit a page behind a login.<br />
<br />
<code>ab -p ~/Documents/post.txt -T application/x-www-form-urlencoded -e http://example.com/manager/</code><br />
<br />
Here is what my post.txt file contains:<br />
email=test@domain.com&password=testing&amp;submit=Login<br />
<br />
Next we need to get these results to a file so we can work with them and have a record of progress as we tweak our site. It can be done with the “-e” parameter. An example is below:<br />
<br />
<code>ab http://example.com/search.php?q=Trees -e ~/Documents/results1.csv</code><br />
<br />
What that does is hits the search page and puts the results in the results1.csv file. It is useful to put the file at the end of the command since you will want to change the filename on each run to keep a history of your results.<br />
<br />
The csv file is separated into two columns. The first is the percentage complete and the second is the time in ms that it took to get to that percentage.<br />
<br />
The first thing you want to look at is the zero percent. This is your latency, it is the amount of time it takes to fulfill the first request. You want this number to be as low as possible. I am running my site on a development server on my local network so the times will be lower but at the end I will show the results from the testing server.<br />
<br />
<code>ab -p ~/Documents/aci_post.txt -T application/x-www-form-urlencoded -e ~/Documents/aci_output.csv -kc 10 -t 10 http://aci/manager/makes.php</code>]]></description>
            <dc:creator>HP</dc:creator>
            <category>Linux系統管理</category>
            <pubDate>Tue, 03 Mar 2009 23:13:05 +0800</pubDate>
        </item>
    </channel>
</rss>
