[轉貼] Debian Linux 完整移除套件 / 重新安裝套件 / 鎖定套件版本(apt)

文章來源:Tsung’s Blog

很多人常會發生把某個套件搞爛了, 或者設定檔之類不小心砍掉了,

再來想到的當然是移除再重新安裝 或直接 (apt-get install –reinstall package),

但是怎麼裝, 設定檔就是回不來, 搞爛的資料也還是留著.

這並不是 Debian 的錯, 主要是怕你在移除時,

不小心就將重要資料跟著就砍掉了(ex: MySQL 不小心移除就把 DB 砍掉, 這就很尷尬了.)

此篇文章也有說明發生狀況: 如何在 Debian Etch 系統下完全移除套件與實體目錄?

套件重新安裝

就上述那篇文章的例子, 不小心將 Apache 的設定檔蓋掉/砍掉, 所以打算重新安裝 Apache.

套件移除重新安裝, 和 apt-get install –reinstall apache2 並沒有錯,

只不過問題是, apache2 的 package 裡面並沒有 設定檔. Orz.

由此可見 Package 套件內容:

  • dpkg -L apache2 | grep conf
  • dpkg -L apache2.2-common | grep conf # Debian 設定檔都放在 package_name-common 中
  • 或者上述文章作者的做法是 less /var/lib/dpkg/info/apache2.list 也是可以.
  • 所以要重新取得設定檔, 應該直接

    apt-get install –reinstall apache2.2-common

    即可. (請修改成自己系統的 apache2 版本)

套件完整移除

現在遇到的另一個狀況是, MySQL 被搞爛了, 所以要將全部移除(含資料都要移除), 再重新安裝.

完整移除的步驟:

apt-get remove –purge mysql-server mysql-server-5.0 mysql-common mysql-client mysql-client-5.0

這一行就會將 DB/設定檔都完整移除(–purge 會將所有移除), 不過大多人的問題是, –purge 後面那一串是從哪來的?

可用下述查法:

  • dpkg -l | grep mysql # dpkg -l 會列出此系統安裝的所有 package
  • ls /var/lib/dpkg/info/*mysql*

移除之後, 重新安裝直接 apt-get install 就可以囉~ :)

註: 若只是 Database file 爛了, 只要 apt-get remove –purge mysql-server-5.0, 再重新安裝 mysql-server-5.0 即可.

套件鎖定版本

此段內容詳可見: Apt和dpkg快速參考

假設現在要鎖定 gaim 版本, 不想要 gaim 被升級或降級,有下述兩種做法:

  1. echo “gaim hold" | dpkg –set-selections # 將 gaim 鎖定版本
    dpkg –get-selections “gaim" # 檢查: 出現 gaim hold # 狀態是 hold, 就不能被升級了.
  2. vim /etc/apt/preferences # 內容如下, 把版本編號寫死.

    Package: gaim
    Pin: version 0.58*

套件解除鎖定

  1. echo “gaim install" | dpkg –set-selections
  2. dpkg –get-selections “gaim" # 檢查: 出現 gaim install # 狀態被重置為 install, 就可以繼續升級了

狀態檔案位置

  • hold / install 這些狀態標誌都寫在 /var/lib/dpkg/status 裡, 也可以手動去修改變 hold / install 等狀態.

其它相關

  • apt-get clean #/var/cache/apt/archives 會清掉 *.deb 檔
  • apt-get update # 會更新 /var/lib/apt/lists 的資料

相關網頁

Run Flashtool in Ubuntu Linux

From: http://duopetalflower.blogspot.tw/2012/08/flashtool-in-ubuntu-linux.html

Flashtool in Ubuntu Linux

Everytime I wanted to change firmware for my Xperia phone, I used to reboot into Windows 7

Recently I feel lots of Blue Screen Of Death in Windows 7 (think due to nvidia driver problem), and did not want to reinstall Windows 7

I tried flashtool in Ubuntu Linux and it worked, I changed firmware in my Xperia phone!! Thanks XDA devs and Flashtool devs

Here is how

Download flashtool for Linux from (Refer, http://forum.xda-developers.com/showthread.php?t=1588586)

http://androxyde.github.com/Flashtool/

After downloading the linux version with extension tar.7z, unzip it

To do this, install p7zip, p7zip-full from synaptic or from software center

Unzip the Flashtool folder,

Add this rules to following file (create this file by copying existing 70-persistent-net.rules as follows,
sudo cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/80-persistent-usb.rules)

sudo vi /etc/udev/rules.d/80-persistent-usb.rules

and add

SUBSYSTEM=="usb", ACTION=="add", SYSFS{idVendor}=="0fce", SYSFS{idProduct}=="*", MODE="0777″

Before running flashtool install ia32-libs

sudo apt-get install ia32-libs

To run the flashtool enter the directory where the 7zip got extracted and run FlashTool as super user

For e.g I did this

cd Downloads/FlashTool/

sudo su

./FlashTool

I choose to install a firmware to my Xperia phone and Flashtool in action

After installing new Firmware my phone screen looks as below

在 Ubuntu 的 /etc/rc.local 上, 設定要執行某些指令卻沒能被執行

由於直接在命令列下達 echo “drbdadm primary all" >> /etc/rc.local 。但重開機後,卻發現 drbd resources 並沒有被設定為 primary。 原來是 原先的 /etc/rc.local 最後一行是「exit 0」(在ubuntu中的), 而我要執行的命令是添加在檔案尾最後一行當然不會被執行囉,因為前面就已經EXIT囉!

clustered lvm commands fail with “activation/monitoring=0 is incompatible with clustered Volume Group" error

From: http://markmail.org/thread/mbr36mj6k3e4m7u3#query:+page:1+mid:5uvd2tdqscgjd676+state:results

[Bug 833368] Re: clustered lvm commands fail with “activation/monitoring=0 is incompatible with clustered Volume Group" error

Public bug reported:

I’m trying to configure a clustered lvm2 using cman and clvm, but clvm start up and lvm commands fail with this error:

# vgchange -a y data_vg

activation/monitoring=0 is incompatible with clustered Volume Group “data_vg":
Skipping.

if I use “–monitor y" then the command works as expected.

# vgchange -a y –monitor y data_vg

1 logical volume(s) in volume group “data_vg" now active

activation/monitoring is set to 1.

This bug was fixed in the package lvm2 – 2.02.66-4ubuntu7.2

————— lvm2 (2.02.66-4ubuntu7.2) precise; urgency=low

* Honour monitoring=1 config option in /etc/lvm/lvm.conf when using clustered VGs (LP: #833368).

* /etc/init.d/clvm status now exits with code 3, if clvm is not running, as per LSB specification. (LP: #988881) — Dmitrijs Ledkovs <dmit@ubuntu.com> Wed, 06 Feb 2013 10:34:32
+0000

** Changed in: lvm2 (Ubuntu Precise) Status: Fix Committed => Fix Released

Ubuntu 登入桌面後會提示更新的帳號,變成不會提示更新。

最終變成需要手動去點擊檢查更新,才會執行更新檢查。但這樣需要輸入 root 的密碼,才會執行。

似乎是該帳號沒被加入到「sudo」群組中。可能是之前不小心將該帳號從「sudo」群組給移除。重新加回來就回復正常了。

這條命令將我的帳號加入 sudo 群組,「sudo usermod -a -G sudo jerry」。

ubuntu install clvm

安裝需要的套件

apt-get install system-config-cluster cman clvm

執行 system-config-cluster 加上叢集節點,產生 cluster.conf 設定檔(讓cman啟動)。

啟動 cman : service cman start

修變設定 lvm.conf : locking_type = 3
或是執行 lvmconf –enabledcluster 指令

建立 DRBD 裝置(primary-primary mode)
建立新的 VG for cluster 或是 修改現有的 VG for cluster
new: vgcreate -c y -n vg-cluster /dev/drbd-device
modify: vgchange -c y exist-vg

啟動 clvm: service clvm start

speed up Ubuntu 12.10 by turning off unnecessary visual effects

Here’s how you can speed up Ubuntu 12.10 by turning off unnecessary visual effects.

1. Open a terminal window.

2. Type in the following command then hit Enter.

sudo apt-get install compizconfig-settings-manager

3. This will install the Compizconfig Settings Manager.

4. Start Compiz and go the Effects menu.

5. Turn off all these effects to speed up Ubuntu 12.10:

Animations
Fading Windows
Window Decoration
Blur Windows
Water Effect
Wobbly Windows

For more, see the original article at the link below.

Install LAMP Server in Ubuntu Server 12.04 LTS

Install LAMP Server in Ubuntu Server 12.04 LTS

Log in on your ubuntu server remotly with ssh

Install LAMP Stack (Linux,Apache, Mysql, PHP) with command below:

sudo apt-get install lamp-server^

Install PHP5 (Some applications require other PHP5 mods) with command:

sudo apt-get install php5 php5-gd php5-mysql php5-curl php5-cli php5-cgi php5-dev

Install phpmyadmin

sudo apt-get install phpmyadmin