# ubuntu 疑難雜症 ###### tags: `note` ubuntu 雖然算是最親民的 linux distrubition 了,但是事實上她仍然時不時會出現一些奇奇怪怪的小問題。 因此在這紀錄一下一些相關快速解決問題的方案。 > Note: 以下方法在 ubuntu 20 中自己實測能成功,並沒有做其餘的驗證。 > kernel version: 5.15.xx ![](https://i.imgur.com/hRVQpla.png =x300) --- ## HELP! my UI is freezing - 恐慌程度: 高 #### Problem: - 症狀: UI 突然凍結,但是電腦似乎仍然在運作(像是音樂仍在撥放) #### solution: 1. `ctrl + alt + f3` to get to the console 2. 輸入 `sudo systemctl restart gdm` 重啟 UI system 3. PRAY for the linux god's blessing --- ## The “initramfs” error #### Problem - 恐慌程度: 超高 - 症狀: 重新開機後,無法進入正常開機畫面,而是出現 console 介面,上面說記憶體出錯需要用 `initramfs` - solution 1 - 1. 注意錯誤訊息內容,如果是 `xxx disk need manule fsck` 就用它上面的硬碟編號 - 2. `(initramfs) fsck [partitian name (/dev/sdXX)] -y` - 3. reboot - solution 2 - 1. `(initramfs) df -h` 查看目前硬碟編號 - 2. `(initramfs) fsck [partitian name (/dev/sdXX)] -y` 用fsck 修復目標硬碟(你裝 ubuntu 的那個硬碟編號) - 3. `(initramfs) reboot` reboot - 4. 祈禱她會成功,如果不成功... 我也不知道該怎麼辦 - [reference](https://linuxhint.com/fix-initramfs-ubuntu/) --- ## apt error #### Problem - 問題程度: 我 apt 突然不會動 - apt spit out some errors like this ``` Errors were encountered while processing: /var/cache/apt/archives/libldacbt-enc2_2.0.2.3+git20200429+ed310a0-5_amd64.deb /var/cache/apt/archives/libldacbt-abr2_2.0.2.3+git20200429+ed310a0-5_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) ``` #### Solution Just force overwirte these fucking troublesome caches ``` sudo dpkg -i --force-overwrite /var/cache/apt/archives/python-problem-report_2.0.1-0ubuntu9_all.deb sudo apt install -f sudo apt clean ``` --- ## Gnome text randomly disappear - 煩躁程度: 高 - 症狀: UI 上的文字隨機的消失 ==TODO: 補圖== - solution: - 1. `alt + f2` 開啟快速指令介面 - 2. `r` 輸入 r,然後 enter - 3. BOOOM! 好了 --- ## Large /var/log/syslog - 問題程度: 我的硬碟容量阿 - 症狀: `/var/log/syslog` 很大而且裡面都是垃圾(先確認垃圾產生原因再刪除) - solution - `sudo echo "" > /var/log/syslog` ##### 題外話 引起我這次問題的人是 discord ``` Snaps are confined, as such Discord may be unable to perform some of the tasks it typically does when unconfined. This may result in the system log getting spammed with apparmor errors. Granting access to the system-observe interface when in the snap will enable the features, and thus reduce the logging. snap connect discord:system-observe This snap is maintained by the Snapcrafters community, and is not necessarily endorsed or officially maintained by the upstream developers ``` #### 相關聯: Discord `colord` warning - discord 發出大量與 `colord` 相關的 warning 塞爆 `/var/log/syslog` - solution - `sudo apt install snmp-mibs-downloader` - `sudo systemctl restart colord` - [reference](https://askubuntu.com/questions/1102926/colord-errors-in-var-log-syslog-in-18-10) --- ## High Resolution Problem #### Problem: 雖然大部分 app 在 ubuntu 設定 scalling 後就會表現正常,但是部分 app 的解析度是寫死的所以在高解析度(2k up)下會變得超小. (e.g. Spotify) #### Solution: force them scale up when start up ```bash= spotify --force-device-scale-factor=2 ``` ```bash # or edit this file nvim /usr/share/applications/spotify.desktop # or this file (if you install this app with snap) nvim /var/lib/snapd/desktop/applications/spotify_spotify.desktop #### # Replace: Exec=spotify %U # With: Exec=spotify --force-device-scale-factor=2.0 %U ``` ``` # for steam at file: 'sudo nvim /usr/share/applications/steam.desktop' Exec=sh -c 'GDK_SCALE=2 /usr/games/steam %U' ``` --- ## ubuntu didn't recognize the monitor 通常是因為 nvidia driver 跑掉了 重裝一次並 reboot 應該就 OK 了 ``` sudo add-apt-repository ppa:graphics-drivers/ppa # add repo to apt-repo sudo apt-get install ubuntu-drivers ubuntu-drivers list # check the versions sudo apt-get install nvidia-driver-450 # 2020/09/26 # this may works too sudo ubuntu-drivers autoinstall ``` ### nvidia 工具 ``` nvidia-smi nvidia-prime ``` ### nvidia-open-source-version (525.60.11) https://askubuntu.com/questions/1392507/nvidia-driver-broken-on-update-unable-to-reinstall - [install nvidia-open](https://hackmd.io/@cccccs100203/linux2022-nvidia-open-gpu) - [github](https://github.com/NVIDIA/open-gpu-kernel-modules) > after using check back and forth > dkms, modprobe --- ## Ubuntu canno't play audio > sound 有時設定那邊沒辦法出現正確的 audio option 通常重起 system deamon 就 OK 了 ```bash systemctl --user restart pipewire pipewire-pulse ``` > 注:在 Ubuntu 20.04 中預設的 audio deamon 是 `pulseaudio`,筆者自行將自己的預設改成了 pipwire --- ## Spotify cannot exit fullscreen mode #### Problem 在某次我換螢幕環境的時候發生了,不清楚詳細為什麼。 總之按照以下作法就 ok 了。 #### solution 1. Close Spotify app 2. input command (modify the config file of spotify) ``` sed -i "/\b\(app.window.position\)\b/d" -- $HOME/snap/spotify/current/.config/spotify/prefs ``` 3. Open Spotify > [source](https://askubuntu.com/questions/1200000/cannot-exit-fullscreen-on-spotify) --- ## IntelliJ IDE behave strange #### Problem: IntelliJ IDE 怪怪的 (我也忘記當初是哪裡怪了 好像是設定解析度沒反應 #### Solution: 去按這個去重啟她 ``` File -> Invalidate Caches/Restart ``` --- ## ufw seems not working #### Problem: ubuntu 內建防火牆工具 `ufw` 在與 docker 共同作用下,可能會沒有用。因為 docker 內部實現 port mapping 的方式是自行修改 `iptables`,而 `ufw` 的功能也是去修改 `iptables`。因此兩者的設定可能會出現衝突。 例如: 在 docker 中設定某 container port 80 mapping 至本機 80 port,然後在 `ufw` 中設定 block 80 port。但是很有可能 ufw 無法實際 block 80 port 的封包,因為 docker 自行設定的 `iptables` 規則可能位於 ufw 設定的 block 規則之上 sometimes ufw may not able to deny the port which a docker container is using. because both docker and ufw impelement their functions by rewriting the `iptables`, thus the rule ufw made may not going above the rule which docker made. [reference from a stackoverflow ans](https://askubuntu.com/questions/652556/uncomplicated-firewall-ufw-is-not-blocking-anything-when-using-docker) --- ## Davinci resolve cannot import vid Linux 版的免費版的 davinci resolve 不支援部份編碼,可以透過底下的 script 去做編碼轉換 > 需要先安裝 `sudo apt-get install ffmpeg` > 它會將當前位置的所有 `.mp4` 檔轉換成 `.mov` 在 `transcoded` 資料夾裡 ```bash mkdir transcoded for i in *.mp4 do ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "tra nscoded/${i%.*}.mov" done ``` --- ## VirtualBox redraw problem - 問題程度:媽的用不了 VirtualBox - solution: 關閉 Fractional Scaling in Setting->Display VirtualBox 的 GUI 在 ubuntu 中很有問題,在使用 fractional Scaling 時,甚至他的 redraw 完全炸開 #### solution 去用 qemu/kvm --- ### ??? https://blog.csdn.net/qxqxqzzz/article/details/112025423 https://askubuntu.com/questions/1189835/the-initramfs-will-attempt-to-resume-from-dev-dm-1