阅读更多
1 Network
1.1 NetworkManager
用NetworkManager
来配置网络
1 | apt install -y network-manager |
编辑/etc/NetworkManager/NetworkManager.conf
文件,确保包含如下内容
1 | [main] |
通过nmtui
添加网卡并启动
1.2 netplan (Recommend)
In Ubuntu 18.04 and later versions, network configuration is managed by netplan. The configuration files are located in the /etc/netplan/
directory and have a .yaml
extension.
In these files, you might find DHCP configurations like the following:
1 | network: |
How to manage netplan:
netplan apply
: This command will reconfigure the network based on the.yaml
configuration files in the/etc/netplan/
directory.netplan try
: This command will temporarily apply the new network configuration. If the configuration has errors, the system will automatically roll back after 120 seconds. If the configuration is correct, you can press “Enter” to permanently apply the changes.
1.3 systemd-resolved
systemd-resolved
is a component of the systemd
suite responsible for providing network name resolution services on Linux systems. It handles DNS (Domain Name System) queries, LLMNR (Link-Local Multicast Name Resolution), and Multicast DNS (mDNS) to resolve hostnames into IP addresses, making network communication possible.
systemd-resolved
runs a local DNS stub listener on 127.0.0.53:53
by default, which applications can use to perform DNS queries. The /etc/resolv.conf
file is typically a symbolic link to /run/systemd/resolve/stub-resolv.conf
, directing DNS requests to the stub resolver.
The configuration file for systemd-resolved
is located at /etc/systemd/resolved.conf
, where you can set options like fallback DNS servers, LLMNR, and mDNS settings.
Commands
1 | resolvectl status |
1.4 Reference
2 Multiple compiling environments
2.1 gcc
编辑/etc/apt/sources.list
,添加如下源:
1 | deb http://dk.archive.ubuntu.com/ubuntu/ trusty main universe |
然后执行apt update
,会报如下错误:
1 | W: GPG error: http://dk.archive.ubuntu.com/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32 |
修改/etc/apt/sources.list
,添加[trusted=yes]
,如下:
1 | deb [trusted=yes] http://dk.archive.ubuntu.com/ubuntu/ trusty main universe |
再次执行apt update
,安装不同版本的gcc/g++
1 | apt update |
查看所有可用的gcc版本:
1 | update-alternatives --list gcc |
切换不同的gcc版本:
1 | update-alternatives --config gcc |
2.2 make
从gnu-make下载make-3.81.tar.gz
1 | tar -zxf make-3.81.tar.gz |
会出现如下错误:
1 | undefined reference to `__alloca' |
修改make-3.81/glob/glob.c
1 | // 将 |
再次编译安装即可:
1 | make -j $(( (cores=$(nproc))>1?cores/2:1 )) |
1 | update-alternatives --install /usr/bin/make make /usr/bin/make 4 |
2.3 Reference
3 apt
- 源配置文件:
/etc/apt/sources.list
- 格式:
deb http://site.example.com/debian distribution component1 component2 component3
- 其中,
distribution
可以参考Ubuntu version historyTrusty
:14.04Xenial
:16.04Bionic
:18.04Focal
:20.04Jammy
:22.04
- 其中,
- 添加
[trusted=yes]
可以绕开一些安全性设置,如下:1
2deb [trusted=yes] http://dk.archive.ubuntu.com/ubuntu/ xenial main universe
deb [trusted=yes] http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
3.1 apt vs. apt-get
The above explanation comes from chartGPT
apt and apt-get are both package management tools used in Debian-based Linux distributions like Ubuntu to manage packages and perform related tasks.
The main difference between the two is the way they are used and the level of user interaction.
apt-get is a low-level tool for package management, and is mainly used from the command line. It provides basic functionality for installing, upgrading, and removing packages, and is used in shell scripts and other automated systems.
apt, on the other hand, is a higher-level tool that builds on top of apt-get. It provides a more user-friendly interface and has additional features, such as the ability to perform multiple operations in a single command and to display more information about packages. apt also handles dependencies more automatically and can handle larger transactions than apt-get.
So, in general, apt is recommended for regular users, while apt-get is more suited for advanced users and automation. However, both apt and apt-get provide the same underlying functionality, and you can use either one to manage packages on your system.
3.2 aptitude
1 | sudo apt install aptitude |
3.3 Reference
4 Tips
4.1 Ubuntu Docker Container 中文乱码
1 | export LANG=C.UTF-8 |