CentOS 7
禁止root远程登录
修改文件/etc/ssh/sshd_config, 将
# PermitRootLogin yes
修改为:
PermitRootLogin no
重新启动ssh服务:
# systemctl restart sshd
禁用IP V6
修改文件/etc/default/grub,找到GRUB_CMDLINE_LINUX,修改为:
GRUB_CMDLINE_LINUX="ipv6.disable=1 ..."
然后执行:
# grub2-mkconfig -o /boot/grub2/grub.cfg
重新启动.
禁用防火墙
# systemctl stop firewalld.service
# systemctl disable firewalld.service
docker镜像增加中文支持
centos7的docker镜像缺省只支持英文,解决方法是修改文件/etc/yum.conf,将
override_install_langs=en_US.utf8
修改为:
override_install_langs=en_US.utf8,zh_CN.utf8
或
override_install_langs=en_US,zh_CN
然后执行:
# yum -y -q reinstall glibc-common
验证:
# export LC_ALL=zh_CN.utf8
# locale -a
C
en_US.utf8
POSIX
zh_CN.utf8
# date
2019年 01月 14日 星期一 13:39:32 UTC
修改时区
# cp -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
或
# timedatectl list-timezones
# timedatectl set-timezone Asia/Shanghai
使用内存虚拟磁盘
修改/etc/fstab,增加:
tmps /dev/shm tmpfs defaults,size=2G 0 0
执行:
# mount -o remount /dev/shm/
# mkdir /dev/shm/tmp
# chmod 755 /dev/shm/tmp
# mount -B /dev/shm/tmp /tmp
设置http代理
export http_proxy="http://localhost:port"
export https_proxy="http://localhost:port"
设置http使用sock5代理
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"
或
export ALL_PROXY=socks5://127.0.0.1:1080
升级内核
通过epel安装最新内核(参考:http://elrepo.org/tiki/tiki-index.php):
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# yum install https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
#
# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
# yum --enablerepo=elrepo-kernel install kernel-ml
查看可用kernel:
# sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (4.4.178-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-957.10.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-262067de42d74b25bb8e7ee3b7de8876) 7 (Core)
调整grub启动顺序:
直接修改/etc/default/grub文件设置 GRUB_DEFAULT=0,或:
# grub2-set-default 0
然后执行:
# grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-editenv list
# reboot
安装最小桌面环境
# yum groups install "X Window System"
安装”X Window System”,通过putty就可以启动桌面程序了。
如果需要在linux中直接运行桌面程序的话,还需要安装xfce4或gnome,如下:
# yum groups install xfce4
# systemctl set-default graphical.target
# shutdown -r now