1、网络配置
网卡配置文件
cat /etc/network/interfaces
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens33:
addresses:
- 10.0.0.203/24
dhcp4: false
gateway4: 10.0.0.254
nameservers:
addresses:
- 10.0.0.254
search: []
ens34:
addresses:
- 172.16.1.203/24
dhcp4: false
nameservers:
addresses: []
search: []
version: 2
vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
addresses:
- 192.168.8.10/24
gateway4: 192.168.8.254
nameservers:
addresses:
- 192.168.8.254
ens34:
addresses:
- 172.16.1.10/24
nameservers: {}
version: 2
ubuntu22 参考以下配置
vim /etc/netplan/01-network-manager-all.yaml
network:
ethernets:
ens33:
dhcp4: no
dhcp6: no
addresses:
- 192.168.0.10/24
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8
version: 2
renderer: networkd
network:
version: 2
ethernets:
ens33:
dhcp4: no
dhcp6: no
addresses:
- 10.10.10.174/24
routes:
- to: default
via: 10.10.10.1
nameservers:
addresses:
- 202.106.0.20
renderer: NetworkManager
vim /etc/netplan/01-network-manager-all.yaml
network:
version: 2
ethernets:
ens33:
dhcp4: yes
dhcp6: no
renderer: NetworkManager
重启网络
netplan apply
附:
dhclient
apt install netplan
apt-get install netplan.io
netplan apply
dhclient -r #释放IP
dhclient #获取IP
dns服务器配置
vim /etc/systemd/resolved.conf
...
[Resolve]
DNS=202.201.0.132
FallbackDNS=202.201.0.133
...
重启服务
systemctl status systemd-resolved.service
2、用户相关
sudo无需密码
vim /etc/sudoers
最后一行添加
wuxing ALL=(ALL) NOPASSWD: ALL
3、安装openssh-server,允许root登录ssh
apt-get install openssh-server
egrep -v "#|^$" /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
PermitRootLogin yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM no
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
sshd直接启动
mkdir -p /var/run/sshd
ssh-keygen -A
echo "root:123456" |chpasswd
nohup /usr/sbin/sshd -D &
4、软件源
cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
或
sed 's#archive.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list
更新apt-get源
apt-get update
安装软件包
apt-get install gcc
apt-get install yum
apt-get install ubuntu-desktop
设置启动模式
sudo systemctl set-default multi-user.target # 命令行
sudo systemctl set-default graphical.target # 图形用户界面
5、软件包管理
https://blog.csdn.net/mbxc816/article/details/7473906?tdsourcetag=s_pcqq_aiomsg
dpkg --info "软件包名" --列出软件包解包后的包名称.
dpkg -l --列出当前系统中所有的包.可以和参数less一起使用在分屏查看. (类似于rpm -qa)
dpkg -l |grep -i "软件包名" --查看系统中与"软件包名"相关联的包.
dpkg -l |grep mysql
dpkg -s 查询已安装的包的详细信息.
dpkg -L 查询系统中已安装的软件包所安装的位置. (类似于rpm -ql)
dpkg -L mysql-server
dpkg -S 查询系统中某个文件属于哪个软件包. (类似于rpm -qf)
dpkg -S mysqld
dpkg -I 查询deb包的详细信息,在一个软件包下载到本地之后看看用不用安装(看一下呗).
dpkg -i 手动安装软件包(这个命令并不能解决软件包之前的依赖性问题),如果在安装某一个软件包的时候遇到了软件依赖的问题,可以用apt-get -f install在解决信赖性这个问题.
dpkg -r 卸载软件包.不是完全的卸载,它的配置文件还存在.
dpkg -P 全部卸载(但是还是不能解决软件包的依赖性的问题)
dpkg -reconfigure 重新配置
说明 | Redhat系 | Debian系 |
---|---|---|
更新缓存 | yum makecache | apt-get update |
更新包 | yum update | apt-get upgrade |
检索包 | yum search | apt-cache search |
检索包内文件 | yum provides | apt-file search |
安装指定的包 | yum install | apt-get install |
删除指定的包 | yum remove | apt-get remove |
显示指定包的信息 | yum info | apt-cache show |
显示包所在组的一览 | yum grouplist | - |
显示指定包所在组的信息 | yum groupinfo | - |
安装指定的包组 | yum groupinstall | - |
删除指定的包组 | yum groupremove | - |
参考库的设定文件 | /etc/yum.repos.d/* | /etc/apt/sources.list |
安装完的包的列表 | rpm -qa | dpkg-query -l |
显示安装完的指定包的信息 | rpm -qi | apt-cache show |
安装完的指定包内的文件列表 | rpm -ql | dpkg-query -L |
安装完的包的信赖包的列表 | rpm -qR | apt-cache depends |
安装完的文件信赖的包 | rpm -qf | dpkg -S |
6、设置时区
timedatectl set-timezone Asia/Shanghai
7、防火墙
关闭
systemctl disable ufw.service
ufw disable
查看状态
ufw status
附
vim粘贴内容错乱
:set paste