zoukankan      html  css  js  c++  java
  • centos 7 查看系统/硬件信息及运维常用命令+联想Y430P无线网卡驱动安装

     centos 7 查看系统/硬件信息及运维常用命令

    当前环境:联想Y430P  CentOS 7.3

    [root@yan-001 ~] # uname -a # 查看内核/操作系统/CPU信息的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不是字母L

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

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

      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系统信息命令

    [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无线网卡驱动安装

    安装路径的建立并解压
    # 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文件夹

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

    编译安装

    # 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分区的信息

    一、注释掉系统不需要的用户和用户组注意:不建议直接删除,当你需要某个用户时,自己重新添加会很麻烦。   

    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:

    二、关闭系统不需要的服务

    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  

    三、禁止非root用户执行/etc/rc.d/init.d/下的系统命令

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

    chmod -R 777 /etc/rc.d/init.d/*    #恢复默认设置  

    四、给下面的文件加上不可更改属性,从而防止非授权用户获得权限

    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   #取消系统服务端口列表文件加锁

    现在可以进行添加删除用户了,操作完之后再锁定目录文件

    五、限制不同文件的权限

    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

    六、禁止使用Ctrl+Alt+Del快捷键重启服务器

    cp /etc/inittab  /etc/inittabbakvi /etc/inittab    #注释掉下面这一行

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

    七、使用yum update更新系统时不升级内核,只更新软件包由于系统与硬件的兼容性问题,有可能升级内核后导致服务器不能正常启动,这是非常可怕的,没有特别的需要,建议不要随意升级内核。

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

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

    2、直接在yum的命令后面加上如下的参数:yum --exclude=kernel* update查看系统版本  cat /etc/issue

    查看内核版本  uname -a

    八、关闭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  #禁止开启启动(系统模式为3、5)

    chkconfig yum-updatesd off  #禁止开启启动(所有启动模式全部禁止)

    chkconfig --list yum-updatesd  #显示当前系统状态

    yum-updatesd    0:关闭  1:关闭  2:启用  3:关闭  4:启用  5:关闭  6:关闭

    九、关闭多余的虚拟控制台

    我们知道从控制台切换到 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

    十、删除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

    十一、修改history命令记录

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

    找到 HISTSIZE=1000 改为 HISTSIZE=50

    十二、隐藏服务器系统信息

    在缺省情况下,当你登陆到linux系统,它会告诉你该linux发行版的名称、版本、内核版本、服务器的名称。为了不让这些默认的信息泄露出来,我们要进行下面的操作,让它只显示一个"login:"提示符。删除/etc/issue和/etc/issue.NET这两个文件,或者把这2个文件改名,效果是一样的。mv  /etc/issue /etc/issuebak

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

    十三、优化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   #使配置立即生效十四、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    #显示当前的各种用户进程限制

    十五、服务器禁止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表示禁止

  • 相关阅读:
    Python全栈开发:socket
    Python全栈开发:线程、进程和协程
    Python全栈开发:基本数据类型
    Python全栈开发:运算符
    使用pyplot和seaborn进行画图
    数据预处理之缺失值的处理
    数据预处理之标准化
    数据预处理之离散化
    集成学习中的 stacking 以及python实现
    使用sklearn进行交叉验证
  • 原文地址:https://www.cnblogs.com/endv/p/6431668.html
Copyright © 2011-2022 走看看