自由學習的風

幽夢影 張潮 少年讀書,如隙中窺月;中年讀書,如庭中望月;老年讀書,如臺上玩月。皆以閱歷之淺深,為所得之淺深耳。
顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

[Ubuntu] 清除 broken 和 residual package

2021年1月31日 星期日

在 debian/ubuntu/mint  安裝或移除套件時,幾乎都是利用 apt 這支程式來處理。

但是有時候安裝失敗時、或是未完全移除時(--purge),就會有套件變得不完全。

residual package 用  dpkg -l 列出來時,會在開頭出現 rc 的字符,而 broken package  則會在開頭出現 iU 的字符,我們可以用下列的指令來篩選出來:

dpkg -l |grep "^rc" 

dpkg -l |grep "^iU"








我們可以下達 apt purge [package name] 的指令來徹底移除它,不過,如果類似的套件很多,就是件折磨人的事了,不過,linux 的好處就可以自己隨意組合指令來符合自己的需求,搭配 awk 把套件名稱撈出來,再丟給 apt 來移除,方便又省事!

sudo apt purge $(dpkg -l |grep "^rc" | awk '{print $2}')

[Ubuntu] 單網卡綁多個網段的IP

2021年1月19日 星期二

Ubuntu Server 20.04 安裝在 ESXi 伺服器之後的問題

2020年12月21日 星期一

問題1: themald error:




無法載入 thermal-conf.xml,網路上的解法,可照下列步驟處理:
1. 開啟 vSphere Client。
2. 找到虛擬機/編輯虛擬機器設定。
3. 選項/進階/一般 ,點擊【組態參數】

4. 點擊【新增列】,名稱輸入「disk.EnableUUID」,值為「TRUE」。


5. 點擊【確定】後,啟動虛擬機即可。

systemd 和 upstart 啟用和停用

2018年8月13日 星期一

參考: https://askubuntu.com/questions/19320/how-to-enable-or-disable-services
-----------------------------------------------------------------------------------------------------------------------

Temporary enabling/disabling services

To stop and start services temporarily (Does not enable / disable them for future boots), you can type service SERVICE_NAME. For example:
  • sudo service apache2 stop (Will STOP the Apache service until Reboot or until you start it again).
  • sudo service apache2 start (Will START the Apache service assuming it was stopped before.).
  • service apache2 status (Will tell you the STATUS of the service, if it is either enabled/running of disabled/NOT running.).
  • sudo service apache2 restart (Will RESTART the service. This is most commonly used when you have changed, a config file. In this case, if you changed either a PHP configuration or an Apache configuration. Restart will save you from having to stop/start with 2 command lines)
  • service apache2 (In this case, since you did not mention the ACTION to execute for the service, it will show you all options available for that specific service.) This aspect varies depending on the service, for example, with MySQL it would only mention that it is missing a parameter. For other services like networking service it would mention the small list of all options available.

SYSTEMD

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:
systemctl start SERVICE - Use it to start a service. Does not persist after reboot
systemctl stop SERVICE - Use it to stop a service. Does not persist after reboot
systemctl restart SERVICE - Use it to restart a service
systemctl reload SERVICE - If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.
systemctl status SERVICE - Shows the status of a service. Tells whether a service is currently running.
systemctl enable SERVICE - Turns the service on, on the next reboot or on the next start event. It persists after reboot.
systemctl disable SERVICE - Turns the service off on the next reboot or on the next stop event. It persists after reboot.
systemctl is-enabled SERVICE - Check if a service is currently configured to start or not on the next reboot.
systemctl is-active SERVICE - Check if a service is currently active.
systemctl show SERVICE - Show all the information about the service.
sudo systemctl mask SERVICE - Completely disable a service by linking it to /dev/null; you cannot start the service manually or enable the service.
sudo systemctl unmask SERVICE - Removes the link to /dev/null and restores the ability to enable and or manually start the service.

UPSTART (Deprecated Since 15.04)

If we want to use the official Upstart way (Note that, for the moment, not all services have been converted to Upstart), we could use the following commands:
status SERVICE - This will tell us if a converted service is running or not. Note that this is deprecated in favor of startstopstatus & restart. It will also tell us if a service has not yet been converted to upstart:
A converted service would typically output the current status (Starting, Running, Stopping...) and process ID. A non converted service would give an error about an unknown job.
Some shortcuts may only work with the service command above but not with the commands below unless they are 100% converted to upstart services:
  • START - sudo start mysql
  • STOP - sudo stop mysql
  • RESTART - sudo restart mysql
  • STATUS - sudo status smbd

Enabling / Disabling a service

To toggle a service from starting or stopping permanently you would need to:
echo manual | sudo tee /etc/init/SERVICE.override
where the stanza manual will stop Upstart from automatically loading the service on next boot. Any service with the .override ending will take precedence over the original service file. You will only be able to start the service manually afterwards. If you do not want this then simply delete the .override. For example:
echo manual | sudo tee /etc/init/mysql.override
Will put the MySQL service into manual mode. If you do not want this, afterwards you can simply do
sudo rm /etc/init/mysql.override
and Reboot for the service to start automatically again. Of course to enable a service, the most common way is by installing it. If you install Apache, Nginx, MySQL or others, they automatically start upon finishing installation and will start every time the computer boots. Disabling, as mentioned above, will make use of the service manual.

lftp 下載/上傳整個目錄

2018年4月23日 星期一

lftp 比 ftp 方便多了,特別當需要上傳或下載整個目錄時,特別方便。
下載整個目錄   mirror  <dir_name>
上傳整個目錄   mirror  -R  <local_dir_name>

lftp 連上後無法顯示目錄檔案

在 Ubuntu 16.04 上安裝  lftp 程式,連上 ftp 站台後無法顯示目錄檔案。
出現的錯誤訊息為:
Fatal error: Certificate verification: Not trusted
解決方法為:
編輯  /etc/lftp.conf 檔案
在檔案結尾加上 下列指令,重新連上就可以正常顯示了。
set ssl:verify-certificate no

[Ubuntu] Apache2 虛擬網頁置於非預設網站目錄

2018年4月5日 星期四

虛擬網站目錄若不是放在預設的 www 目錄下,就會出現  forbidden 無法瀏覽的訊息。只要增加 該目錄的的區段設定,就可以正常瀏覽了

例:  testsite 放在 /opt 底下

        DocumentRoot /opt/testsite
        <Directory /opt/testsite/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all granted
        </Directory>



[Ubuntu] Apache2 設定監聽 port


情境1:監聽 8000 port,網站目錄置於 /var/www/html/testsite
方式:
  1.增加監聽 port    /etc/apache2/ports.conf
  2. 新增網站設定檔  testsite.conf
/etc/apache2/sites-available# cp  000-default.conf   testsite.conf

    #  a2ensite   testsite
    #  systemctl   restart   apache2.service


[Ubuntu] Google Chromecast 突然無法在chrome 瀏覽器上播放

2018年2月4日 星期日

適用 chrome 55 以後版本


  • 在網址列上輸入 「chrome://flags/#media-router」
  • 將 「Default」 改為 「Disable」
  • 重新啟動  Google Chrome

[Ubuntu] 單網卡多個IP

2018年1月17日 星期三

1. 臨時性
sudo ip address add <ip-address>/<netmask> dev <interface>
例:
sudo ip address add 10.231.141.231/24 dev eth0

2. 永久性 /etc/network/interfaces
iface eth0 dhcp
iface eth0 inet static
    address 10.231.141.231/24
iface eth0 inet static
    address 10.241.141.231/24

重新啟動
sudo ifdown eth0 && sudo ifup eth0

補充:The iproute2 suite:
The iproute2 suite is the communication suite for interprocess communication beween the kernel and the user space via the netlink protocol. It should replace the whole standard network tools. Here is what they replace:
  • ifconfig --> ip addr and ip link
  • route --> ip route
  • arp --> ip neigh
  • iptunnel --> ip tunnel
  • ipmaddr --> ip maddr
  • netstat --> ss

[Ubuntu] 系統更新或安裝新套件時,一直提示 click 失敗無法執行

2017年7月7日 星期五

家裡的系統是 Ubuntu 14.04,前兩個禮拜開始更新檔案或安裝新套件時,一直出現要先做 「 sudo apt-get -f install 」修改未完成的安裝動作。
仔細看了之後發現是有支 package  「click」無法執行,手動執行「 click」指令時,則會出現下列的錯誤訊息:
Traceback (most recent call last):
  File "/usr/bin/click", line 37, in <module>
    import click
ImportError: No module named 'click'
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Traceback (most recent call last):
  File "/usr/bin/click", line 37, in <module>
    import click
ImportError: No module named 'click'
無法強制將它remove,用 「easy_install  click」 或 「easy_install3 click」也沒有用,雖然還是可以操作,但是整個系統就像 freeze 住了,無法更新,也無法安裝新的套件,直到前天晚上才又在 askubuntu 上看到一篇文章,雖然原PO 作者的系統是 17.04,不過,跟著步驟做了一遍,整個套件管理總算正常了。把記錄下來,免得下次遇到時又得找半天
cd /var/lib/dpkg/info/
sudo rm -r python3-apparmor-click.*
sudo rm -r click-apparmor.*
sudo rm -r click.*
sudo rm -r ubuntu-app-launch.* 
sudo apt purge python3-apparmor-click
sudo apt purge click-apparmor    
sudo apt purge click
sudo apt purge ubuntu-app-launch
sudo apt update
sudo apt-get -f install
sudo apt-get dist-upgrade
感謝網路,讚美 Google!

[ubuntu] 解決 Chrome / Chromium 開啟後會閃礫的問題

2017年6月3日 星期六


$ sudo  nano  /usr/share/X11/xorg.conf.d/20-intel.conf
        Section "Device"
           Identifier  "Intel Graphics"
           Driver      "intel"
           Option      "AccelMethod"  "sna"
           Option      "TearFree"    "true"
           Option      "DRI"    "3"
        EndSection

存檔後重新啟動,狀況會改善!

[Ubuntu] 設定 scratch2 檔案關聯

2016年12月30日 星期五



資料來源:https://scratch.mit.edu/discuss/topic/187916/


1. define .sb2 file's type

sudo vi /usr/share/mime/package/***.xml

*** is new file's name. Set is as you like. ex)scratch2

write text below in the file




<?xml version=“1.0” encoding=“UTF-8”?>

<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info“>

<mime-type type=”application/x-scratch2“>

<comment></comment>

<glob pattern=”*.sb2“/>

</mime-type>

</mime-info>




2. associate .sb2 file with scratch 2 application

Find ”edu.media.mit.scratch2editor.desktop" file under directory of /usr/share/applications/ ,

and add only one line in the last line of that desktop file.

MimeType=application/x-scratch2




3. update
sudo update-desktop-databese
sudo update-mime-database

4. change sb2 file's icon
sudo cp /opt/Scratch\ 2/share/icons/ProjectIcon48.png /usr/share/icons/gnome/scalable/mimetypes/application-x-scratch2.png

(參考:http://wiki.ubuntu.com.cn/UbuntuHelp:AddingMimeTypes)

5. 更新圖示cache
sudo gtk-update-icon-cache  /usr/share/icons/gnome/ -f

4. reboot PC




Linux 軟體套件格式 - Flatpak, Appimage And Snap – How Do They Stack?

2016年12月13日 星期二

Flatpak, Appimage And Snap – How Do They Stack?

原文網址:http://news.tecmint.com/flatpak-appimage-and-snap-how-do-they-stack/



相關網址:

Ubuntu 移除不需要的語系

2016年12月9日 星期五

列出目前的語系

locale -a
or
localedef --list-archive

移除不需要的語系

sudo locale-gen --purge en_US.UTF-8 zh_TW.UTF-8 && echo Success



Ubuntu 裝在 SSD 硬碟的注意事項

2016年10月30日 星期日

1. 寫入磁碟極少化 (也是最重要的一點)
在/etc/fstab 裡加入nodiratimenoatime

2. 啟用 TRIM 功能
在 /etc/cron.weekly/fstrim 裡加入 exec fstrim-all --no-model-check

如何在 shell 中產生 urlencode 字串

2016年9月25日 星期日

從 stack overflow 找到的技法,超讚的,一行解決。

設定
$ alias urldecode='python -c "import sys, urllib as ul; \
    print ul.unquote_plus(sys.argv[1])"'

$ alias urlencode='python -c "import sys, urllib as ul; \
    print ul.quote_plus(sys.argv[1])"'
使用
$ urlencode 'file:///media/bob/MyUSB/我的資料夾'
file%3A%2F%2F%2Fmedia%2Fbob%2FMyUSB%2F%E6%88%91%E7%9A%84%E8%B3%87%E6%96%99%E5%A4%BE

kickstart 參考

2016年7月15日 星期五

Ubuntu 安裝的預設或自動安裝的相關設定…

Ubuntu 16.04 把網卡名稱改為舊的命名方式( eth0...)

2016年6月6日 星期一

最近測試 Ubuntu 16.04 LTS 之後才發現,網卡的命名方式改了,不過,好像從  15.10 就開始了,不過,實在不太習慣這種方式,找了一下資料,還是把它改回來。

1. 修改 /etc/default/grub
$ sudo nano /etc/default/grub
找到「GRUB_CMDLINE_LINUX=""」,加入參數「net.ifnames=0  biosdevname=0




2. 產生新的 grub.cfg 開機設定檔
$ sudo grub-mkconfig -o /boot/grub/grub.cfg

3. 如果網路是走 DHCP 的話,直接重新啟動電腦,應該網卡代號就會變回原來 eth0 的樣子.




4. 如果是走靜態 IP 的話,重新開機前還要去 /etc/network/interfaces 將原本的網卡代號改成 eth0