Linux 系统初始化脚本

简介:

Linux 系统初始化脚本

 

适用于批量部署linux 操作系统!

 

#update 20130305

cat sys-init.sh

 
  1. #!/bin/bash 
  2. #linux system initialization 
  3. #update 20130305 by dongnan 
  4. #关闭不需要的服务  
  5. chkconfig atd off 
  6. chkconfig cups off    
  7. chkconfig bluetooth off    
  8. chkconfig hidd off    
  9. chkconfig ip6tables off    
  10. chkconfig auditd off    
  11. chkconfig autofs off    
  12. chkconfig avahi-daemon off    
  13. chkconfig avahi-dnsconfd off    
  14. chkconfig cpuspeed off    
  15. chkconfig isdn off    
  16. chkconfig nscd off    
  17. chkconfig pcscd off    
  18. chkconfig yum-updatesd off    
  19. chkconfig acpid off   
  20. chkconfig autofs off   
  21. chkconfig firstboot off   
  22. chkconfig mcstrans off    
  23. chkconfig rpcgssd off   
  24. chkconfig rpcidmapd off   
  25. chkconfig setroubleshoot off   
  26. chkconfig xfs off   
  27. chkconfig xinetd off   
  28. chkconfig messagebus off   
  29. chkconfig gpm off    
  30. chkconfig restorecond off    
  31. chkconfig haldaemon off   
  32. chkconfig sysstat off   
  33. chkconfig readahead_early off   
  34. chkconfig anacron off   
  35. chkconfig iscsid off   
  36. chkconfig iscsi off 
  37. chkconfig lm_sensors  off   
  38. chkconfig mdmonitor  off   
  39. chkconfig ntpd off   
  40. chkconfig smb off   
  41. chkconfig rawdevices off   
  42. chkconfig iptables off   
  43. chkconfig netfs off   
  44. chkconfig nfs off 
  45. chkconfig nfslock off 
  46. chkconfig portmap off 
  47. chkconfig hplip off 
  48. chkconfig nfs off 
  49. chkconfig nfslock off   
  50. chkconfig portmap off  
  51.  
  52. #打开需要的服务  
  53. chkconfig crond on   
  54. chkconfig irqbalance on   
  55. chkconfig kudzu on   
  56. chkconfig microcode_ctl on   
  57. chkconfig messagebus on   
  58. chkconfig network on   
  59. chkconfig sshd on   
  60. chkconfig syslog on   
  61. chkconfig --list | grep '3:on'   
  62.  
  63. #关闭selinux  
  64. sed -ir 's/SELINUX=.*/SELINUX=disabled/g'  /etc/selinux/config  
  65.  
  66. #设定最大文件句柄数量  
  67. echo -e '* soft nofile 65536  
  68. * hard nofile 65536'  >> /etc/security/limits.conf  
  69.  
  70. #同步时间  
  71. echo -e "#ntpdate \n/usr/sbin/ntpdate time-nw.nist.gov" >> /etc/rc.local   
  72.  
  73. #tcp/ip 优化  
  74. echo -en '#begin 
  75. net.ipv4.tcp_tw_reuse = 1 
  76. net.ipv4.tcp_fin_timeout = 30 
  77. net.ipv4.ip_local_port_range = 10240 65000 
  78. net.ipv4.tcp_max_syn_backlog = 16384 
  79. net.ipv4.tcp_synack_retries = 3 
  80. net.ipv4.tcp_syncookies = 1\n' >> /etc/sysctl.conf  
  81. sysctl -p 
  82.  
  83. #.vimrc 文件  
  84. cat >  ~/.vimrc << EOF 
  85. set nobackup  
  86. set number  
  87. set cindent  
  88. set autoindent  
  89. set shiftwidth=2  
  90. set tabstop=2  
  91. set softtabstop=2  
  92. set expandtab  
  93. set ruler  
  94. syntax on  
  95. EOF 
  96.  
  97. #.bash_profile  
  98. echo -en '# .bash_profile  
  99. # Get the aliases and functions  
  100. if [ -f ~/.bashrc ]; then  
  101. . ~/.bashrc  
  102. fi  
  103. # User specific environment and startup programs  
  104. PATH=$PATH:$HOME/bin  
  105. export PATH  
  106. HISTTIMEFORMAT="$(whoami) [%Y-%m-%d %H:%M:%S] " && export HISTTIMEFORMAT 
  107.  
  108. #after add  
  109. ip=`/sbin/ifconfig eth0 | grep Bcast | sed -e "s/^.* addr:\\(.*\\) Bcast.*$/\1/"` || ip=`/sbin/ifconfig eth1 | grep Bcast | sed -e "s/^.* addr:\\(.*\\) Bcast.*$/\1/"` 
  110. PS1="\[\e[32;1m\]$ip\[\e[0m\][\W]\$ " && export PS1 
  111.  
  112. #export HISTIGNORE="&:history:ls:ls *:ps:ps -A:df:df *:du:du *:[bf]g:exit"  
  113. #unset USERNAME  
  114. echo "[LOAD]";cat /proc/loadavg;echo "[DISK]";df -Th  
  115.  
  116. locale | sed -r 's/zh_CN/en_US/g' > .lang   
  117. source ~/.lang \n' > ~/.bash_profile 

 

结束 
更多请: 
linux 系统运维  37275208 
vmware 虚拟化  166682360


本文转自 dongnan 51CTO博客,原文链接:http://blog.51cto.com/dngood/738108

相关文章
|
7天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
41 2
|
10天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
61 0
|
10天前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
26 0
|
17天前
|
存储 前端开发 Linux
Linux系统之部署ToDoList任务管理工具
【4月更文挑战第1天】Linux系统之部署ToDoList任务管理工具
61 1
|
8天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
25 6
|
18天前
|
Ubuntu 架构师 Java
Linux系统常用命令非常详细建议收藏
Linux系统常用命令非常详细建议收藏
49 0
|
3天前
|
运维 网络协议 Unix
18.系统知识-Linux常用命令
18.系统知识-Linux常用命令
|
12天前
|
Prometheus 监控 Cloud Native
【Linux】查看系统内存命令(详细讲解)
【Linux】查看系统内存命令(详细讲解)
|
14天前
|
Linux API C语言
FFmpeg开发笔记(一)搭建Linux系统的开发环境
本文指导初学者如何在Linux上搭建FFmpeg开发环境。首先,由于FFmpeg依赖第三方库,可以免去编译源码的复杂过程,直接安装预编译的FFmpeg动态库。推荐网站<https://github.com/BtbN/FFmpeg-Builds/releases>提供适用于不同系统的FFmpeg包。但在安装前,需确保系统有不低于2.22版本的glibc库。详细步骤包括下载glibc-2.23源码,配置、编译和安装。接着,下载Linux版FFmpeg安装包,解压至/usr/local/ffmpeg,并设置环境变量。最后编写和编译简单的C或C++测试程序验证FFmpeg环境是否正确配置。
35 8
FFmpeg开发笔记(一)搭建Linux系统的开发环境
|
15天前
|
资源调度 JavaScript 安全
Linux系统之部署web-check网站分析工具
【4月更文挑战第3天】Linux系统之部署web-check网站分析工具
64 9