顯示具有 ubuntu 標籤的文章。 顯示所有文章
顯示具有 ubuntu 標籤的文章。 顯示所有文章

星期六, 2月 25, 2023

ubuntu的apt與gpg

最近因為在 Ubuntu 更新的時候,老是出現 gpg pub key 錯誤,有問題的套件庫是 hashicorp 跟 yarn 的套件庫,今天終於下定決心處理。

第一個找到的是這篇:How to configure HashiCorp repository

處理方法是這樣的,先下載 gpg key,然後用 sudo gpg 匯入

wget --quiet --output-document - https://apt.releases.hashicorp.com/gpg | \
  sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/hashicorp-archive-keyring.gpg --import

然後檢查 /usr/share/keyrings/hashicorp-archive-keyring.gpg

ls -l /usr/share/keyrings/hashicorp-archive-keyring.gpg

permission 結果應該要是 644 。

接著檢查 source list 檔案,裏面會有 signed-by 的字串

deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com jammy main

基本上這樣就解決了,yarn 的處理方式也一樣。

wget --quiet --output-document - https://dl.yarnpkg.com/debian/pubkey.gpg | sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/yarnkey.gpg --import

只是這邊做完,還是有問題,後來才靈機一動想到要檢查 /usr/share/keyrings/yarnkey.gpg 的 permission,發現是 600,用 chmod 改為 644 以後,apt update 就沒問題了。

星期六, 10月 15, 2022

Debian/Ubuntu 自動更新

要如何設定 Debian/Ubuntu 自動做更新呢?這可以使用 dpkg-reconfigure -plow unattended-upgrade 來設定

sudo dpkg-reconfigure -plow unattended-upgrades

執行指令後,會跳出視窗詢問是否要自動更新,選擇 Yes 就可以了。執行以後,會更新 /etc/apt/apt.conf.d/20auto-upgrades 這個檔案的內容

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

如果有不想自動更新的套件,可以用黑白名單來設置,這邊可以參考 /etc/apt/apt.conf.d/50unattended-upgrades 檔案裡的範例來設定。

有些套件在更新後,會需要重新開機,unattended-upgrade 也可以做到自動重開機,主要是在 /etc/apt/apt.conf.d/20auto-upgrades 加入以下設定

//Unattended-Upgrade::Automatic-Reboot "false";
//Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
//Unattended-Upgrade::Automatic-Reboot-Time "02:00";

除了可以指定是否自動重開機外,也可以指定自動重開機的時間。

了解 Debian/Ubuntu 如何自動更新以後,相信在管理主機上會更為輕鬆。

參考資料

星期日, 8月 07, 2022

tuned-套用適合的系統設定

RHEL 跟 Ubuntu 都有提供這個系統服務,可以啟用這個系統服務來微調系統的設定,以達到預期的效能。

安裝

印象中,RHEL8 預設已經安裝,若沒有,可以用以下指令來安裝

yum install -y tuned

Ubuntu 可以使用以下指令來安裝

sudo apt install tuned

使用

使用相當簡單,啟動系統服務以後就可以了。

systemctl start tuned

之後就可以使用 tuned-adm 來做一些操作,這邊先說明一下什麼是 profile 。

profile 就是一組針對特定用途所提供的系統設定,例如網路最佳化或是資料庫最佳化等等的,不同的用途要調整的設定也不一樣。在啟動 tuned 以後,會啟用預設的 profile ,以 ubuntu 來說,是啟動 balanced 這個 profile。

tuned-adm 有以下子指令可以使用,以進行 profile 的操作:

子指令用途
list列出所有可用的 profile,每個 Linux 發行版所提供的 profile 都不太一樣。
active列出目前啟用的 profile
off關閉所有調整
profile切換到指定的 profile
profile_info顯示指定的 profile 資訊
recommend顯示建議的 profile
verify檢查
auto_profile自動選擇 profile
profile_mode顯示目前是自動選擇 profile 還是手動指定 profile

如果要客製化自己的 profile,也是可以的,這邊可以參考 /usr/lib/tuned 裡的 profile 來做複製跟改動。

星期六, 7月 30, 2022

Ubuntu LivePatch

Ubuntu LivePath 是一個動態修補 kernel 漏洞的機制。在傳統作法上,如果修補、更新了 kernel ,就一定要重新開機,讓新的 kernel 生效才能真正的修補漏洞。LivePatch 則提供了一個不需要重開機的方法,他會動態的修補在目前的 kernel 裡。在 ubuntu 的 How kernel livepatching works 有圖片說明。

Canonical 很佛心的提供了 Personal token,只要去 ubuntu.com 註冊,就可以取得。

取得 token 以後,就可以使用以下指令啟用

sudo ua attach <token>
sudo ua enable livepatch

啟用後,若想知道目前套用了哪些修補,可以用 canonical-livepatch 指令察看

canonical-livepatch status

若是公司使用,會需要購買企業訂閱。若是想把修補放到公司內部來節省頻寬,可以參考 Livepatch on-prem 的說明來進行。我大致看了一下,說是會把修補放到 S3 上面,離線的作法或許可以架設 minio 來代替 S3。這部份因為沒用到,就先跳過不看了。

星期五, 7月 29, 2022

SSH登入使用2FA驗證

Ubuntu 跟 RHEL 的設定方法大同小異:

  • Ubuntu: sudo apt install libpam-google-authenticator
  • RHEL: sudo yum install -y google-authenticator qrencode

步驟1

用 google-authenticator 產生所需的設定檔。

產生出來的檔案會在 ~/.google_authenticator

步驟2

設定 /etc/pam.d/sshd

加入

auth required pam_google_authenticator.so

步驟3

在 SSHD 設定檔 /etc/ssh/sshd_config 裡找到 ChallengeResponseAuthentication ,將其後的值改為 yes

ChallengeResponseAuthentication yes

修改完成後,重新啟動 sshd。

有陷阱!!

大致就這樣,在 RHEL8 會踩到 SELinux 的雷,這邊要修改 /etc/pam.d/sshd 的設定,將之前加入的那行改為

auth required pam_google_authenticator.so secret=/home/${USER}/.ssh/.google_authenticator

然後把 ~/.google_authenticator 檔案搬到 ~/.ssh/google_authenticator

處理一下 SELinux 權限

restorecon -Rv ~/.ssh/google_authenticator

然後一樣,重新啟動 sshd

圖形介面

參考資料裡的後半段有關於 GUI 登入的設定,這邊我就沒試過了。

參考資料

星期日, 2月 20, 2022

在 Ubuntu 開發 .Net 應用程式

這幾年微軟大力推廣 .Net core ,把 .Net runtime 鋪到每個 Linux 發行版去,所以現在 Ubuntu、Red Hat Enterprise、Debian、Fedora、CentOS、Alpine 等 Linux 發行版都可以安裝 .Net runtime 跟 .Net SDK 。

以 Ubuntu 來說,安裝方法很簡單,就是照這篇 在Ubuntu 上安裝 .NET SDK 或 .NET 執行時間 來做就可以。

我桌機安裝的是 Ubuntu 21.10 ,所以下面就只節錄 Ubuntu 21.10 的部份

wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0 aspnetcore-runtime-6.0

安裝完成以後,就可以使用 dotnet 這個指令來開發應用程式了。

首先建立目錄,然後切換到此目錄下

mkdir -p ~/dotnetcore-hello
cd ~/dotnetcore-hello

然後用 dotnet 指令建立範本

dotnet new webapp -n dotnetcore-hello -o .
  • webapp 表示建立網頁應用程式。
  • -n 是表示專案名稱。
  • -o . 是表示輸出到目前的目錄。

產生完畢,就可以啟動。

dotnet run

啟動以後會有以下訊息

正在建置...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7219
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5063
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /home/user/dotnetcore-hello/

從訊息可以知道,用瀏覽器開啟 http://localhost:5063 或是 https://localhost:7219 就可以開啟網站。

一般在開發時,會把 port 固定起來,以方便開發;或者是禁用 https 。那這樣該怎麼做呢?這時候可以參考 How do I disable HTTPS in ASP.NET Core 2.1 + Kestrel? ,dotnet 應用程式的 port 跟 https 設定是在 Properties/launchSettings.json 裏面去指定的,只要修改裡面的 applicationUrl 即可。

例如 applicationUrl 本來是 https://localhost:7219;http://localhost:5063,改為只有 http,port 8000 並讓網路上其他電腦都可以連進來的話,就改為 http://0.0.0.0:8000

最後,開發完畢以後,要輸出檔案去佈署,可以用 dotnet publish 來建置。

dotnet publish -c release -o out

以上面的指令來說,

  • -c 是指定要使用的 configuration
  • -o 是指定把建置好的檔案輸出到 out 目錄下。

今天就把 QuickStart 的開發流程紀錄起來,免得以後遇到又在那邊查。

星期日, 3月 07, 2021

如何在 multipass VM內執行 GUI 應用程式

multipass 是 Canonical 所推出的一個輕量級 VM 管理工具,它跨平台,支援 Linux、Windows 跟 MacOS。

這個工具用一陣子了,相當的好用,缺點是目前只有 Ubuntu 的 VM 可用。之前是想到,既然 multipass shell 是用 ssh 登入,那麼應該要可以 Forward X11 才對。也就是說以 SSH 登入以後,執行 GUI 應用程式,畫面會轉向到目前 Host 的 X Server 。

但試了以後卻不行,請教 Google 以後,Google 告訴我 StackOverflow 上已經有人解答了:18.04 – How to open GUI applications in multipass container(guest = ubuntu, host = ubuntu)? X-Forwarding – Ask Ubuntu

先說明一下我的環境:

  • Ubuntu 20.04
  • 用 snap 安裝 multipass

首先,先取得 ssh key,因為 multipass 是用 snap 安裝的,所以得從 /var/snap/multipass 裏面找到 ssh private key,把它複製到 ~/.ssh/multipassKey 目錄下。

    mkdir ~/.ssh/multipassKey
    sudo cp /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa ~/.ssh/multipassKey/id_rsa

接著變更這個 private key 的權限為 0600,並且變更擁有者

sudo chown user -R ~/.ssh/multipassKey
sudo chmod 0600 ~/.ssh/multipassKey/id_rsa

再來啟動 VM,並且察看 VM 的 IP

multipass start name
multipass ls

最後使用 ssh 登入

ssh -X -i ~/.ssh/multipassKey/id_rsa ubuntu@<my_vm_ip>

就這樣。

星期五, 10月 04, 2019

Tor

這篇只講在 Ubuntu 16.04/18.04 上的安裝。

安裝

echo "deb https://deb.torproject.org/torproject.org/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/tor.list
curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
sudo apt-get update
sudo apt-get install tor tor-geoipdb torsocks deb.torproject.org-keyring privoxy
修改 /etc/privoxy/config ,檔案結尾加入
forward-socks5 / localhost:9050 .
然後重新啟動
sudo systemctl restart privoxy
privoxy 主要是為只支援 http proxy 的程式提供 http proxy,tor 主要只提供 sock proxy。執行程式時,用 torsocks your_command 即可。要查 IP ,可以用 torsocks curl ipv4.icanhazip.com

參考資料

星期五, 1月 04, 2019

Ubuntu 14.04 + Python 3.7.2

我是使用 pyenv 來安裝,pyenv 的安裝:
# 一鍵安裝
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
在安裝 Python 3.7.2 時,出現 ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib? 這樣的錯誤。
參考錯誤訊息,先依據 https://github.com/pyenv/pyenv/wiki/Common-build-problems 上的說明去檢查並安裝,但安裝了所需的套件之後,仍然有錯誤。後來再去找,才在 pyenv issue #950 找到原因,原來是 Ubuntu 14.04 的 OpenSSL 版本過舊,Python 3.7 需要 OpenSSL 1.0.2 以後的版本才行。
看了一下 Ubuntu 16.04 的 openssl 套件,版本是 1.0.2,於是就拿了 16.04 openssl 的 source package 回來,在 14.04 上編譯出 deb 來安裝就可以了。
# On Ubuntu 16.04
apt-get source openssl
# On Ubuntu 14.04
cd openssl-1.0.2g
dpkg-buildpackage
ls ../*.deb
# Output:
# ../libssl1.0.0_1.0.2g-1ubuntu4.14_amd64.deb      ../libssl-dev_1.0.2g-1ubuntu4.14_amd64.deb  ../openssl_1.0.2g-1ubuntu4.14_amd64.deb
# ../libssl1.0.0-dbg_1.0.2g-1ubuntu4.14_amd64.deb  ../libssl-doc_1.0.2g-1ubuntu4.14_all.deb
# Install them
ls ../*.deb | xargs sudo dpkg -i
再次安裝 Python 3.7.2
pyenv install -v 3.7.2
# 將當前目錄的 python 設定為 3.7.2,也就是以後切換到這個目錄時,自動使用 python 3.7.2
pyenv local 3.7.2
python --version
# Output:
# Python 3.7.2
# Use local python to make virtualenv
mkvirtualenv myproject --python=$(pyenv which python) -r requirements.txt

星期日, 11月 25, 2018

apt 使用 mirror

看到這篇文章:How to select the fastest apt mirror on Ubuntu Linux ,sources.list 裡可以改用 mirror://mirrors.ubuntu.com/mirrors.txt 這樣的 URL,apt 就會自動使用 mirror ,不過 apt 不一定會選到最快的 mirror。
在選最快的 mirror 時,可以用 netselect ,但 debian 才有包 netselect 。文章的留言有人提到一個組合命令可以用來取代 netselect ,我試了之後,發現不能用,稍稍做了調整 (改 sed 以及改用 awk 取 ping 結果):
for mirror in $(wget -qO - mirrors.ubuntu.com/mirrors.txt|sed 's/^http:\/\///;s/\/.*$//') ; do echo $(ping -c 1 $mirror|awk 'BEGIN {FS="[=]|[ ]"} NR==2 {print $11}') $mirror ; done|sort -n|grep "^[0-9]"|head -n 20
執行以後的結果:
2.49 mirror01.idc.hinet.net
3.47 debian.linux.org.tw
3.61 ubuntu.cs.nctu.edu.tw
5.45 ftp.tku.edu.tw
13.5 ftp.ntou.edu.tw
33.3 ubuntu.stu.edu.tw
40.8 ftp.ubuntu-tw.net
91.8 mirror.ncunwlab.tk
96.6 ftp.yzu.edu.tw
284 archive.ubuntu.com
看起來是中華電信最快,這時候再用 sed 去替換 sources.list 的來源即可。
sed 's/mirror:\/\/mirrors\.ubuntu\.com\/mirrors\.txt/http:\/\/mirror01\.idc\.hinet\.net\/ubuntu/' /etc/apt/sources.list | sudo tee /etc/apt/sources.list

星期日, 11月 12, 2017

讓套件停留在指定版本,避免升級

公司 gitlab 版本有點舊,搭配的 gitlab runner 得避免使用太新的版本,要不然會無法作用。請 google 幫忙了一下,在 StackOverflow 上找到解答:updates - How to prevent updating of a specific package? - Ask Ubuntu
所以我先使用
sudo apt-get install package_name==the_version
再使用
sudo apt-mark hold package_name
告知 apt 以後不要升級此套件即可。

星期五, 5月 12, 2017

anbox 與 snappy

Anbox 是一個以 container 來摹擬 Android 的技術,如此一來,就可以在 Ubuntu 裡執行 Android app。
按照 Anbox 的說明,得先安裝 snappy,snappy 是 Canonical 推的新的套件機制,軟體以類似 container 的方式安裝進去,不過這個技術推行快兩年了,用的人好像還是不怎麼多。安裝 snappy 的方法很簡單,只要安裝 snapd 就可以了:
sudo apt-get install snapd

安裝 snappy 以後,你還得要先登入 Ubuntu one 的帳號 (用法):
sudo snap login your_email
,之後才能依照 Anbox 的說明,進行安裝:
snap install --classic anbox-installer
。如果不先 login ,snap install 時,會不給安裝。
安裝 anbox-installer 以後,再執行
anbox-installer
就會啟動安裝程序了。
不過我還是安裝失敗了,anbox 說 Ubuntu 14.04 應該是可以安裝,但是實際狀況是有問題,我沒深究,就算了。

星期二, 6月 16, 2015

Build pcmanfm-qt in Ubuntu trusty

Just summary build steps.
First, you need to install these packages: qt5-default, qtchooser, qt5-qmake, appmenu-qt5, qtdeclarative5-dev, qttools5-dev, qttools5-dev-tools, libqt5x11extras5-dev, libglib2.0-dev, libgio2.0-cil-dev, libfm-dev, libmenu-cache-dev
Then clone pcmanfm-qt from https://github.com/lxde/pcmanfm-qt
Enter pcmanfm-qt directory, type: cmake -G "Unix Makefiles", then run: make && make install
After installation, you need to add a file "x86_64-linux-gnu-local.conf" in /etc/ld.so.conf.d and put "/usr/local/lib/x86_64-linux-gnu/" in it.  Run sudo ldconfig to make the setting available.

星期三, 5月 20, 2015

LTS Enablement Stacks - trusty to utopic


要把 trusty 的 kernel 跟 xserver 升級到目前 utopic ,可以參考這篇 Kernel/LTSEnablementStack - Ubuntu Wiki
其 實就是 apt-get install 相關的 package 而已:sudo apt-get install --install-recommends linux-generic-lts-utopic xserver-xorg-lts-utopic libgl1-mesa-glx-lts-utopic libegl1-mesa-drivers-lts-utopic
伺服器版的話,因為沒有 xserver 的牽絆,只要 sudo apt-get install --install-recommends linux-generic-lts-utopic 就可以。
要特別注意的,就是在安裝過程會移除掉某些 package,這裡要特別留意,在安裝前 apt 會有事先提示。以我來說,skype 、google earth 跟 wine 都被移除掉,所以在安裝完重開機以後,要記得把這些軟體裝回去。
這次升級的意外發現是 Google earth 不需要額外處理就有中文顯示了,終於啊...

星期五, 9月 26, 2014

更換 Ubuntu 開機過程的佈景主題

Ubuntu 開機過程其實是可以更換圖片的,甚至已經提供了不少佈景主題可以使用:apt-cache search plymouth-theme
plymouth-theme-ubuntu-logo - graphical boot animation and logger - ubuntu-logo theme
plymouth-theme-ubuntu-text - graphical boot animation and logger - ubuntu-logo theme
mythbuntu-default-settings - default settings for Mythbuntu
plymouth-theme-edubuntu - Plymouth is an application that runs very early
plymouth-theme-fade-in - graphical boot animation and logger - fade-in theme
plymouth-theme-glow - graphical boot animation and logger - glow theme
plymouth-theme-kubuntu-logo - graphical boot animation and logger - kubuntu-logo theme
plymouth-theme-kubuntu-text - graphical boot animation and logger - kubuntu-text theme
plymouth-theme-lubuntu-logo - plymouth theme for Lubuntu
plymouth-theme-lubuntu-text - plymouth text theme for Lubuntu
plymouth-theme-sabily - plymouth theme for Sabily (graphical theme)
plymouth-theme-sabily-text - plymouth theme for Sabily (text theme)
plymouth-theme-script - graphical boot animation and logger - script theme
plymouth-theme-solar - graphical boot animation and logger - solar theme
plymouth-theme-spinfinity - graphical boot animation and logger - spinfinity theme
plymouth-theme-text - graphical boot animation and logger - text theme
plymouth-theme-ubuntu-gnome-logo - graphical boot animation and logger - ubuntu-gnome-logo theme
plymouth-theme-ubuntu-gnome-text - graphical boot animation and logger - ubuntu-gnome-text theme
plymouth-theme-ubuntustudio - Ubuntu Studio Plymouth theme
plymouth-theme-xubuntu-logo - graphical boot animation and logger - xubuntu-logo theme
plymouth-theme-xubuntu-text - graphical boot animation and logger - xubuntu-text theme
你可以使用 apt-get install 來安裝,這些佈景主題會被安裝到 /lib/plymouth/themes/ 目錄下,安裝以後,該如何使用呢? 可以用 update-alternative 來替換,在 terminal 輸入 sudo update-alternative default.plymouth 以後,就可以選擇你喜愛的佈景主題了。
網路上也有人自行去修改 theme,調整字的位置、圖形等等的,用 ubuntu plymouth 去找,就可以找到相關的資訊了。

星期三, 5月 07, 2014

Grub symbol ‘grub_term_highlight_color’ not found

把筆電的 Ubuntu 13.10 升級到 14.04,想不到卻中了招,重開機時,出現 symbol ‘grub_term_highlight_color’ not found 的錯誤。

網路上一找,果然 launchpad 上已經有人回報了,網路上也有不少人分享解法。大致上有兩類解法:
  1. 設法用 livecd/liveusb 重新 chroot 進去,然後用 grub-install 重新安裝 grub
  2. 用 livecd/liveusb 開機,安裝 boot-repair ,利用 boot-repair 來解。

這兩類解法對我都無效,後來是在 launchpad 的那篇裡,看到 downgrade grub ,就想說來試試看。主要的步驟,還是 boot-repair,所以先用 Ubuntu 14.04 的 liveusb 開機,安裝 boot-repair,執行 boot-repair 。boot-repair 的過程裡,會有一些提示,以及需要手動下指令的部份,第一次會是要移除 grub 以及相關的套件;到了第二次時,會要你重新安裝 grub,這邊的指令要改變一下,先裝指定版本的 grub,再執行 boot-repair 提供的指令:sudo apt-get install grub-common=2.00-19ubuntu2 grub-efi-amd64=2.00-19ubuntu2 grub-efi-amd64-bin=2.00-19ubuntu2 grub-efi-amd64-signed=1.22+2.00-19ubuntu2 grub2-common=2.00-19ubuntu2

接著就是讓 boot-repair 做完就可以了。

備註:
  • 如果你不知道有哪些版本可以用,要找某 package 之前的版本,可以用 apt-cache show package | grep Version 來看。
  • 用 LiveCD/LiveUSB 開進去以後,自行掛載並 chroot 的方法,就是先用 sudo parted -l 或 sudo fdisk -l 確認分割區,接著做掛載的動作,大致是這樣 (分割區請自行替換,不要照抄):
    sudo mount /dev/sda5 /mnt
    sudo mount /dev/sda4 /mnt/boot
    sudo mount /dev/sda7 /mnt/home
    for i in /dev /dev/pts /sys /proc /run; do sudo mount --bind $i /mnt$i; done
    sudo chroot /mnt
    hostname your_host
    export HOME=/root

星期四, 4月 03, 2014

debian package 的相依性圖形

找了半天找不到適當的指令顯示套件的相依套件,想起之前無意找到的 apt-cache dotty,就想說用圖形來看套件的相依性還是最快的。

產生圖形的方法:

  • apt-cache:apt-cache 本身就有提供 dotty command 可以產生,用法是 apt-cache dotty your_package > out.dot

  • debtree:debtree 需要另外安裝,好處是有提供更多額外的參數來產生圖形,用法是 debtree your_package > out.dot

接著就可以利用 dot 指令來產生圖形了,dot 是 graphviz 套件提供的指令,可以根據 dot 語法來產生圖形,用法是 dot -T png -o out.png out.dot。用 apt-cache dotty 產生的 dot 語法,會讓 dot 產生圖形的速度變得非常慢;而 debtree 所產生出來的 dot 語法,就不會如此。我猜想是 debtree 有預先排除掉 libc6, libstdc++6 與 zlib1g 的關係吧。

星期日, 3月 02, 2014

systemd

最近 Debian 宣佈以後改用 systemd,Canonical 也隨之跟進,所以之後衍生的 distribution 應該也都會跟進。Arch 是已經改用 systemd 了,CentOS/RHEL 應該是到 7 以後才會可能會用 systemd。

看到這兒就想到目前在用的 Ubuntu 12.04 應該也可以改用 systemd 吧~目前先找到這兩篇:
基本上都是要特定 ppa (上面這兩篇提到的 ppa 還都不同,到時候再來看那邊比較新就用哪個),安裝 systemd 以後,然後改 grub ,大概就這樣。可能遇到的問題是 /etc/mtab 問題以及一些服務可能會無法啟動。從 Ubuntu Wiki 對 systemd 的說明裡 看起來缺的東西不少,我想最好是先拿 VM 的機器來試驗,不要拿工作機來試驗,免得把自己搞得焦頭爛額。

星期二, 2月 11, 2014

extundelete

之前一直以為在 Linux 上反刪除是很麻煩的,直到過年前自己誤刪了檔案,去 Google 解法之後,才知道現在有 extundelete 這工具。
根據 extundelete 的網站說明,在反刪除之前,第一要先卸載,如果是系統分割區,那最好就是趕緊重開機,以 LiveCD 開機;第二就是用 extundelete 進行搜索被刪除的檔案。
我 自己的情況是不小心移除了系統分割區上的檔案,所以我趕緊重新開機以 Ubuntu 12.04 LiveCD 開機。重開機以後,去系統設定裡的 "Software & Updates" ,把 main, universe, restricted, multiverse 都勾選起來,接著到 terminal 裡執行 sudo apt-get udpate && sudo apt-get install extundelete ,安裝 extundelete。安裝完成後,執行 sudo extundelete --restore-all --restore-directory /home/user --after 1390881600 /dev/sda1 就會開始進行反刪除的動作,反刪除後的檔案會放置在當前目錄下的 RECOVERED_FILES 資料夾下。"--after" 表示只拯救指定日期後的檔案,而其後的數字,是用 date -d "2014-01-28 12:00" +%s 取得,extundelete 不接受日期時間字串,只能透過 date 指令取得數字來使用,這部份可以在 extundelete 的 man page 裡看到。
只 是 Ubuntu 12.04 的 extundelete 有問題,我後來再用 Ubuntu 13.10 的 LiveCD,才能正常使用。但最後還是拯救失敗,因為從刪除到重開機,我還是做了太多動作,導致一些檔案已經被覆蓋掉,殘念,只能安慰自己說那些檔案其 實不重要。
參考資料:

星期三, 1月 30, 2013

預載 Windows 8 + Ubuntu 12.10 安裝經驗分享

我的環境:Toshiba Portege R930 + 預載的 Windows 8
身為自由軟體愛好者,當然是要裝上 Ubuntu 來試試看。這次安裝花了不少時間,才摸索出來。
原本打算用 wubi 的,但是看到這篇 AskUbuntu 上的問答 ,就發現用 wubi 是不可行的了。問答的二樓建議不要用 wubi,先在win8挪出分割區,到 BIOS 把secure boot 關掉,開機順序改由live cd/usb 開,然後裝上ubuntu 12.10,裝完開機選單找不到 win8 的話,用ppa:yannubuntu/boot-repair去修,這樣大概就沒啥問題。最後去電源選項改成不要快速關機。
基本上我照著 步驟做了,但是重新開機時,還是 Windows 8 的 boot loader 起來,根本無從選 ubuntu,也沒得用 boot-repair。後來想說,可不可以像 XP 一樣,改 Windows boot loader 的開機選單就行,於是就下載了 EasyBCD 軟體來改,可是還是不行,之後又重新裝了幾次 Ubuntu 都不行。
直到今天早上,今天早上想說還沒有試過 boot-repair,就用 LiveUSB 開機進去,然後安裝 boot-repair 、執行。boot-repair 會偵測環境然後亮出介面,介面上有個 Advanced Options,點進去一看,這設定還真多,當下就又縮回去,不調整,依照原先介面上的建議進行 repair。基本上 repair 的動作是自動的,直到最後才要你開 terminal 打指令,就依樣打完,重開機,GRUB 的選單就出現了。試著開機到 Windows、Linux 都沒問題,大功告成。
詳細步驟:
  1. 進 Windows 8 的磁碟分割,壓縮原來的 C:\ 以取得空間給 Ubuntu 使用。
  2. 關機,按下關機前,先按下 shift,這樣可以確定是真正的關機。
  3. 開機,按 F2 進 BIOS,將 Secure boot 設為 disabled,修改開機順序,改為由 USB 或 CD 開機。
  4. 用 Ubuntu Live USB/CD 開機,開始安裝,我這邊是採取自行分配,不是交給 Ubuntu 幫我分配,我將在步驟 1 切出來的剩餘空間分為: /boot 256MB,/ 40GB,swap 8GB,然後剩下的都給 /home。
  5. 安裝完成,重新開機,會進 Windows 8。依照步驟 2 關機,然後再以 Live USB/CD 開機。
  6. 進 入 Ubuntu 以後,安裝 boot-repair:開啟 terminal,輸入 sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update && sudo apt-get install boot-repair -y
  7. 安裝完成以後,執行 boot-repair,我是直接按下上面那個按鈕,也就是依照 boot-repair 的建議進行修復。
  8. 重新開機,大功告成。
參考資料:
  • Ubuntu Document - UEFI