微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos6.8基础调优详解

第一章查看系统信息

uname 你的(linux)名字/信息

-r kernel显示内核版本

-m 显示32位或64

-a显示所有信息

cat /etc/redhat-release 查看linux版本

[root@oldboyedu-shen ~]# cat/etc/redhat-release

CentOS release 6.8 (Final)

[root@oldboyedu-shen ~]# uname -a

Linux oldboyedu-shen 2.6.32-642.el6.x86_64#1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@oldboyedu-shen ~]# echo $(uname-a)>/root/kernel.txt

[root@oldboyedu-shen ~]# cat/root/kernel.txt

Linux oldboyedu-shen 2.6.32-642.el6.x86_64#1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

第二章新建用户修改密码,切换用户

useradd :新建用户

[root@oldboyedu-shen home]# useraddzhengwang

[root@oldboyedu-shen home]# ll

total 36

drwx------. 2 aaa aaa4096 Mar 11 11:58 aaa

drwx------. 2 bb bb 4096 Mar 11 12:08 bb

drwx------. 2 kai kai4096 Mar 13 21:19 kai

drwx------. 2 li li 4096 Mar 13 21:19 li

drwx------. 2 shen shen4096 Mar 13 21:42 shen

drwx------. 2 wang wang4096 Mar 13 21:19 wang

drwx------. 2 wu wu 4096 Mar 14 00:49 wu

drwx------. 2 zhao zhao4096 Mar 13 21:42 zhao

drwx------. 2 zhengwang zhengwang 4096 Mar14 00:54 zhengwang

passwd :修改密码(交互式)

参数: +用户名修改制定用户名密码

修改当前用户密码

例子:

[root@oldboyedu-shen home]# passwd

Changing password for user root.

New password:

[root@oldboyedu-shen home]# passwd shen

Changing password for user shen.

New password:

非交互式修改密码

[root@oldboyedu-35 ~]# echo 123456 |passwd--stdin oldboy

Changing password for user oldboy.

passwd: all authentication tokens updatedsuccessfully.

su :切换用户

参数: su - 用户名

例子:

[root@oldboyedu-shen ~]# su - shen

[shen@oldboyedu-shen ~]$ su - root

Password:

[root@oldboyedu-shen ~]

ctrl+d 快速退出当前用户logout

whoami : 查看当前用户

[root@oldboyedu-shen ~]# whoami

root

[root@oldboyedu-shen ~]#

第三章环境变量的初识

变量(放东西 查看变量的内容

PS1---变量的名字------藏经阁里面的武功秘籍(葵花宝典) 秘籍名字(书名)

$PS1---查看变量里面的内容---手端着书(葵花宝典) 看书的内容(读书)

PS1=新的内容 ---向变量里面放入东西----修改书的内容升级书)

linux变量名字(书名)大写的一般是自己用(linux环境变量),在哪里都可以用的变量

[root@oldboyedu-shen ~]# echo $PS1

[\u@\h \W]\$

第四章关闭Selinux

SELinux是「Security-Enhanced Linux」的简称,是美国国家安全局「NSA=The National Security AgencySCCSecure Computing Corporation)开发的 Linux一个扩张强制访问控制安全模块。原先是在Fluke上开发的,2000年以 GNU GPL 发布。

1.先查看selinux的状态selinux有「disabled」「permissive」,「enforcing3种选择。

disabled禁止permissive就是Selinux有效,但是即使你违反了策略的话它让你继续操作,但是把你的违反的内容记录下来。在我们开发策略的时候非常的有用。

相当于Debug模式。

Enforcing就是你违反了策略,你就无法继续操作下去。

getenforec命令查看状态

[root@oldboyedu-shen ~]# getenforce

Permissive

2.然后更改配置文件(先备份,在更改)(永久修改

Selinux配置文件路径为:/etc/selinux/config

[root@oldboyedu-shen ~]# cp/etc/selinux/config/etc/selinux/config.bak

[root@oldboyedu-shen ~]# vim/etc/selinux/config

(重启后才能生效,但是生产环境不能轻易重启机器)

3.setenforce命令临时关闭,将状态改为permissive

[root@oldboyedu-shen ~]# setenforce 0

第五章关闭防火墙(iptables

彻底关闭一个服务的思路是:

1/etc/init.d/iptables stop(临时)关闭防火墙(重启后,会继续运行)

/etc/init.d/iptables stop(重复执行,防止不彻底)

[root@oldboyedu-shen ~]#/etc/init.d/iptables stop

iptables: Setting chains to policy ACCEPT:filter [ OK ]

iptables: Flushing firewall rules: [ OK ]

iptables: Unloading modules: [ OK ]

[root@oldboyedu-shen ~]#/etc/init.d/iptables stop

2.查看开机自起服务:chkconfig

blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off

cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off

crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off

haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off

ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

irqbalance 0:off 1:off 2:off 3:on 4:on 5:on 6:off

kdump 0:off 1:off 2:off 3:on 4:on 5:on 6:off

lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off

mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off

messagebus 0:off 1:off 2:on 3:on 4:on 5:on 6:off

netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off

3.关闭防火墙开机自己起动:chkconfig iptables off

[root@oldboyedu-shen ~]# chkconfig iptablesoff

4. 然后检查是否在运行

/etc/init.do/iptables status

[root@oldboyedu-shen ~]#/etc/init.d/iptables status

iptables: Firewall is not running.

在检查是否开机自启动

[root@oldboyedu-shen ~]# chkconfig | grepiptables

iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

第六章解决或预防乱码问题

  1. 查看语言和编码的环境变量LANG

echo $LANG

[root@oldboyedu-shen ~]# echo $LANG

en_US.UTF-8

  1. 修改当前环境的语言和编码(临时修改)

export.GB2312

[root@oldboyedu-shen ~]# exportLANG=zh_CN.GB22312

[root@oldboyedu-shen ~]# echo $LANG

zh_CN.GB2312

(故意造成的乱码,原因是xshell的编码和linux的编码不一致)

解决一下:

export.utf-8

  1. 更改配置文件/etc/sysconfig/i18n)(永久更改)

先看一下cat /etc/sysconfig/i18n(记住要备份,以下不举例了)

[root@oldboyedu-shen ~]# cat/etc/sysconfig/i18n

LANG="en_US.UTF-8"

SYSFONT="latarcyrheb-sun16"

[root@oldboyedu-shen sysconfig]# sed's#LANG="en_US.UTF-8"#LANG="zh_CN.UTF-8"#g' i18n

LANG="zh_CN.UTF-8"

SYSFONT="latarcyrheb-sun16"

[root@oldboyedu-shen sysconfig]# sed -i's#LANG="en_US.UTF-8"#LANG="zh_CN.UTF-8"#g' i18n

[root@oldboyedu-shen sysconfig]# echo $LANG

en_US.UTF-8

(这是因为系统文件改动后不会立即生效)

4.配置文件生效(source)(或者重启)

source /etc/sysconfig/i18n

除此之外别名也是用source 生效的。

spacer.gif

原文地址:https://www.jb51.cc/centos/378380.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。