LINUX操作系统配置

创建用户

  • 建工作组xxxx

#groupadd xxxx

  • 添加用户

#adduser -g xxxx xxxx

  • 修改用户密码

#passwd xxxx

输入2次密码

  • 查看用户属性

#id xxxx

  • 安全整改要求,将用户加入wheel组,即允许su到root用户

#usermod -G wheel xxxx

修改主机名和HOSTS文件

主机名字不要为localhosts

编辑/etc/sysconfig/network 文件,给主机启用一个全网唯一的名字

vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=xxx

  • 将整个集群的名字加入到Hosts文件

vi /etc/hosts

字符集配置(可选)

#vi /etc/sysconfig/i18n

替换为以下内容:

LANG="zh_CN.GB18030"

LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"

SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"

SYSFONT="latarcyrheb-sun16"

以下是执行让其生效

#source /etc/sysconfig/i18n

修改SSH端口

此步骤参考openssh升级

#vi /etc/ssh/sshd_config

#port 22

去掉#号,改为port 30022

#service sshd restart //重启ssh服务

/etc/init.d/sshd stop && /etc/init.d/sshd start

打开文件数配置

  • 编辑vi /etc/rc.d/rc.local,在最后插入以下内容:

#vi /etc/rc.d/rc.local

插入以下内容:

echo 655360 > /proc/sys/fs/file-max

  • 编辑vi /etc/security/limits.conf,在最后插入以下内容:

#vi /etc/security/limits.conf

添加如下的行

root soft nproc 65536

root hard nproc 65536

root soft nofile 65536

root hard nofile 65536

ccssoft soft nproc 65536

ccssoft hard nproc 65536

ccssoft soft nofile 65536

ccssoft hard nofile 65536

说明:* 代表针对所有用户

noproc 是代表最大进程数

nofile 是代表最大文件打开数

修改后重新连ssh

#vi /etc/security/limits.d/90-nproc.conf

#添加以下行

ccssoft soft nproc unlimited

vi /etc/pam.d/login

加入:

session required /lib64/security/pam_limits.so

注意核实是否存在:/lib64/security/pam_limits.so 这个文件

  • 注:rhel7的修改还可能需要修改:

#vi /etc/systemd/system.conf

DefaultLimitNOFILE=1024000

DefaultLimitNPROC=1024000

NTP时钟同步

  • 方法1,启用ntpd服务,缺点是启用后有安全漏洞的风险,需要不断升级整改

vi /etc/ntp.conf

添加

server 132.122.132.33

--手工校正

ntpdate 132.122.132.33

--服务打开

chkconfig ntpd on

--服务重启

/etc/init.d/ntpd restart

--查看服务情况

/usr/sbin/ntpq -p

  • 方法2 使用crontab任务同步时钟,建议采取此方式

#crontab –e

编辑如下:

0 12 * * * /usr/sbin/ntpdate -u 132.122.132.33

关闭SELINUX和防火墙

  • 关闭防火墙(视情况而定)

ptables -F

service iptables stop

chkconfig iptables off

  • 关闭selinux 服务

编辑selinux配置文件/etc/selinux/config修改 为SELINUX=disabled

setenforce 0

getenforce (查看是否已经关闭)

  • 修改telnet回显信息,
  • 修改文件/etc/issue 和/etc/issue.net中的内容,执行如下两条命令:

#echo " Authorized users only. All activity may be monitored and reported " > /etc/issue

#echo " Authorized users only. All activity may be monitored and reported " > /etc/issue.net

可根据实际需要修改该文件的内容,但是不要出现系统敏感信息,如redhat,suse等。

  • 重启服务(注意,本来没有启动的,不需要启动该服务)

#/etc/init.d/xinetd restart

卸载红帽订阅服务

  • 没有购买服务的情况下,可以卸载红帽的订阅服务

#rpm -e subscription-manager-firstboot

# rpm -e subscription-manager-gui-1.16.8-8.el6.x86_64

# rpm -e subscription-manager

关闭和卸载X窗口模式

  • 关闭X窗口

此设置可以减少操作系统本身内存和CPU的占用

vi /etc/inittab

改成命令行模式:

id:3:initdefault:

执行 init 3即可关闭桌面

  • 回退可以修改配置id:5:initdefault:

执行指令 init 5 ;start x 即可

  • 卸载相关的组

查看安装的组,卸载

#yum grouplist

# yum groupremove "打印客户端

# yum groupremove “打印服务器”

# yum groupremove "X Window System"

#...

TCP内核参数调整

加大TCP并发连接数

vi /etc/sysctl.conf 

//在文件最后追加如下类容:

net.core.rmem_default = 256960

net.core.rmem_max = 513920

net.core.wmem_default = 256960 net.core.wmem_max = 513920

net.core.netdev_max_backlog = 262144 net.core.somaxconn = 3240000

net.ipv4.tcp_max_orphans = 65536

net.ipv4.tcp_max_syn_backlog = 262144

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_synack_retries = 1

net.ipv4.tcp_syn_retries = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_fin_timeout = 5

net.ipv4.tcp_keepalive_time =15

net.ipv4.tcp_keepalive_probes=3

net.ipv4.tcp_keepalive_intvl=5

net.ipv4.tcp_max_tw_buckets=6000

net.ipv4.tcp_syncookies=1

net.ipv4.tcp_retries2=5

# for 8G

#net.ipv4.tcp_mem = 524288     699050  1048576

net.ipv4.tcp_mem = 786432 2097152 3145728

net.ipv4.tcp_rmem = 4096 4096 16777216

net.ipv4.tcp_wmem = 4096 4096 16777216

net.ipv4.ip_local_port_range = 1024 65535

fs.file-max = 2390251

kernel.pid_max=655350

kernel.threads-max=6553500

vm.max_map_count= 655350

#使配置立即生效可使用如下命令: #/sbin/sysctl -p

关闭部份不用到的服务

报未识别的服务为正常,可能未安装此服务,可忽略

  • 打印服务

service cups stop

chkconfig cups off

  • ftp服务

/etc/rc.d/init.d/vsftpd stop

chkconfig vsftpd off

  • snmp服务

service snmpd stop

chkconfig snmpd off

  • apache服务

service httpd stop

chkconfig httpd off

  • 蓝牙服务

/etc/init.d/bluetooth stop

chkconfig bluetooth off

  • 邮件服务

service sendmail stop

chkconfig sendmail off

  • firstboot服务

service firstboot stop

chkconfig firstboot off

  • IPV6防火墙服务

service ip6tables stop

chkconfig ip6tables off

service cups stop

chkconfig cups off

/etc/rc.d/init.d/vsftpd stop

chkconfig vsftpd off

service snmpd stop

chkconfig snmpd off

service httpd stop

chkconfig httpd off

/etc/init.d/bluetooth stop

chkconfig bluetooth off

service sendmail stop

chkconfig sendmail off

service firstboot stop

chkconfig firstboot off

service ip6tables stop

chkconfig ip6tables off

service rpcbind stop

chkconfig rpcbind off

service postfix stop

chkconfig postfix off

service nfslock stop

chkconfig nfslock off

service ntpd stop

chkconfig ntpd off

----------------------

vnc服务

一般情况下不建议使用VNC服务,使用完需要及时关掉服务

  • 优化界面

#cd /root/.vnc

#vi xstartup

//把最后一行改为: gnome-session&

  • 启动VNC服务

#vncserver

第一次要设置密码;可以重复开多个server,可以在不同用户下启动属于特定用户的VNC

#vncpasswd //修改vnc密码

停止VNC服务

#vncserver -kill :1 (注意kill后面有空格)

#vncserver -kill :2

…………

  • vnc客户端

vnc客户端

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值