Ubuntu 18 初始配置
建议最小化安装 Ubuntu 系统,精简不必要的软件!
Ubuntu 镜像
用于 apt
加速。首先,选择你的 Ubuntu 版本的配置,
然后,替换进 /etc/apt/sources.list
:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
sudo vi /etc/apt/sources.list
sudo apt update
中文输入法
- 打开
Settings
的Region & Language
配置页,点击Manage Installed Language
弹出Language Support
窗口 - 于
Language Support
窗口,点击Install/Remove Languages
,勾选Chinese (simplified)
再Apply
安装语言Keyboard Input method system
选IBus
- 回到
Region & Language
配置页,Input Sources
下点击+
,选择Chinese
再Chinese (Intelligent Pinyin)
完成 - 打开
Settings
的Devices
Keyboard
配置页,可修改Typing
快捷键。默认Super+Space
切换输入。Chinese (Intelligent Pinyin)
时Shift
切换中英。
SSH 配置
远程机器启用 SSH 服务:
# 安装服务
sudo apt install openssh-server
# 启动服务
sudo service ssh start
# 检查服务
ps -aux | grep ssh
如果要免密登录,可把公钥复制进 ~/.ssh/authorized_keys
。或者,本地机器写进远程机器:
ssh-copy-id -i ~/.ssh/id_rsa.pub remote@0.0.0.0
本地机器添加 SSH 私钥:
# 如果没有,则生成秘钥
# 私钥 id_rsa 公钥 id_rsa.pub
ssh-keygen -t rsa -C "ikuokuo@hotmail.com"
# 把已有私钥放进 ~/.ssh/
mkdir -p ~/.ssh/
mv id_rsa ~/.ssh/
chmod 600 ~/.ssh/id_rsa
# 添加进 ssh-agent
ssh-add ~/.ssh/id_rsa
# 测试是否成功
ssh -T remote@0.0.0.0
配置 ~/.ssh/config
,可设 Host 昵称,如用于 GitHub 多账户:
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
exFAT 驱动
支持 exFAT 格式的移动硬盘。 exFAT 于 macOS, Windows 可读写;文件和分区的大小,可到 128PB 。
sudo apt install exfat-fuse exfat-utils
Nvidia 驱动
如果是 N 卡,可安装 Nvidia 驱动。推荐使用 graphics drivers PPA 方式:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
如果安装 CUDA Toolkit ,请先了解 CUDA Compatibility 。安装 CUDA Toolkit 时,注意其携带的驱动版本,最好将其与驱动分别进行安装。而驱动从官方上直接找合适的版本。
查看驱动信息
Settings > Details > About, Graphics: 查看显卡驱动
$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:14.3 ==
modalias : pci:v00008086d000006F0sv00008086sd000002A4bc02sc80i00
vendor : Intel Corporation
manual_install: True
driver : backport-iwlwifi-dkms - distro free
$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation Device 9bc4 (rev 05)
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1f15 (rev a1)
$ lspci -v -s 01:00.0
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1f15 (rev a1) (prog-if 00 [VGA controller])
Subsystem: Device 1d05:1097
Flags: bus master, fast devsel, latency 0, IRQ 159
Memory at c5000000 (32-bit, non-prefetchable) [size=16M]
Memory at b0000000 (64-bit, prefetchable) [size=256M]
Memory at c0000000 (64-bit, prefetchable) [size=32M]
I/O ports at 6000 [size=128]
Expansion ROM at c6000000 [disabled] [size=512K]
Capabilities: <access denied>
Kernel driver in use: nouveau
Kernel modules: nvidiafb, nouveau
安装 Nvidia 驱动
apt-cache search nvidia | grep ^nvidia-driver
sudo apt install nvidia-driver-440
查看 Nvidia 驱动信息
$ nvidia-smi
Fri Apr 17 07:31:55 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.82 Driver Version: 440.82 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 2060 Off | 00000000:01:00.0 Off | N/A |
| N/A 40C P8 5W / N/A | 263MiB / 5934MiB | 3% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1560 G /usr/lib/xorg/Xorg 144MiB |
| 0 1726 G /usr/bin/gnome-shell 76MiB |
| 0 2063 G ...uest-channel-token=10544833948196615517 39MiB |
+-----------------------------------------------------------------------------+
# after reboot
$ nvidia-settings
常用工具
ifconfig
查网络:
sudo apt install -y net-tools
ifconfig
htop
查进程:
sudo apt install -y htop
htop
# 或,系统监控器
gnome-system-monitor -r
# 或,查 CPU 信息
cat /proc/cpuinfo
iostat
查 IO:
iostat -x -m 1 8
# 或,iotop
sudo apt install -y iotop
sudo iotop
nvidia-smi
查 GPU:
# 持续监测
nvidia-smi dmon
# 或,
watch -d -n 1 nvidia-smi
lshw
查硬件:
lshw -short
# 如,查产品型号
sudo lshw -C system
更多见 Linux Performance,如:
桌面优化
可用 Tweaks 优化或定制 GNOME 桌面。其扩展可见: https://extensions.gnome.org 。
sudo apt install gnome-tweaks
屏幕分享
Settings > Sharing > Screen Sharing ,启用屏幕分享。
系统最小化安装时,或于某些嵌入式版本的 Ubuntu ,不存在上述选项,需安装:
# 安装服务
sudo apt install vino
# 启用服务
/usr/lib/vino/vino-server
# SSH 登录启用服务
/usr/lib/vino/vino-server --display=:0
配置需关闭 require-encryption ,此后如 macOS Screen Sharing 等才可登录:
# sudo apt install dconf-editor
sudo apt install dconf-tools
dconf write /org/gnome/desktop/remote-access/require-encryption false
Ubuntu 可用 Remmina 客户端软件, VNC 进入远程桌面:
sudo apt install remmina remmina-plugin-vnc
屏幕录制
- Kazam: 屏幕录制
- HandBrake: 格式转换
因为 Kazam 录制格式于其他平台可能存在问题,如微信。可用 HandBrake 转换成 MPEG-4 再分享。
sudo apt install kazam handbrake
媒体播放
VLC media player 跨平台多媒体播放器及框架:
sudo snap install vlc
开发软件
编译
sudo apt install build-essential cmake git
编辑
调试
gdb
调试:
gdb --args <prog>
pstack
查进程堆栈:
sudo apt install -y pstack
pstack <pid>
strace
查进程堆栈:
sudo apt install -y strace
strace -o strace.txt -Ttt -f -p <pid>
Valgrind 调试或分析:
sudo apt install -y valgrind kcachegrind
- Valkyrie: a Qt4-based GUI for the Valgrind 3.6.x and 3.7.x series, that works for the Memcheck and Helgrind tools
- KCachegrind: visualization tool for the Valgrind profiler
- massif-visualizer: visualizer for Valgrind Massif memory-usage tracking tool
MySQL
MySQL Workbench 图形化管理工具:
sudo apt install -y mysql-workbench
Redis
Redis Desktop Manager 图形化管理工具:
sudo snap install redis-desktop-manager
命令行工具:
$ sudo apt install -y redis-tools
$ redis-cli -h <ip> -p <port>
> AUTH password
> INFO
模型可视化
Netron
sudo snap install netron