Ubuntu 14.04 LTS Server 安裝 dnsmasq DHCP Server

dnsmasq 也是一套 DHCP Server,除此之外,也可以用來做為 caching DNS proxy 和 TFTP Server。

參考網頁:Dnsmasq – Community Help Wiki

1. 查詢 dnsmasq套件相關訊息
$ sudo apt-cache search dnsmasq | grep ^dnsmasq
dnsmasq-base – Small caching DNS proxy and DHCP/TFTP server
dnsmasq-utils – Utilities for manipulating DHCP leases
dnsmasq – Small caching DNS proxy and DHCP/TFTP server

2. 進行安裝
$ sudo apt-get install  dnsmasq dnsmasq-utils -y
[@more@]3. 備份原設定檔
$ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.$(date +%F)

4. 修改設定檔
$ sudo vim /etc/dnsmasq.conf
domain-needed
bogus-priv
local=/computerclassroom.tces.ilc.edu.tw/
expand-hosts
domain=computerclassroom.tces.ilc.edu.tw
interface=eth1
dhcp-range=eth1,192.168.5.1,192.168.5.200,12h
listen-address=127.0.0.1
server=168.95.1.1
server=140.111.66.1
log-queries
log-dhcp

5. 執行 dnsmasq 服務
$ sudo service dnsmasq start
 * Starting DNS forwarder and DHCP server dnsmasq                                    [ OK ]

6. 檢查是否有正常啟動
$ netstat -au | grep :bootps
udp        0      0 *:bootps                *:*

感覺 dnsmasq 的設定比較簡單,但比較沒有辦法像 isc-dhcp-server 一樣做到比較細微的設定,如:針對某一台電腦給予固定的 IP。

移除 dnsmasq
$ sudo apt-get remove –purge dnsmasq dnsmasq-base dnsmasq-utils libmnl0 libnetfilter-conntrack3

Ubuntu 14.04 LTS Server 安裝 DHCP Server

1. 安裝 DHCP Server 套件
$ sudo apt-get install isc-dhcp-server -y

2. 進行設定,指定發送 IP  的網路卡
$ sudo sed -i ‘s/INTERFACES=””/INTERFACES=”eth1″/’ /etc/default/isc-dhcp-server
[@more@]3. 修改設定檔 /etc/dhcp/dhcpd.conf
$ sudo vim /etc/dhcp/dhcpd.conf
列出 DHCP Server 設定
$ sudo cat /etc/dhcp/dhcpd.conf | egrep -v ‘^$|^#’
ddns-update-style none;
option domain-name “computerclassroom.tces.ilc.edu.tw”;
option domain-name-servers 168.95.1.1, 140.111.66.1;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.5.0 netmask 255.255.255.0 {
  range 192.168.5.201 192.168.5.205;
  option domain-name-servers 168.95.1.1, 140.111.66.1;
  option domain-name “computerclassroom.tces.ilc.edu.tw”;
  option routers 192.168.5.254;
  option broadcast-address 192.168.5.255;
  default-lease-time 600;
  max-lease-time 7200;
}
host windows81 {
   hardware ethernet 00:1e:90:48:c8:8b;
   fixed-address 192.168.5.201;
}
host windows7 {
   hardware ethernet 00:1e:90:47:fa:78;
   fixed-address 192.168.5.202;
}

4. 啟動 DHCP Server
$ sudo service isc-dhcp-server start
isc-dhcp-server start/running, process 3524

5. 檢查是否有正常啟動
# netstat -anu | grep :67
udp        0      0 0.0.0.0:67              0.0.0.0:*

# lsof -i :67
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
dhcpd   30687 dhcpd    7u  IPv4 360732      0t0  UDP *:bootps

6. 設定開機時啟動 DHCP Server
# update-rc.d isc-dhcp-server defaults
 Adding system startup for /etc/init.d/isc-dhcp-server …
   /etc/rc0.d/K20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc1.d/K20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc6.d/K20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc2.d/S20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc3.d/S20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc4.d/S20isc-dhcp-server -> ../init.d/isc-dhcp-server
   /etc/rc5.d/S20isc-dhcp-server -> ../init.d/isc-dhcp-server

Ubuntu 12.04 關閉自動更新的提示

參考網站:
ubuntu 12.04关闭自动更新提示 – 快乐编程

目前有一台筆電是安裝 Ubuntu Mac Style,每次開機或三不五時都會跳出下面的提示視窗
[@more@]因為 Ubuntu Mac Style 使用的是 Ubuntu 12.04,所以每次都會一直跳出提示,是否要升級到 14.04。

解決方式:
1. 選擇 系統工具 / 管理 / 更新管理員

2. 選擇設定(S)

3. 視自己的需求做設定,好了之請按 關閉(C)


/etc/update-manager/release-upgrades 設定檔中的
APT::Periodic::Update-Package-Lists “1”;
改成
APT::Periodic::Update-Package-Lists “0“;
$ sudo sed -i ‘/Package-Lists/s/1/0/’ /etc/apt/apt.conf.d/10periodic

4. 如果之後要更新時
$ sudo apt-get update
$ sudo apt-get upgrade
或是
$ sudo apt-get dist-upgrade

在 Ubuntu Linux 上使用 Scratch 2 來開啟 .sb2 檔

在 Ubuntu Linux 上 .sb2 檔會被當成壓縮檔,使用壓縮檔的開啟程式來開啟,無法按二下直接用 Scratch 2 來直接開啟,有些不方便

參考下列的網頁來完成:夢幻天地blog: ubuntu加入自訂的檔案關聯
1.  開啟 Ubuntu Tweak,選擇 管理員(A)
[@more@]2. 選擇 檔案類型管理員

3. 選擇 應用程式 / Zip 封存檔 / 編輯(E)

4. 使用自訂指令(U)

5.  輸入 /opt/Scratch 2/bin/Scratch 2,並按 加入(A)

6. 按 關閉

7. 這時候就可以按二下 .sb2 用 Scratch 2 來開啟,或是按滑鼠右鍵,選擇 以 Scratch2 開啟(O)

Ubuntu Linux 將套件更新來源改成國家高速網路中心

原本的 Ubuntu Linux 在做套件更新時,會依照地區所在別,切換到不同的 Server,以臺灣為例是 tw.archive.ubuntu.com
查看一下這一台 Server 的資訊
$ host tw.archive.ubuntu.com
tw.archive.ubuntu.com is an alias for ubuntu.stu.edu.tw.
ubuntu.stu.edu.tw is an alias for ftp.stu.edu.tw.
ftp.stu.edu.tw has address 120.119.118.1
ftp.stu.edu.tw has IPv6 address 2001:e10:c41:eeee::1

因為 Server 是在臺灣,所以連線速度都還不會太慢[@more@]但安全性更新(security),則是 security.ubuntu.com
$ host security.ubuntu.com
security.ubuntu.com has address 91.189.91.14
security.ubuntu.com has address 91.189.91.15
security.ubuntu.com has address 91.189.91.23
security.ubuntu.com has address 91.189.91.13
security.ubuntu.com has address 91.189.92.201
security.ubuntu.com has address 91.189.88.149
security.ubuntu.com has address 91.189.92.200
security.ubuntu.com has address 91.189.91.24
security.ubuntu.com has IPv6 address 2001:67c:1562::17
security.ubuntu.com has IPv6 address 2001:67c:1562::13
security.ubuntu.com has IPv6 address 2001:67c:1562::16
security.ubuntu.com has IPv6 address 2001:67c:1562::14
security.ubuntu.com has IPv6 address 2001:67c:1562::15
security.ubuntu.com has IPv6 address 2001:67c:1360:8c01::18
security.ubuntu.com has IPv6 address 2001:67c:1360:8c01::19

這一台 Server 看起來則不像是在臺灣,所以連線速度有時候會很慢

底下將更新的 Server 都改成國家高速網路中心
$ sudo sed -i ‘s/tw.archive.ubuntu.com/free.nchc.org.tw/g’ /etc/apt/sources.list
$ sudo sed -i ‘s/security.ubuntu.com/free.nchc.org.tw/g’ /etc/apt/sources.list
清除所有的
$ sudo apt-get clean all
更新套件庫
$ sudo apt-get update

Ubuntu Linux 鎖住某些套件不升級

有些因為某些因素,所以不想把套件升級到最新版本,設定方式:
參考網頁:
夢幻天地blog: ubuntu鎖套件版本

鎖住 zip 套件不升級
# echo “zip hold” | dpkg –set-selections

解除 zip 套件鎖定
# echo “zip install” | dpkg –set-selections

查看 zip 套件是否有被鎖定,出現 hold 代表被鎖定,install 沒有被鎖定
# dpkg –get-selections zip
zip                        hold

查看有哪些套件被鎖定
# dpkg –get-selections | grep hold

Ubuntu Linux 通知系統可升級的套件

因為資安的問題,所以作業系統或是程式都要常做更新,才能確保系統的安全。在作業系統或程式更新的時候,我通常喜歡自己決定更新的時候或是更新的套件,因為有時候,太快更新或是自動更新,可能會造成災難,所以能自行掌握更新時間點,會是比較好的事,但這會造成使用者的一些負擔,必須要常常去注意相關的訊息。
參考網頁:力力皆辛苦: [Ubuntu]啟用Ubuntu 自動安全更新與設定E-mail通知
Ubuntu Linux 在登入時,系統會有提示可以更新的套件
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-74-generic-pae i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Jan 20 08:28:27 CST 2015

  System load:  0.0               Processes:           80
  Usage of /:   7.8% of 72.05GB   Users logged in:     1
  Memory usage: 24%               IP address for eth0: 140.111.xx.xx
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

25 packages can be updated.
24 updates are security updates.

New release ‘trusty’ available.
Run ‘do-release-upgrade’ to upgrade to it.[@more@]但管理者並不一定會常常登入系統,所以改用 apt-get -s upgrade 的指令來查詢出可以更新的套件,再配合 crontab 和 mail,當系統有套件可以更新時,寄信通知管理者。

# vim /usr/local/bin/check-update
#!/bin/bash
apt-get update > /dev/null  2>&1
apt-get -s upgrade | grep Inst | awk ‘{print $2,$3}’ > /tmp/$(date +%F)
if [ -s /tmp/$(date +%F) ] ;then
   mail -s “Ubuntu Linux Updates Available” xxx@gmail.com < /tmp/$(date +%F)
   rm -rf /tmp/$(date +%F)
else
   rm -rf /tmp/$(date +%F)
fi

更改權限
# chmod 700 /usr/local/bin/check-update

加入工作排程
# crontab -e
0 3 * * * /usr/lcoal/bin/check-update

在 Ubuntu Linux 使用 PPA 的方式來安裝 Google Chrome

參考網頁:
Install Google Chrome in Ubuntu 14.04 / 13.10 / 12.04 PPA
Install Google Chrome 39 in Ubuntu 14.04 and 12.04 LTS

1. 安裝 add-apt-repository 套件
$ sudo apt-get install software-properties-common python-software-properties

2. 增加套件庫
$ wget -q -O – https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add –
$ sudo sh -c ‘echo “deb http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google-chrome.list’

3. 更新套件庫
$ sudo apt-get update[@more@]4. 安裝 Google Chrome Stable
$ sudo apt-get install google-chrome-stable

或是其它的測試版本
$ sudo apt-get install google-chrome-beta
$ sudo apt-get install google-chrome-unstable

在 Ubuntu Mac Style 上的 LibreOffice 加上標點符號工具列

雖然自己使用的行列輸入法中可以很方便輸入標點符號,但在資訊課教學生時,學生在輸入標點符號時,就會遇到一些困擾,這時如果有標點符號工具列就方便多了!
[@more@]在 LibreOffice 中可以使用的標點符號工具列有二套,
漢文標點符號(台灣)工具列
中華民國臺灣正體中文標點符號工具列

1. 首先先使用 中華民國臺灣正體中文標點符號工具列
選擇 Download extension

2. 將下載下來的檔案儲存起來

3. 開啟 LibreOffice Writer,選擇 檔案 / 開啟

4. 選擇下來下來的檔案 roctwtcpaoo401intel-2.0.0.oxt,然後按 開啟

5. 按 確定

6. 無法安裝,因為我的 LibreOffice 版本過舊,要 4.x 版才安裝

7. 改安裝 漢文標點符號(台灣)工具列

8. 將下載下來的檔案儲存起來

9. 開啟 LibreOffice Writer,選擇 檔案 / 開啟

10. 選擇 chinesepunctuationtw-1.0.1.oxt,並按 開啟

11. 選擇 確定

12. 授權合約,請按 向下捲動(S),最後按 接受

13. 選擇 關閉

14. 出現浮動的標點符號工具列

15. 也可以拉動固定在工具列上