0%

Kubuntu使用指南

概述

  • 由于 Manjaro 的一些问题,当前使用 Kubuntu.

常识

snap

snap:Canonical 公司发布的全新软件包管理方式,一个容器拥有一个应用程序所有的文件和库,解决了应用程序之间的依赖问题,更容易管理,but,会占用更多的磁盘空间

1
2
3
4
5
6
7
8
9
sudo snap list
sudo snap find {pkg_name} # 搜索要安装的包
sudo snap install {pkg_name}
sudo snap refresh {pkg_name} # 不加包名则更新所有包
sudo snap revert {pkg_name} # 将一个包还原到以前安装的版本
sudo snap remove {pkg_name} # 删除一个snap
d
root / var / snap.
snap changes # 查询最近做的操作

dpkg

dpkg:package manager for Debian:Debian 和基于 Debian 的系统中一个主要的包管理工具,用来安装、构建、卸载、管理 deb 格式的软件包。

  • dpkg:主要用来安装已下载到本地的 deb 软件包,或对已经安装好的软件进行管理
  • apt:类似红帽系的 yum,能自行解决

汉化

  • 有些地方还是英文 ,强迫症不能忍

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    # 安装中文语言包
    sudo apt-get install language-pack-zh-han*
    # 运行语言支持检查
    sudo apt install $(check-language-support)
    # 修改配置文件
    vim /etc/default/locale
    # 替换为
    LANG="zh_CN.UTF-8"
    LANGUAGE="zh_CN:zh"
    LC_NUMERIC="zh_CN"
    LC_TIME="zh_CN"
    LC_MONETARY="zh_CN"
    LC_PAPER="zh_CN"
    LC_NAME="zh_CN"
    LC_ADDRESS="zh_CN"
    LC_TELEPHONE="zh_CN"
    LC_MEASUREMENT="zh_CN"
    LC_IDENTIFICATION="zh_CN"
    LC_ALL="zh_CN.UTF-8"


    # 再改
    sudo vim /etc/environment
    # 在最后一行后再开一行,加入
    LANG="zh_CN.UTF-8"
    LANGUAGE="zh_CN:zh"
    LC_NUMERIC="zh_CN"
    LC_TIME="zh_CN"
    LC_MONETARY="zh_CN"
    LC_PAPER="zh_CN"
    LC_NAME="zh_CN"
    LC_ADDRESS="zh_CN"
    LC_TELEPHONE="zh_CN"
    LC_MEASUREMENT="zh_CN"
    LC_IDENTIFICATION="zh_CN"
    LC_ALL="zh_CN.UTF-8"

    # 再改
    sudo vim /etc/profile

    sudo locale-gen zh_CN.UTF-8

选择源

  • 打开 清华镜像源 官网,在搜索框中,输入 Ubuntu,窗口紧接着会筛选出关于 Ubuntu 的链接
  • 在筛选出来的链接中,会发现链接 Ubuntu 右上方有个 ?,点击它
  • 在选择你的 ubuntu 版本一栏,根据你的 Ubuntu 系统进行选择,同时下方会输出需要配置的镜像源链接列表

常用操作

虚拟机

  • 菜单:点击 安装增强功能
1
2
3
4
5
sudo ./VBoxLinuxAdditions.run
sudo reboot now

# 安装虚拟机自动缩放显卡驱动
sudo apt install open-vm-tools-desktop -y

更新

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 更新本地包数据库
sudo apt update

# 更新所有已安装的包(也可以使用 full-upgrade)
sudo apt upgrade

# 自动移除不需要的包
sudo apt autoremove

# 清除安装时下载到/var/cache/apt/archives中的.deb中的过期的包
sudo apt autoclean
sudo apt clean # =rm /var/cache/archives/*.deb

sudo apt autoremove: 删除为了满足其他软件包的依赖而安装,但现在不再需要的软件包;
# 此时dpkg的列表中有“rc”状态的软件包,可以执行如下命令做最后清理:
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
sudo apt remove [软件包名]: 删除已安装的软件包(保留配置文件);
sudo apt --purge remove [软件包名]: 删除已安装包(不保留配置文件)。

xmind
迅雷 xware desktop
teamviewer
Openshot Video Editor
kdenlive
audacity

proxyee-down
todesk
Fsearch

fcitx

添加五笔拼音输入法

1
sudo apt install fcitx-table-wbpy
  • fcitx 是默认四码唯一自动上屏,不喜欢,改 /usr/share/fcitx/table/wbpy.conf
1
AutoSend=0

nodejs

1
2
3
4
5
6
7
8
sudo apt install nodejs
node -v
# v10.19.0

sudo apt install npm
# 下载了286个包?laji吧
npm -v
# 6.14.4

其他向后移植 PPA

请注意,另外的向后移植 PPA ppa:kubuntu-ppa/backports 目前提供的是 Plasma 5.24。因此,请勿使用与上面不同的 PPA。我不确定这个 PPA 是否会得到更新。

1
sudo add-apt-repository ppa:kubuntu-ppa/backports // 不要使用这个

如何卸载

在任何时候,如果你想回到 KDE Plasma 桌面的原始版本,那么你可以安装 ppa-purge 并删除该 PPA,然后刷新包。

打开终端,依次执行以下命令:

1
2
3
sudo apt install ppa-purge
sudo ppa-purge ppa:kubuntu-ppa/backports-extra
sudo apt update

完成上述命令后,重启系统。

todo

Redis

Redis - ArchWiki

1
2
3
4
sudo pacman -S redis
# redis_version:6.2.5:20210920
sudo systemctl start redis
sudo systemctl enable redis

supervisor

Supervisor:用 Python 开发的一套通用的进程管理程序,能将一个普通的命令行进程变成后台 daemon,并监控进程状态,异常退出时能自动重启

  • 通过 fork/exec 的方式将被管理的进程当作 supervisor 的子进程来启动
1
sudo pacman -S supervisor
  • supervisor 不能监控后台进程,commond 不能为后台运行命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sudo vi /etc/supervisord.d/testconf

[program:test]
directory=/home/user_name/test
command=/usr/bin/python /home/user_name/test/test.py # 程序启动命令
autostart=true # supervisord 启动时自动启动
autorestart=true # 程序挂掉时自动重启
startsecs=10 # 启动 10s 后,此时仍在 running,则认为启动成功了
stopasgroup=true #
ikillasgroup=true
startretries=1
redirect_stderr=true
#stdout 日志文件大小,默认 50MB
stdout_logfile_maxbytes = 20M
#stdout 日志文件备份数
stdout_logfile_backups = 20
stderr_logfile=/tmp/blog_stderr.log
stdout_logfile=/tmp/blog_stdout.log
redirect_stderr=true # 把 stderr 重定向到 stdout,默认 false
user=user_name # 脚本运行的用户
1
2
3
4
5
6
7
# 常用命令
supervisorctl status # 查看所有进程的状态
supervisorctl stop test # 停止 test,或 all 表示所有
supervisorctl start test # 启动 test
supervisorctl restart test # 重启 tess
supervisorctl update # 配置文件修改后可以使用该命令加载新的配置
supervisorctl reload: # 重新启动配置中的所有程序

Docker

1
2
sudo pacman -S docker
sudo pacman -S docker-compose

关闭服务

必要的服务

查看启动服务

1
systemctl list-unit-files --type=service | grep enabled

关闭不必要的服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# bluetooth.service:
sudo systemctl stop bluetooth.service
sudo systemctl disable bluetooth.service

# # ModemManager.service 该服务是一个被 dbus 激活的守护进程,用于提供移动宽频 broadband(2G/3G/4G)接口,如果你没有该接口,无论是内置接口,还是通过如蓝牙配对的电话,以及 USB 适配器,那么你也无需该服务。
sudo systemctl stop ModemManager.service
sudo systemctl disable ModemManager.service

# avahi-daemon.service 用于零配置网络发现,使电脑超容易发现网络中打印机或其他的主机,我总是禁用它,别漏掉它。
sudo systemctl stop avahi-daemon.service
Warning: Stopping avahi-daemon.service, but it can still be activated by: avahi-daemon.socket

sudo systemctl status avahi-daemon.service
Job for avahi-daemon.service canceled.

sudo systemctl disable avahi-daemon.service

sudo systemctl status avahi-daemon.socket
sudo systemctl stop avahi-daemon.socket
sudo systemctl disable avahi-daemon.socket

sudo
sudo systemctl stop org.cups.cupsd.service
sudo systemctl disable org.cups.cupsd.service

环境变量

1
2
3
4
5
6
7
8
9
10
11
alias update='sudo pacman -Syyu'  
alias py='python3'
alias python='python3'
alias vi='vim'
alias python=python3
alias pip=pip3
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk"
export PATH=$JAVA_HOME/bin:$PATH

export NEO4J_HOME=/opt/neo4j/
export PATH=$PATH:$NEO4J_HOME/bin/

WPS

1
wget https://wdl1.cache.wps.cn/wps/download/ep/Linux2019/10702/wps-office_11.1.0.10702_amd64.deb
  • 字体缺失问题:
    • 下载字体包,https://pan.baidu.com/s/1d2h2khml3wAu1phOLcmR-w 提取码:n5m3

    • 将里面的字体加入到目录/usr/share/fonts/wps-office

      1
      2
      3
      4
      5
      sudo mkdir /usr/share/fonts/wps-office
      sudo cp -r wps_symbol_fonts.zip /usr/share/fonts/wps-office
      cd /usr/share/fonts/wps-office
      sudo unzip wps_symbol_fonts.zip
      sudo rm -r wps_symbol_fonts.zip

nvidia

  • ubuntu softwares - Software & Updates - Additional Drivers
  • 选择第一个(proprietary, tested),Ubuntu 测试过的
1
2
3
4
5
6
7
8
9
10
11
lsmod | grep nvidia
nvidia-smi

# 挂载驱动
modprobe nvidia-smi


# 命令行查看需要装的
ubuntu-drivers devices

sudo ubuntu-drivers autoinstall
  • Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later
    • NO
  • Nvidia’s 32-bit compatibility libraries?
    • NO
  • Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up
    • YES

驱动卸载

1
2
3
4
5
sudo apt --purge remove nvidia*
sudo apt autoremove

# 卸载cuda
sudo apt-get --purge remove "*cublas*" "cuda*"

PyTorch

  • 不用安装 cuda,PyTorch 内部已集成
1
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu118

后台服务管理

1
sudo apt install supervisor

遇到的问题

换源后 Certificate verification failed: The certificate is NOT trusted.

1
2
3
4
5
6
# 1、换源,粘贴或者更改源,并将新增的 https:// 改  http://)
apt update
apt install ca-certificates

看到有的文章将源改为http便无下文,建议继续执行以下步骤改回https,使用http将大幅度提高网络风险)

系统进入时的 30s 等待

1
2
3
4
5
# vi /etc/default/grub,在最后添加
GRUB_RECORDFAIL_TIMEOUT=0

# 然后
sudo update-grub # 更新boot/grub/grub.cfg

无网络 Ubuntu 安装软件

  • 难点:软件包一般会有很多依赖项、依赖套依赖
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo apt install --download-only {package_name}
# 文件会下载在 /var/cache/apt/archives
# 安装之
sudo dpkg -i *


# 需要将依赖包一起下载,需要:
sudo apt install apt-rdepends
# 下载包
apt download $(apt-rdepends {package_name} | grep -v "^ ")

# 若报错:E: Can't select candidate version from package debconf-2.0 as it has no candidate

# 使用
apt-get download $(apt-rdepends vim | grep -v "^ " | sed 's/debconf-2.0/debconf/g')
1
2
3
4
5
6
7
8
9
# 显示包的所有依赖项列表
sudo apt-cache depends python

# 下载 包以及所需的所有依赖项
for i in $(apt-cache depends python | grep -E 'Depends|Recommends|Suggests' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/); do sudo apt-get download $i 2>>errors.txt; done

# 安装
sudo dpkg -i *

双系统下时间不同步

  • 因为 windows 与 ubuntu 更新 BIOS 时间时的做法不用,Windows 是直接设,Ubuntu 把 BIOS 看作 UTC 时间
1
2
3
4
5
# 查看
timedatectl status

# 设置
timedatectl set-local-rtc 1

ACPI BIOS Error(bug):Could not resolve symbol

  • 原因:
  • 解决方案:
给博主来一杯卡布奇诺