- 关闭SELinux(是美国安全局对强制访问的实现)功能
[[email protected] ~]# sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config #使用sed + i 命令修改 [[email protected] ~]# grep "SELINUX=disabled" /etc/selinux/config #grep查看 SELINUX=disabled [[email protected] ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted 以上重启生效,生产环境不能重启 用以下命令不用重启 [[email protected] ~]# getenforce Enforcing [[email protected] ~]# setenforce usage: setenforce [ Enforcing | Permissive | 1 | 0 ] [[email protected] ~]# setenforce 0 [[email protected] ~]# getenforce Permissive
- 运行级别
[[email protected] ~]# cat /etc/inittab # inittab is only used by upstart for the default runlevel. # # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. # # System initialization is started by /etc/init/rcS.conf # # Individual runlevels are started by /etc/init/rc.conf # # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf # # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf, # with configuration in /etc/sysconfig/init. # # For information on how to write upstart event handlers, or how # upstart works, see init(5), init(8), and initctl(8). # # Default runlevel. The runlevels used are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 #桌面 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: [[email protected] ~]# grep 3:initdefault /etc/inittab #调整运行级别,默认3,可以调成其他 id:3:initdefault: [[email protected] ~]# runlevel #查看当前级别 N 3 [[email protected] ~]# init 0 #切换运行级别
- 关机
shutdown(halt) init0 参数 -r reboot after shutdown -h halt or power off after shutdown shutdown -h 10 #10分钟后关闭 shutdown now #马上 poweroff #关闭电源 *关闭防火墙 [[email protected] ~]# /etc/init.d/iptables stop #临时关闭 iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] [[email protected] ~]# /etc/init.d/iptables status #查看状态 iptables:未运行防火墙。 [[email protected] ~]# /etc/init.d/iptables restart # 重启防火墙 iptables:应用防火墙规则: [确定] [[email protected] ~]# chkconfig iptables off #开机也不启动了
- linux中文显示设置等
*中文显示设置 [[email protected] ~]# echo ‘LANG="zh_CN.UTF-8“‘ > /etc/sysconfig/i18n [[email protected] ~]# cat /etc/sysconfig/i18n LANG="zh_CN.UTF-8“ [[email protected] ~]# echo $LANG zh_CN.UTF-8 同时调整ssh客户端 *设置账号超时时间 [[email protected] ~]# export TMOUT=5 #5秒后关机 (临时生效) [[email protected] ~]# timed out waiting for input: auto-logout *设置命令行历史记录 [[email protected] ~]# history -c #清除所有历史记录 [[email protected] ~]# history #查看历史记录 1 history [[email protected] ~]# echo 1 1 [[email protected] ~]# echo 2 2 [[email protected] ~]# echo 3 3 [[email protected] ~]# echo 4 4 [[email protected] ~]# echo 5 5 [[email protected] ~]# history -d 3 #删除指定行记录 [[email protected] ~]# history 1 history 2 echo 1 3 echo 3 4 echo 4 5 echo 5 6 history -d 3 7 history [[email protected] ~]# !6 #执行某行历史命令 history -d 3 [[email protected] ~]# export HISTSIZE=5 #控制历史记录记录数量(临时生效)#永久生效放在/etc/profile文件下,然后source以下/etc/profile [[email protected] ~]# history 5 history 6 echo 7 history -d 3 8 export HISTSIZE=5 9 history [[email protected] ~]# cat ~/.bash_history #即使控制了在根目录下还有 [[email protected] ~]# export HISTORYSIZE=5 #命令行命令对应文件的记录数 *隐藏版本信息 [[email protected] ~]# cat /etc/issue CentOS release 6.7 (Final) Kernel \r on an \m [[email protected] ~]# > /etc/issue [[email protected] ~]# cat /etc/issue.net CentOS release 6.7 (Final) Kernel \r on an \m [[email protected] ~]# >/etc/issue.net [[email protected] ~]# cat /etc/issue [[email protected] ~]#
时间: 2025-01-03 16:23:32