CentOS下修改主机名

系统环境:CentOS 5.8

1.临时修改主机名(重启后失效)

# hostname newhostname

2.永久性修改主机名

修改/etc/sysconfig/network文件,将其中的HOSTNAME行改为:
HOSTNAME=newhostname即可

CentOS 6下安装Exim邮件服务器

系统环境:CentOS 6.0(postfix默认情况下已安装)

1.下载epel包(exim包位于EPEL软件源中)

# wget http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-7.noarch.rpm

2.安装epel

# rpm -ivh epel-release-6-7.noarch.rpm

3.停止postfix服务,并禁止其开机自动启动

# service postfix stop
# chkconfig postfix off

4.安装exim包

# yum install exim

5.将exim设为默认的MTA

# alternatives --config mta<!--more-->

6.启动exim服务,并将其设为开机自动启动

# service exim start 
# chkconfig exim on

7.卸载postfix

# yum remove postfix

8.安装mutt

# yum install mutt

9.发送测试邮件

# echo "It's the first email" |mutt -s "test email" chen@qq.com

备注:
/sbin/chkconfig、/usr/sbin/alternatives文件由chkconfig包提供

关闭MySQL日志,删除mysql-bin日志

centos安装的MySQL默认开启了日志文件,如果数据操作比较频繁就会产生大量的日志,
在/usr/local/mysql/var/下面产生mysql-bin.0000* 类似的文件,
而且一般都在几十MB到几个GB,更甚会吃掉整个硬盘空间,从来导致mysql无法启动或报错,
如何关闭MySQL的日志功能:
删除日志:
执行:

/usr/local/mysql/bin/mysql -u root -p

输入密码登录后再执行:reset master;
关闭日志:
修改/etc/my.cnf 文件,找到

log-bin=mysql-bin
binlog_format=mixed

再这两行前面加上#,将其注释掉,再执行

/etc/init.d/mysql restart

一键最大限度优化CentOS系统服务

根据各自实际情况增减。复制下面内容粘贴到你的终端,回车就可以。
也可以保存为脚本,文件头加上#!/bin/sh,另存为.sh文件运行就可以。

service acpid off
service atd stop
service auditd stop
service avahi-daemon stop
service avahi-dnsconfd stop
service bluetooth stop
service conman stop
service cpuspeed stop
service cups stop
service dnsmasq stop
service dund stop
service firstboot stop
service hidd stop
service httpd stop
service ibmasm stop
service ip6tables stop
service irda stop
service kdump stop
service lm_sensors stop
service mcstrans stop
service messagebus stop
service microcode_ctl stop
service netconsole stop
service netfs stop
service netplugd stop
service nfs stop
service nfslock stop
service nscd stop
service ntpd stop
service oddjobd stop
service pand stop
service pcscd stop
service portmap stop
service psacct stop
service rdisc stop
service restorecond stop
service rpcgssd stop
service rpcidmapd stop
service rpcsvcgssd stop
service saslauthd stop
service sendmail stop
service setroubleshoot stop
service smb stop
service vncserver stop
service winbind stop
service wpa_supplicant stop
service xfs stop
service ypbind stop
service yum-updatesd stop
chkconfig acpid off
chkconfig atd off
chkconfig auditd off
chkconfig avahi-daemon off
chkconfig avahi-dnsconfd off
chkconfig bluetooth off
chkconfig conman off
chkconfig cpuspeed off
chkconfig cups off
chkconfig dnsmasq off
chkconfig dund off
chkconfig firstboot off
chkconfig hidd off
chkconfig httpd off
chkconfig ibmasm off
chkconfig ip6tables off
chkconfig irda off
chkconfig kdump off
chkconfig lm_sensors off
chkconfig mcstrans off
chkconfig messagebus off
chkconfig microcode_ctl off
chkconfig netconsole off
chkconfig netfs off
chkconfig netplugd off
chkconfig nfs off
chkconfig nfslock off
chkconfig nscd off
chkconfig ntpd off
chkconfig oddjobd off
chkconfig pand off
chkconfig pcscd off
chkconfig portmap off
chkconfig psacct off
chkconfig rdisc off
chkconfig restorecond off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig rpcsvcgssd off
chkconfig saslauthd off
chkconfig sendmail off
chkconfig setroubleshoot off
chkconfig smb off
chkconfig vncserver off
chkconfig winbind off
chkconfig wpa_supplicant off
chkconfig xfs off
chkconfig ypbind off
chkconfig yum-updatesd off

Centos添加组、所有者权限

为运行在Centos上的网站添加一个组权限,这个组权限作为网站运行的一个权限用户.以利达到权限控制.
命令如下:
chown -R 组:拥有者 目录
chown -R 组:拥有者 目录
例如:chown -R www:www /home/wwwroot
这样一来就是为wwwroot的文件夹添加一个组为www拥有者为www权限的一个用户.
说明:
使用权限 : root
使用方式 : chown [-cfhvR] [–help] [–version] user[:group] file&#8230;
<h2>参数说明</h2>
user : 新的档案拥有者的使用者 ID
group : 新的档案拥有者的使用者群体(group)
-c : 若该档案拥有者确实已经更改,才显示其更改动作
-f : 若该档案拥有者无法被更改也不要显示错误讯息
-h : 只对于连结(link)进行变更,而非该 link 真正指向的档案
-v : 显示拥有者变更的详细资料
-R : 对目前目录下的所有档案与子目录进行相同的拥有者变更(即以递回的方式逐个变更)
–help : 显示辅助说明
–version : 显示版本