使用Moduler存储库
$ dnf module list Last metadata expiration check: 0:01:21 ago on Tue 01 Nov 2022 10:10:32 PM CST. CentOS Linux 8 - AppStream Name Stream Profiles Summary 389-ds 1.4 389 Directory Server (base) ant 1.10 [d] common [ Java build tool d] container-tools rhel8 [d] common [ Most recent (rolling) versions of podman, buildah, skopeo, runc, conmon, r d] unc, conmon, CRIU, Udica, etc as well as dependencies such as container-se linux built and tested together, and updated as frequently as every 12 wee ks. container-tools 1.0 common [ Stable versions of podman 1.0, buildah 1.5, skopeo 0.1, runc, conmon, CRIU d] , Udica, etc as well as dependencies such as container- subversion 1.14 common [ Apache Subversion d], serv er swig 3.0 [d] common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete swig 4.0 common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete ....................... ....................... varnish 6 [d] common [ Varnish HTTP cache d] virt rhel [d] common [ Virtualization module d] Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
要安装可用模块,请按如下所示进行配置。
$ dnf module list postgresql Last metadata expiration check: 0:13:08 ago on Tue 01 Nov 2022 10:10:32 PM CST. CentOS Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled $ dnf module install -y postgresql:10 $ dnf module list postgresql Last metadata expiration check: 0:15:17 ago on Tue 01 Nov 2022 10:10:32 PM CST. CentOS Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d][e] client, server [d] [i] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
如果您想更改为已安装模块的另一个版本,请按以下步骤进行配置。
例如,从上面[2]上安装的PostgreSQL 10
切换到PostgreSQL 9.6
。
$ dnf module reset -y postgresql $ dnf module install -y postgresql:9.6 #[PostgreSQL 9.6]的状态变为[e]启用 $ dnf module list postgresql Last metadata expiration check: 0:18:06 ago on Tue 01 Nov 2022 10:10:32 PM CST. CentOS Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 [e] client, server [d] [i] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
更新阿里云 yum 源
mv /etc/yum.repos.d /etc/yum.repos.d.bak # 先备份原有的 Yum 源 mkdir /etc/yum.repos.d wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo yum clean all && yum makecache
用户管理
- 要在CentOS服务器上添加普通用户帐户,请按以下步骤设置。
$ useradd centos $ passwd centos Changing password for user centos. New password: #输入您要设置的任何密码 Retype new password: passwd: all authentication tokens updated successfully.$所有身份验证令牌已成功更新
- 如果您想从普通用户切换到root用户帐户,请使用[su]命令。
[root@localhost ~]# su - centos $切换centos账号 [centos@localhost ~]$ su - $切换root账号 Password: $输入root密码 [root@localhost ~]# $切换到root账号
- 如果您想限制用户运行[su]命令,请进行如下设置。
在以下示例中,只有[wheel]组中的用户可以运行[su]命令。
[root@localhost ~]# usermod -G wheel centos [root@localhost ~]# vi /etc/pam.d/su [root@localhost ~]# cat /etc/pam.d/su #%PAM-1.0 auth required pam_env.so auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. #auth sufficient pam_wheel.so trust use_uid $我们添加的配置项 # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid auth substack system-auth auth include postlogin account sufficient pam_succeed_if.so uid = 0 use_uid quiet account include system-auth password include system-auth session include system-auth session include postlogin session optional pam_xauth.so auth sufficient pam_rootok.so debug [root@localhost ~]# groups centos $查看账号所在的组 centos : centos wheel
我们可以创建一个账号user01
没有在wheel
组,并尝试切换到root
账号
[root@localhost ~]# useradd user01 [root@localhost ~]# passwd user01 Changing password for user user01. New password: Retype new password: passwd: all authentication tokens updated successfully. [root@localhost ~]# [root@localhost ~]# su - user01 [user01@localhost ~]$ [user01@localhost ~]$ su - Password: su: Permission denied $通常是被拒绝的 [user01@localhost ~]$
- 如果您要删除用户帐户,请按以下步骤设置。
[root@localhost ~]# userdel -r user01 #删除用户[user01](仅删除的用户帐户) userdel: user 'user01' does not exist [root@localhost ~]# ll /home/ total 4 drwxr-xr-x. 3 admin admin 78 Sep 28 10:09 admin drwx------. 4 centos centos 113 Dec 4 13:56 centos drwx------. 15 localhost localhost 4096 Sep 27 16:42 localhost drwx------. 3 tddev users 78 Sep 28 10:09 tddev drwx------. 5 tdops users 143 Oct 15 16:10 tdops drwx------. 3 tdsec users 78 Sep 28 10:09 tdsec drwx------. 4 1006 1006 113 Dec 4 14:16 user01 #删除用户[user01](已删除的用户帐户和他的主目录) [root@localhost ~]# userdel -r user01 userdel: user 'user01' does not exist [root@localhost ~]# userdel -r localhost
- 添加到
wheel
组用户免密切换root
账号设置步骤。
[root@localhost ~]# vi /etc/sudoers ## Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL $添加这段内容后,wheel组用户,切换到root不需要知道root密码。 [root@localhost ~]# su - centos [centos@localhost ~]$ id uid=1005(centos) gid=1005(centos) groups=1005(centos),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [centos@localhost ~]$ [centos@localhost ~]$ sudo su - $#免密切换到root账号。 [root@localhost ~]#
给用户添加sudo权限
$ sed -i '/^root.*ALL=(ALL).*ALL/a\going\tALL=(ALL) \tALL' /etc/sudoers $ cat /etc/sudoers root ALL=(ALL) ALL going ALL=(ALL) ALL
Cockpit 管理控制台
dnf install -y cockpit systemctl enable --now cockpit.socket systemctl status --now cockpit.socket
- 登陆:https://192.168.10.14:9090
- 用户名:root
- 密码:<你设置的主机密码>
概览
磁盘、cpu、内存、网络监控
安装软件
日志
磁盘存储
网络
用户
服务
应用
诊断报表
kdump
软件更新
界面终端