Ubuntu的设置
Ubuntu的初始设置
这次我打算搭建GCE并学习Ubuntu。
使用Ubuntu时应该做的事情
-
- 检查安装时的软件包信息
-
- 进行更新
-
- 检查AppArmor状态
- 检查防火墙
确认安装时的软件包信息
使用dpkg命令来检查所有软件包。
$ dpkg -l | more
||/ Name Version Architecture Description
+++-===============================-=======================================-============-======================
==========================================================
ii adduser 3.118ubuntu5 all add and remove users a
nd groups
ii apparmor 3.0.4-2ubuntu2.1 amd64 user-space parser util
ity for AppArmor
ii apport 2.20.11-0ubuntu82.1 all automatically generate
crash reports for debugging
ii apt 2.4.6 amd64 commandline package ma
nager
ii base-files 12ubuntu4.2 amd64 Debian base system mis
cellaneous files
ii base-passwd 3.5.52build1 amd64 Debian base system mas
ter password and group files
--More--
进行更新
在Ubuntu中进行常规的错误修复和功能改进,并通过软件源提供这些更新。首先,您需要更新本地管理的软件包索引,然后进行系统更新。
$ sudo apt update
然后会显示如下内容。
Hit:1 http://asia-northeast1.gce.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://asia-northeast1.gce.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:3 http://asia-northeast1.gce.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Fetched 324 kB in 1s (256 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
接下来,安装包索引中所列的库。
$ sudo apt upgrade
如果没有特别要安装的东西,就会显示如下内容。
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
eject libatasmart4 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2
libnspr4 libnss3 libntfs-3g89 libparted-fs-resize0 libudisks2-0 ntfs-3g
Use 'sudo apt autoremove' to remove them.
The following packages have been kept back:
python3-distupgrade ubuntu-release-upgrader-core
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
进行AppArmor状态确认
查看所有服务的状态。
$ systemctl
确认AppArmor的当前状态
$ systemctl status apparmor.service
以下展示如下。
● apparmor.service - Load AppArmor profiles
Loaded: loaded (/lib/systemd/system/apparmor.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2022-08-07 07:49:44 UTC; 5h 36min ago
Docs: man:apparmor(7)
https://gitlab.com/apparmor/apparmor/wikis/home/
Main PID: 292 (code=exited, status=0/SUCCESS)
CPU: 1.324s
Aug 07 07:49:43 ubuntu systemd[1]: Starting Load AppArmor profiles...
Aug 07 07:49:43 ubuntu apparmor.systemd[292]: Restarting AppArmor
Aug 07 07:49:43 ubuntu apparmor.systemd[292]: Reloading AppArmor profiles
Aug 07 07:49:44 ubuntu apparmor.systemd[327]: Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
Aug 07 07:49:44 ubuntu systemd[1]: Finished Load AppArmor profiles.
确认防火墙
由于Ubuntu的默认状态下没有安装firewalld,因此需要使用以下命令进行安装。
$ sudo apt install firewalld
请确认是否通过以下命令启动。
$ sudo ufw status
因为最初的GCE中没有安装ufw,所以通过下面的命令进行安装。
$ sudo apt install ufw
如果是非活跃的情况,可以接受。