Skip to content

Ubuntu玩机笔记

键盘Fn无法切换功能键与多媒体键

终端输入:

bash
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

然后再长按 Fn+X+L 约四秒即可成功使用Fn切换功能键与多媒体键。

永久生效

以上方法只是输入命令后生效,想要永久生效,可以进行如下操作:

  1. 创建/etc/modprobe.d/hid_apple.conf文件
  2. 在文件中添加以下一行内容并保存:options hid_apple fnmode=0
  3. 执行如下命令:sudo update-initramfs -u
  4. 重启

保持Typore旧版本,不自动更新。

shell
sudo apt-mark hold typora

使用V2rayA

v2rayA 提供的镜像脚本(推荐)

shell
curl -Ls https://mirrors.v2raya.org/go.sh | sudo bash
sudo systemctl disable v2ray --now

添加公钥

shell
wget -qO - https://apt.v2raya.org/key/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/v2raya.asc

添加 V2RayA 软件源

shell
echo "deb https://apt.v2raya.org/ v2raya main" | sudo tee /etc/apt/sources.list.d/v2raya.list
sudo apt update

安装 V2RayA

shell
sudo apt install v2raya

安装 V2Ray 内核

shell
curl -Ls https://mirrors.v2raya.org/go.sh | sudo bash

安装后关掉服务,因为 v2rayA 不依赖于该 systemd 服务

shell
sudo systemctl disable v2ray --now ### Xray 需要替换服务为 xray

安装 v2rayA

curl -Ls https://mirrors.v2raya.org/go.sh | sudo bash

添加公钥

shell
wget -qO - https://apt.v2raya.mzz.pub/key/public-key.asc | sudo apt-key add -

添加 V2RayA 软件源

shell
echo "deb https://apt.v2raya.mzz.pub/ v2raya main" | sudo tee /etc/apt/sources.list.d/v2raya.list
sudo apt update

安装 V2RayA

shell
sudo apt install v2raya

启动:

启动 v2rayA

shell
sudo systemctl start v2raya.service

设置开机自动启动

shell
sudo systemctl enable v2raya.service

设置

http://localhost:2017 访问 UI 界面。

点击导入,将地址粘贴

image-20230115180628752

更新订阅后点击出现的订阅

image-20230115180702387

选择节点(右侧选择按钮,可以选多个)后点击启动

image-20230115180855652

选中节点变成蓝色后,即启动成功

再修改下设置

image-202130223101745832

修改日期显示为英文

打开终端,输入

shell
sudo vim /etc/default/locale
# 添加
LC_TIME="en_US.UTF-8"

Picgo

shell
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install v12
npm install picgo -g
picgo set uploader

输入配置后

shell
picgo use uploader

最终配置文件

json
{
  "picBed": {
    "uploader": "aliyun",
    "current": "aliyun",
    "aliyun": {
      "accessKeyId": "LTAI5tQYhCCpCQL2MH1byCgs",
      "accessKeySecret": "AZcvek0IPiWuNvtQPVwz6iGeAupMoC",
      "bucket": "gettler-images",
      "area": "oss-cn-beijing",
      "path": "images/",
      "customUrl": "",
      "options": ""
    },
    "transformer": "path"
  },
  "picgoPlugins": {}
}

输入法

shell
sudo apt-get install fcitx-bin
sudo apt-get install fcitx-table
shell
sudo apt-get install fcitx-googlepinyin

image-202303241617113535

点击

选择配置,将谷歌拼音挪到第一位,然后点击重新启动即可载入配置

image-202303241162714578

image-202130324165057510

同步时间

shell
sudo apt install ntpdate
sudo ntpdate time.windows.com
sudo hwclock --localtime --systohc
text
timedatectl set-local-rtc 1

deepin.wine

shell
git clone https://gitee.com/wszqkzqk/deepin-wine-for-ubuntu.git
cd deepin-wine
sudo sh install.sh
wget -O- https://deepin-wine.i-m.dev/setup.sh | sh
sudo apt install gnome-shell-extension-top-icons-plus

多个Java 版本共存

shell
sudo update-alternatives --config java

开启远程桌面

确保 GDM 强制使用 Xorg(而非 Wayland)

先检查 GDM 是否被强制到 Xorg:

bash

grep -i WaylandEnable /etc/gdm3/custom.conf

  • 如果输出是 #WaylandEnable=false(前面有 #,被注释了),说明系统可能还在尝试用 Wayland。

  • 如果是 WaylandEnable=false(无注释),则是强制 Xorg。

硬盘扩容

初始状态

shell
lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 512G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 126G 0 part └─ubuntu--vg-ubuntu--lv 252:0 0 63G 0 lvm /

  1. 扩展 sda3 分区至磁盘末尾
    bash
    sudo parted /dev/sda resizepart 3 100%
    • 遇到 Fix/Ignore?Fix
    • 遇到 End? 输入 100%(或 -1

Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 805306368 blocks) or continue with the current setting? Fix/Ignore? fix
Partition number? 3
End? [137GB]? -1
Information: You may need to update /etc/fstab.

  1. 让 LVM 识别物理卷空间变大

    bash
    sudo pvresize /dev/sda3
  2. 把物理卷所有空闲空间分配给根逻辑卷

    bash
    sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  3. 在线扩展文件系统(ext4)

    bash
    sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

验证

shell
lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 512G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 510G 0 part └─ubuntu--vg-ubuntu--lv 252:0 0 510G 0 lvm /