Linux/傻逼 CentOS & RHEL

Linux/傻逼 CentOS & RHEL

CentOS 和 RHEL 是最傻逼的 Linux 发行版。

Tips

无法启动时修复 file system

ext2 / ext3 / ext4

fsck

XFS

xfs_repair -d -L /dev/mapper/cl-root

增加源

Extra Packages for Enterprise Linux (EPEL)

### For CentOS/RHEL 8 ###
yum localinstall --nogpgcheck https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/e/epel-release-8-8.el8.noarch.rpm

### For CentOS/RHEL 7 ###
yum localinstall --nogpgcheck http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

### For CentOS/RHEL 6 ###
yum localinstall --nogpgcheck  http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

VNC

yum install tigervnc-server

修改系统时区

mv /etc/localtime /etc/localtime.backup
ln -s /usr/share/zoneinfo/UTC /etc/localtime
#ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 手工更新一次时间以使生效
ntpdate be.pool.ntp.org
# 写入主板硬件时间
hwclock --systohc

VNC

CentOS VNC 文档

安装 vnc-server 包。

修改 ~/.vnc/xstartup

#!/bin/sh
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

Console 无法登录 (login loop)

突然出现的问题,无法登录,输入用户名和密码后又回到登录界面(与密码错误时的响应不同)。(SSH登录是没有问题的,但貌似出现这种情况是经常伴随虚拟机网卡 MAC 地址 / IP 变化)

修复:

1、进入单用户模式 (grub => press a => append " single" to boot args

2、查看/var/log/secure文件,日志如下:

Mar 14 11:05:06 testOpenfire login: PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: cannot open shared object file: No such file or directory
Mar 14 11:05:06 testOpenfire login: PAM adding faulty module: /lib/security/pam_limits.so
Mar 14 11:05:10 testOpenfire login: pam_limits(login:session): unknown limit type 'herd'
Mar 14 11:05:10 testOpenfire login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Mar 14 11:05:10 testOpenfire login: Module is unknown
Mar 14 11:05:21 testOpenfire login: PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: cannot open shared object file: No such file or directory

意思是PAM unable to dlopen /lib/security/pam_limits.so这个文件,于是乎去/lib/security/下查看下有没有pam_limits.so这个文件,果然没有。

3、在/etc/pam.d/login里,里面的配置信息如下:

auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth       include      system-auth
account    required     pam_nologin.so
account    include      system-auth
password   include      system-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
session    optional     pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      system-auth
-session   optional     pam_ck_connector.so
session required /lib/security/pam_limits.so
session required pam_limits.so
~                                                                                                                               
~      

session required /lib/security/pam_limits.so 和 "session required pam_limits.so" 这两行用 # 注释掉或者是改为(搜了下,64位系统在lib64目录下):/lib64/security/pam_limits.so,保存后,重启系统即可。

如果不行,同样方式修改 /etc/pam.d/system-auth 等文件。


Last update: 2021-01-07 03:35:04 UTC