Ubuntu使用记录
# root密码
Ubuntu的默认root密码是随机的,即每次开机都有一个新的root密码。我们可以在终端输入命令 sudo passwd,然后输入当前用户的密码,enter,终端会提示我们输入新的密码并确认,此时的密码就是root新密码。修改成功后,输入命令 su root,再输入新的密码就ok了。
# 替换apt源
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources
# 设置静态ip
ifconfig查看网卡名称,ip a也可以查看网卡名称。
编辑/etc/netplan/00-installer-config.yaml文件
network:
version: 2
renderer: networkd
ethernets:
wlp0s20f3:
dhcp4: no
addresses: [192.168.18.119/22]
routes:
- to: default
via: 192.168.18.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
2
3
4
5
6
7
8
9
10
11
12
sudo netplan apply应用配置
警告:WARNING **: 18:54:11.106: Permissions for /etc/netplan/01-network-manager-all.yaml are too open. Netplan configuration should NOT be accessible by others.
chmod 600 /etc/netplan/01-network-manager-all.yaml修改权限
在给两台机器交换ip时发现,虽然修改了ip,但使用原ip依然能访问,通过ip addr发现,网卡上有两个地址,机器使用的是WiFi连接的,尝试将WiFi的ipv4方式设置为手动,并设置成同样的新ip,解决问题。
# 设置笔记本合盖不休眠
编辑/etc/systemd/logind.conf文件,将HandleLidSwitch的值改为ignore。
# 安装nginx
apt-get install nginx
# 查看运行状态
systemctl status nginx
2
3
systemctl enable nginx 开机自启动
修改配置,/etc/nginx/nginx.conf 或在/etc/nginx/conf.d/目录下新建配置文件。
nginx -t 检查配置
systemctl reload nginx 重载配置
systemctl restart nginx 重启服务