环境准备: 系统版本信息: CentOS Linux release 7.6.1810 (Core) 系统内核信息: Linux linux67 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
系统用户优化 系统命令提示符(shell) 系统安全优化 系统字符集优化 时间优化
创建用户:useradd 设置密码: 1.root用户设置密码 [root@linux ]# passwd (用户名) 2.不同用户自己设置密码 [oldg@linux ~]$ passwd
删除用户:userdel (用户名) 检查用户信息:id (用户名) 切换用户信息:su - (用户名)
优化提示符显示信息 PS1 — 用于设置系统命令提示符
# echo $PS1 [ \u @ \h \W ]\$ [root@linux67 tmp]# \u --- 当前登录用户 @ --- 分割符号 \h --- 显示系统主机名称 \W --- 显示当前路径信息 \$ --- 显示登录系统用户信息 # 管理员用户 root $ 普通用户 oldboy临时设置: PS1="[\u@\h \t \W]\$ " PS1=’[\u@\h \t \W]$ ’
永久设置: vi /etc/profile PS1=’[\u@\h \t \W]$ ’
恢复提示符正常显示 永久设置: vi /etc/profile PS1=’[\u@\h \t \W]$ ’
CentOS 6一定要优化,CentOS 7不一定要优化。 CentOS 7在yum下载源上面自动匹配做的很好。 关于这一块要不要优化,大家自行决定。
yum下载软件原理: yum仓库 yum源文件 yum源文件下载说明: 重要目录: /etc/yum.repos.d/ — 保存yum源文件目录 Base yum源优化 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
epel yum源优化 (企业扩展yum仓库) Extra Packages for Enterprise Linux wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 或者 curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安全服务: firewalld(防火墙)-centos7 iptables(防火墙)-centos6 安全服务: selinux (限制root用户行为) 系统权限概念 root管理员
防火墙服务如何关闭: 临时关闭: centos7 centos6 systemctl stop firewalld /etc/init.d/iptables stop systemctl is-active firewalld /etc/init.d/iptables status services stop iptables 永久关闭: centos7 centos6 systemctl disable firewalld chkconfig iptables off systemctl is-enabled firewalld chkconfig --list iptables
selinux安全服务如何关闭 临时关闭: setenforce usage: setenforce [ Enforcing | Permissive | 1 | 0 ] ?? setenforce Permissive | 0 # getenforce Permissive
永久关闭: vim /etc/selinux/config SELINUX=disabled enforcing - SELinux security policy is enforced. selinux安全策略会被强制执行 permissive - SELinux prints warnings instead of enforcing. selinux输出警告信息代替强制执行
disabled - No SELinux policy is loaded. 不加载Selinux策略
sed -i ‘7s#enforcing#disabled#g’ /etc/selinux/config ps:永久关闭后要重启才生效,临时关闭直接生效。
中国地区汉字编码标准 王永民 – 五笔 UTF-8 GBK
1.避免出现字符乱码 字符编码信息如何调整: 临时调整: LANG=“en_US.GBK”
永久调整 LANG=“en_US.GBK” 方法一: 将配置信息放入到/etc/profile LANG=“en_US.GBK” 方法二: 将配置信息放入到/etc/locale.conf LANG=“zh_CN.gbk” 说明: 配置的字符编码必须是系统可以识别的 localectl list-locales
即临时修改, 又永久修改 localectl set-locale LANG=“en_US.iso88591”
2.可以中文显示信息 localectl set-locale LANG=“zh_CN.utf8”
ps:永久关闭后要重启才生效,临时关闭直接生效。
修改时间信息和真正时间同步 时区不正确: timedatectl set-timezone ZONE 调整时间信息: a 手动调整时间信息 timedatectl set-time TIME b 自动调整时间信息 yum install -y chrony timedatectl set-ntp 1
timedatectl 参数信息: status Show current time settings 显示目前时间设置信息 set-time TIME Set system time 设置系统时间 timedatectl set-time “2019-10-10 10:57” set-timezone ZONE Set system time zone list-timezones Show known time zones 显示出已知系统时区信息 timedatectl set-timezone Asia/Shanghai set-local-rtc BOOL Control whether RTC is in local time set-local-rtc 0 rtc功能是关闭 set-local-rtc 1 rtc功能是开启
1.修改远程服务配置文件: vim /etc/ssh/sshd_config – :set nu 2.将79行和115行进行修改 79 GSSAPIAuthentication no – 远程认证方式 115 UseDNS no – 远程访问时根据IP地址进行反向解析过程 3.重启ssh服务 systemctl restart sshd
