centos 7 查看系統/硬件信息及運維經常使用命令+聯想Y430P無線網卡驅動安裝

 centos 7 查看系統/硬件信息及運維經常使用命令 node

當前環境:聯想Y430P  CentOS 7.3mysql

 

[root@yan-001 ~] # uname -a # 查看內核/操做系統/CPU信息的Linux系統信息命令linux

 

[root@endv ~]# uname -a
Linux endv 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@endv ~]#

 

 

 

[root@yan-001 ~] # head -n 1 /etc/issue # 查看操做系統版本,是數字1不是字母Les6

 

[root@endv ~]#  head -n 1 /etc/issue
\S
[root@endv ~]# 

 

 

 

[root@yan-001 ~] # cat /proc/cpuinfo # 查看CPU信息的linux系統信息命令sql

 

  1 [root@endv ~]# cat /proc/cpuinfo
  2 processor    : 0
  3 vendor_id    : GenuineIntel
  4 cpu family    : 6
  5 model        : 60
  6 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
  7 stepping    : 3
  8 microcode    : 0x20
  9 cpu MHz        : 2992.871
 10 cache size    : 6144 KB
 11 physical id    : 0
 12 siblings    : 8
 13 core id        : 0
 14 cpu cores    : 4
 15 apicid        : 0
 16 initial apicid    : 0
 17 fpu        : yes
 18 fpu_exception    : yes
 19 cpuid level    : 13
 20 wp        : yes
 21 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
 22 bogomips    : 4988.36
 23 clflush size    : 64
 24 cache_alignment    : 64
 25 address sizes    : 39 bits physical, 48 bits virtual
 26 power management:
 27 
 28 processor    : 1
 29 vendor_id    : GenuineIntel
 30 cpu family    : 6
 31 model        : 60
 32 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
 33 stepping    : 3
 34 microcode    : 0x20
 35 cpu MHz        : 2600.781
 36 cache size    : 6144 KB
 37 physical id    : 0
 38 siblings    : 8
 39 core id        : 0
 40 cpu cores    : 4
 41 apicid        : 1
 42 initial apicid    : 1
 43 fpu        : yes
 44 fpu_exception    : yes
 45 cpuid level    : 13
 46 wp        : yes
 47 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
 48 bogomips    : 4988.36
 49 clflush size    : 64
 50 cache_alignment    : 64
 51 address sizes    : 39 bits physical, 48 bits virtual
 52 power management:
 53 
 54 processor    : 2
 55 vendor_id    : GenuineIntel
 56 cpu family    : 6
 57 model        : 60
 58 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
 59 stepping    : 3
 60 microcode    : 0x20
 61 cpu MHz        : 2529.980
 62 cache size    : 6144 KB
 63 physical id    : 0
 64 siblings    : 8
 65 core id        : 1
 66 cpu cores    : 4
 67 apicid        : 2
 68 initial apicid    : 2
 69 fpu        : yes
 70 fpu_exception    : yes
 71 cpuid level    : 13
 72 wp        : yes
 73 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
 74 bogomips    : 4988.36
 75 clflush size    : 64
 76 cache_alignment    : 64
 77 address sizes    : 39 bits physical, 48 bits virtual
 78 power management:
 79 
 80 processor    : 3
 81 vendor_id    : GenuineIntel
 82 cpu family    : 6
 83 model        : 60
 84 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
 85 stepping    : 3
 86 microcode    : 0x20
 87 cpu MHz        : 2747.949
 88 cache size    : 6144 KB
 89 physical id    : 0
 90 siblings    : 8
 91 core id        : 1
 92 cpu cores    : 4
 93 apicid        : 3
 94 initial apicid    : 3
 95 fpu        : yes
 96 fpu_exception    : yes
 97 cpuid level    : 13
 98 wp        : yes
 99 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
100 bogomips    : 4988.36
101 clflush size    : 64
102 cache_alignment    : 64
103 address sizes    : 39 bits physical, 48 bits virtual
104 power management:
105 
106 processor    : 4
107 vendor_id    : GenuineIntel
108 cpu family    : 6
109 model        : 60
110 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
111 stepping    : 3
112 microcode    : 0x20
113 cpu MHz        : 2245.019
114 cache size    : 6144 KB
115 physical id    : 0
116 siblings    : 8
117 core id        : 2
118 cpu cores    : 4
119 apicid        : 4
120 initial apicid    : 4
121 fpu        : yes
122 fpu_exception    : yes
123 cpuid level    : 13
124 wp        : yes
125 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
126 bogomips    : 4988.36
127 clflush size    : 64
128 cache_alignment    : 64
129 address sizes    : 39 bits physical, 48 bits virtual
130 power management:
131 
132 processor    : 5
133 vendor_id    : GenuineIntel
134 cpu family    : 6
135 model        : 60
136 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
137 stepping    : 3
138 microcode    : 0x20
139 cpu MHz        : 3021.484
140 cache size    : 6144 KB
141 physical id    : 0
142 siblings    : 8
143 core id        : 2
144 cpu cores    : 4
145 apicid        : 5
146 initial apicid    : 5
147 fpu        : yes
148 fpu_exception    : yes
149 cpuid level    : 13
150 wp        : yes
151 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
152 bogomips    : 4988.36
153 clflush size    : 64
154 cache_alignment    : 64
155 address sizes    : 39 bits physical, 48 bits virtual
156 power management:
157 
158 processor    : 6
159 vendor_id    : GenuineIntel
160 cpu family    : 6
161 model        : 60
162 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
163 stepping    : 3
164 microcode    : 0x20
165 cpu MHz        : 2552.246
166 cache size    : 6144 KB
167 physical id    : 0
168 siblings    : 8
169 core id        : 3
170 cpu cores    : 4
171 apicid        : 6
172 initial apicid    : 6
173 fpu        : yes
174 fpu_exception    : yes
175 cpuid level    : 13
176 wp        : yes
177 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
178 bogomips    : 4988.36
179 clflush size    : 64
180 cache_alignment    : 64
181 address sizes    : 39 bits physical, 48 bits virtual
182 power management:
183 
184 processor    : 7
185 vendor_id    : GenuineIntel
186 cpu family    : 6
187 model        : 60
188 model name    : Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
189 stepping    : 3
190 microcode    : 0x20
191 cpu MHz        : 2913.671
192 cache size    : 6144 KB
193 physical id    : 0
194 siblings    : 8
195 core id        : 3
196 cpu cores    : 4
197 apicid        : 7
198 initial apicid    : 7
199 fpu        : yes
200 fpu_exception    : yes
201 cpuid level    : 13
202 wp        : yes
203 flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
204 bogomips    : 4988.36
205 clflush size    : 64
206 cache_alignment    : 64
207 address sizes    : 39 bits physical, 48 bits virtual
208 power management:
209 
210 [root@endv ~]# 
View Code

 

 

 

[root@yan-001 ~] # hostname # 查看計算機名的linux系統信息命令shell

[root@yan-001 ~] # lspci -tv # 列出全部PCI設備數據庫

 

 1 [root@endv ~]#  lspci -tv  2 -[0000:00]-+-00.0 Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller  3 +-01.0-[01-06]----00.0 NVIDIA Corporation GM107M [GeForce GTX 850M]  4 +-02.0 Intel Corporation 4th Gen Core Processor Integrated Graphics Controller  5 +-03.0 Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller  6 +-14.0 Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI  7 +-16.0 Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1  8 +-1a.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2  9 +-1b.0 Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller 10  +-1c.0-[07]----00.0 Qualcomm Atheros QCA8171 Gigabit Ethernet # 高通創銳訊 QCA8171  千兆以太網 (本地網卡)
11 +-1c.4-[08]----00.0 Broadcom Limited BCM43142 802.11b/g/n
BCM43142
Wi-Fi Direct™ & Bluetooth 4.0 Combo Chip for PCs & Notebooks
https://www.broadcom.com/products/wireless/wireless-lan-bluetooth/bcm43142
# 博通無線網卡 BCM43142 802.11b/g/n
# 驅動下載地址:https://www.broadcom.com/products/wireless/wireless-lan-bluetooth/bcm43142
# https://docs.broadcom.com/docs/12358410
                #            [gz] Linux® STA 64-bit driver
                #               These packages contain Broadcom's IEEE 802.11a/b/g/n
                #               hybrid Linux.. device driver for use with Broadcom's BCM4311-, BCM4312-, BCM4313-,
                #               BCM4321-, BCM4322-, BCM43224-, and BCM43225-, BCM43227- and BCM43228-based hardware.
                #               There are different tars for 32-bit and 64-bit x86 CPU 
                #               DATE: 10/02/2015SIZE: 2859 KB
                               These packages contain Broadcom's IEEE 802.11a/b/g/n
                              hybrid Linux.. device driver for use with Broadcom's BCM4311-, BCM
 12 +-1d.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 13 +-1f.0 Intel Corporation HM86 Express LPC Controller 14 +-1f.2 Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] 15 \-1f.3 Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller 16 [root@endv ~]# 

 聯想Y430P無線網卡驅動安裝vim

安裝路徑的創建並解壓
# mkdir -p /usr/local/src/hybrid-wl
將剛剛下載的.tar.gz複製到新建好的文件夾中
# cp /home/XXXX/下載/hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz /usr/local/src/hybrid-wl 

進入hybrid-hy文件夾centos

# cd /usr/local/src/hybrid-wl

編譯安裝api

# make clean
# make API=WEXT

 編譯成功,ls如下,發現生成了wl.ko文件 而後安裝

# make install

配置驅動

移除全部其它的BROADCOM 無線設備驅動

如下任何一種驅動存在,移除它:
# rmmod b43
# rmmod ssb
# rmmod bcma
# rmmod wl
rmmod b43
rmmod ssb
rmmod bcma
rmmod wl 所這些配置加入黑名單,不讓它們被使用:
# echo 「blacklist ssb」 >> /etc/modprobe.d/blacklist.conf
# echo 「blacklist bcma」 >> /etc/modprobe.d/blacklist.conf
# echo 「blacklist b43″ >> /etc/modprobe.d/blacklist.conf
載入驅動
# modprobe lib80211 # 由於 wl.ko 須要依賴該模塊
# insmod wl.ko
完成這一步以後,你已經可以在你的網絡連接中找到「無線網絡」了,這意味着你將搜索到周圍的熱點
最後一步:
# cp wl.ko /lib/modules/3.10.0-514.6.1.el7.x86_64/kernel/drivers/net/wireless (將wl.ko複製進去,其中3.10.0-514.6.1.el7.x86_64是你的內核版本,能夠進入modules文件夾中ls一下)
# depmod -a
# echo modeprobe wl >> /etc/rc.local
完成上面一步時,已經添加了開機啓動,這樣在reboot以後不會發現無線網絡不可用。


 無線網卡 無線網絡的配置

這裏有些問題,稍後補充

[root@endv ~]# lsusb

 

  激活

ifconfig virbr0 up

 

 

 

 

 

 

 

 

 

[root@yan-001 ~] # lsusb -tv # 列出全部USB設備的linux系統信息命令

[root@yan-001 ~] # lsmod # 列出加載的內核模塊

[root@yan-001 ~] # env # 查看環境變量資源

[root@yan-001 ~] # free -m # 查看內存使用量和交換區使用量

[root@yan-001 ~] # df -h # 查看各分區使用狀況

[root@yan-001 ~] # du -sh # 查看指定目錄的大小

[root@yan-001 ~] # grep MemTotal /proc/meminfo # 查看內存總量

[root@yan-001 ~] # grep MemFree /proc/meminfo # 查看空閒內存量

[root@yan-001 ~] # uptime # 查看系統運行時間、用戶數、負載

[root@yan-001 ~] # cat /proc/loadavg # 查看系統負載磁盤和分區

[root@yan-001 ~] # mount | column -t # 查看掛接的分區狀態

[root@yan-001 ~] # fdisk -l # 查看全部分區

[root@yan-001 ~] # swapon -s # 查看全部交換分區

[root@yan-001 ~] # hdparm -i /dev/hda # 查看磁盤參數(僅適用於IDE設備)

[root@yan-001 ~] # dmesg | grep IDE # 查看啓動時IDE設備檢測情況網絡

[root@yan-001 ~] # ifconfig # 查看全部網絡接口的屬性

[root@yan-001 ~] # iptables -L # 查看防火牆設置

[root@yan-001 ~] # route -n # 查看路由表

[root@yan-001 ~] # netstat -lntp # 查看全部監聽端口

[root@yan-001 ~] # netstat -antp # 查看全部已經創建的鏈接

[root@yan-001 ~] # netstat -s # 查看網絡統計信息進程

[root@yan-001 ~] # ps -ef # 查看全部進程

[root@yan-001 ~] # top # 實時顯示進程狀態用戶

[root@yan-001 ~] # w # 查看活動用戶

[root@yan-001 ~] # id # 查看指定用戶信息

[root@yan-001 ~] # last # 查看用戶登陸日誌

[root@yan-001 ~] # cut -d: -f1 /etc/passwd # 查看系統全部用戶

[root@yan-001 ~] # cut -d: -f1 /etc/group # 查看系統全部組

[root@yan-001 ~] # crontab -l # 查看當前用戶的計劃任務服務

[root@yan-001 ~] # chkconfig –list # 列出全部系統服務

[root@yan-001 ~] # chkconfig –list | grep on # 列出全部啓動的系統服務程序

[root@yan-001 ~] # rpm -qa # 查看全部安裝的軟件包

[root@yan-001 ~] # cat /proc/cpuinfo # 查看CPU相關參數的linux系統命令

[root@yan-001 ~] # cat /proc/partitions # 查看linux硬盤和分區信息的系統信息命令

[root@yan-001 ~] # cat /proc/meminfo # 查看linux系統內存信息的linux系統命令

[root@yan-001 ~] # cat /proc/version # 查看版本,相似uname -r

[root@yan-001 ~] # cat /proc/ioports # 查看設備io端口

[root@yan-001 ~] # cat /proc/interrupts # 查看中斷

[root@yan-001 ~] # cat /proc/pci # 查看pci設備的信息

[root@yan-001 ~] # cat /proc/swaps # 查看全部swap分區的信息

 

 

1、註釋掉系統不須要的用戶和用戶組注意:不建議直接刪除,當你須要某個用戶時,本身從新添加會很麻煩。   

cp  /etc/passwd  /etc/passwdbak   #修改以前先備份   

vi /etc/passwd  #編輯用戶,在前面加上#註釋掉 此行 

#adm:x:3:4:adm:/var/adm:/sbin/nologin

#lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

#sync:x:5:0:sync:/sbin:/bin/sync

#shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

#halt:x:7:0:halt:/sbin:/sbin/halt#uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

#operator:x:11:0:operator:/root:/sbin/nologin

#games:x:12:100:games:/usr/games:/sbin/nologin

#gopher:x:13:30:gopher:/var/gopher:/sbin/nologin

#ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin    

#註釋掉ftp匿名帳號cp /etc/group   /etc/groupbak  

 #修改以前先備份  vi /etc/group  

#編輯用戶組,在前面加上#註釋掉此行

#adm:x:4:root,adm,daemon

#lp:x:7:daemon,lp

#uucp:x:14:uucp

#games:x:20:

#dip:x:40:

 

2、關閉系統不須要的服務

service acpid stop  chkconfig acpid off   #中止服務,取消開機啓動  #電源進階設定,經常使用在 Laptop 上

service autofs stop  chkconfig autofs off  #停用自動掛載檔桉系統與週邊裝置

service bluetooth stop  chkconfig  bluetooth  off   #停用Bluetooth藍芽

service cpuspeed stop  chkconfig  cpuspeed  off   #停用控制CPU速度主要用來省電

service cups stop   chkconfig cups off    #停用 Common UNIX Printing System 使系統支援印表機

service ip6tables stop  chkconfig ip6tables off   #禁止IPv6

 若是要恢復某一個服務,能夠執行下面操做

  service acpid start  chkconfig acpid on  

 

3、禁止非root用戶執行/etc/rc.d/init.d/下的系統命令

chmod -R 700 /etc/rc.d/init.d/*

chmod -R 777 /etc/rc.d/init.d/*    #恢復默認設置  

4、給下面的文件加上不可更改屬性,從而防止非受權用戶得到權限

chattr +i /etc/passwd

chattr +i /etc/shadow

chattr +i /etc/group

chattr +i /etc/gshadow

chattr +i /etc/services    #給系統服務端口列表文件加鎖,防止未經許可的刪除或添加服務

lsattr  /etc/passwd   /etc/shadow  /etc/group  /etc/gshadow   /etc/services   #顯示文件的屬性  

注意:執行以上權限修改以後,就沒法添加刪除用戶了。若是再要添加刪除用戶,須要先取消上面的設置,等用戶添加刪除完成以後,再執行上面的操做

chattr -i /etc/passwd     #取消權限鎖定設置  

chattr -i /etc/shadow  

chattr -i /etc/group  

chattr -i /etc/gshadow  

chattr -i /etc/services   #取消系統服務端口列表文件加鎖

如今能夠進行添加刪除用戶了,操做完以後再鎖定目錄文件

 

5、限制不一樣文件的權限

chattr +a .bash_history           #避免刪除.bash_history或者重定向到/dev/null

chattr +i .bash_historychmod 700 /usr/bin                恢復  chmod 555 /usr/binchmod 700 /bin/ping              恢復  chmod 4755 /bin/pingchmod 700 /usr/bin/vim         恢復  chmod 755 /usr/bin/vimchmod 700 /bin/netstat          恢復  chmod 755 /bin/netstatchmod 700 /usr/bin/tail          恢復  chmod 755 /usr/bin/tailchmod 700 /usr/bin/less         恢復  chmod 755 /usr/bin/lesschmod 700 /usr/bin/head       恢復  chmod 755 /usr/bin/headchmod 700 /bin/cat                恢復  chmod 755 /bin/catchmod 700 /bin/uname          恢復  chmod 755 /bin/uname

chmod 500 /bin/ps                 恢復  chmod 755 /bin/ps

 

6、禁止使用Ctrl+Alt+Del快捷鍵重啓服務器

cp /etc/inittab  /etc/inittabbakvi /etc/inittab    #註釋掉下面這一行

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now

 

7、使用yum update更新系統時不升級內核,只更新軟件包因爲系統與硬件的兼容性問題,有可能升級內核後致使服務器不能正常啓動,這是很是可怕的,沒有特別的須要,建議不要隨意升級內核。

cp /etc/yum.conf    /etc/yum.confbak

一、修改yum的配置文件 vi /etc/yum.conf  在[main]的最後添加 exclude=kernel*

二、直接在yum的命令後面加上以下的參數:yum --exclude=kernel* update查看系統版本  cat /etc/issue

查看內核版本  uname -a

 

8、關閉Centos自動更新

chkconfig --list yum-updatesd  #顯示當前系統狀態yum-updatesd    0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉

service yum-updatesd stop      #關閉  開啓參數爲start中止 yum-updatesd:                                        [肯定]

service yum-updatesd status   #查看是否關閉yum-updatesd 已停

chkconfig --level 35 yum-updatesd off  #禁止開啓啓動(系統模式爲三、5)

chkconfig yum-updatesd off  #禁止開啓啓動(全部啓動模式所有禁止)

chkconfig --list yum-updatesd  #顯示當前系統狀態

yum-updatesd    0:關閉  1:關閉  2:啓用  3:關閉  4:啓用  5:關閉  6:關閉

 

9、關閉多餘的虛擬控制檯

咱們知道從控制檯切換到 X 窗口,通常採用 Alt-F7 ,爲何呢?由於系統默認定義了 6 個虛擬控制檯,因此 X 就成了第7個。實際上,不少人通常不會須要這麼多虛擬控制檯的,修改/etc/inittab ,註釋掉那些你不須要的。

cp  /etc/inittab  /etc/inittabbakvi /etc/inittab# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty1#2:2345:respawn:/sbin/mingetty tty2#3:2345:respawn:/sbin/mingetty tty3#4:2345:respawn:/sbin/mingetty tty4#5:2345:respawn:/sbin/mingetty tty5

#6:2345:respawn:/sbin/mingetty tty6

 

10、刪除MySQL歷史記錄

用戶登錄數據庫後 執行的SQL命令也會被MySQL記錄在用戶目錄的.mysql_history文件裏。若是數據庫用戶用SQL語句修改了數據庫密碼,也會 因.mysql_history文件而泄漏。因此咱們在shell登錄及備份的時候不要在-p後直接加密碼,而是在提示後再輸入數據庫密碼。另外這兩個文 件咱們也應該不讓它記錄咱們的操做,以防萬一。cdcp .bash_history  .bash_historybak  #備份cp .mysql_history .mysql_historybakrm .bash_history .mysql_historyln -s /dev/null .bash_history

ln -s /dev/null .mysql_history

 

11、修改history命令記錄

cp /etc/profile   /etc/profilebakvi /etc/profile

找到 HISTSIZE=1000 改成 HISTSIZE=50

 

12、隱藏服務器系統信息

在缺省狀況下,當你登錄到linux系統,它會告訴你該linux發行版的名稱、版本、內核版本、服務器的名稱。爲了避免讓這些默認的信息泄露出來,咱們要進行下面的操做,讓它只顯示一個"login:"提示符。刪除/etc/issue和/etc/issue.NET這兩個文件,或者把這2個文件更名,效果是同樣的。mv  /etc/issue /etc/issuebak

mv  /etc/issue.Net   /etc/issue.netbak

 

十3、優化Linux內核參數

cp /etc/sysctl.conf  /etc/sysctl.confbakvi /etc/sysctl.conf    #在文件末尾添加如下內容net.ipv4.ip_forward = 1 #修改成1net.core.somaxconn = 262144net.core.netdev_max_backlog = 262144net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.netfilter.ip_conntrack_max = 131072net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180net.ipv4.route.gc_timeout = 20net.ipv4.ip_conntrack_max = 819200net.ipv4.ip_local_port_range = 10024  65535net.ipv4.tcp_retries2 = 5net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_timestamps = 0net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_len = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_keepalive_time = 120net.ipv4.tcp_keepalive_probes = 3net.ipv4.tcp_keepalive_intvl = 15net.ipv4.tcp_max_tw_buckets = 36000net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_wmem = 8192 131072 16777216net.ipv4.tcp_rmem = 32768 131072 16777216net.ipv4.tcp_mem = 94500000 915000000 927000000/sbin/sysctl -p   #使配置當即生效十4、CentOS 系統優化cp  /etc/profile  /etc/profilebak2vi /etc/profile      #在文件末尾添加如下內容ulimit -c unlimitedulimit -s unlimitedulimit -SHn 65535ulimit -S -c 0export LC_ALL=Csource  /etc/profile    #使配置當即生效

ulimit -a    #顯示當前的各類用戶進程限制

 

十5、服務器禁止ping

cp  /etc/rc.d/rc.local  /etc/rc.d/rc.localbakvi  /etc/rc.d/rc.local        #在文件末尾增長下面這一行echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all參數0表示容許   1表示禁止

相關文章
相關標籤/搜索