现在的位置: 首页 > 综合 > 正文

system2之:7 进程管理

2014年01月27日 ⁄ 综合 ⁄ 共 16209字 ⁄ 字号 评论关闭

开机自动运行的命令,写到这个文件里: /etc/rc.local
linux从内核引导,读取的是/etc/fstab里的系统文件

遇到的问题:
    磁盘空间使用率100%,导致不能正常的进入系统,修改文件不能保存。

    原因是:日志接受功能打开,/var/log/相关日志文件使用了所有的剩余空间,个别文件(secure、messages)达到320G,建议关闭日志接受功能。

====
进程和程序的区别?
一个程序被加载到内存当中运行,那么在内存中的哪个数据就被称为进程,
进程是动态的,程序是静态的。
执行程序,建立起进程。

====

内核的作用:
    1.cpu的调度管理
    2.内存的管理
    3.文件系统的管理
    4.其他硬件的管理

    5.进程的管理

7.2.png

====
进程组成:
    程序部分、数据集合、pcb

pcb:也叫进程控制块,进程标识符(pid)、处理器的状态等信息

进程:一个进程可以包含很多线程
apache提供web服务,默认情况下采用进程的方式为用户提供web服务,一个用户对应一个进程。

进程和线程2种方式进行对比:
    进程方式比较稳定,一个进程死了,不会影响其他的进程,但是比较耗资源。
    线程方式开销比较小,节约内存和cpu的资源。可以同时应付大量的并发连接,但是缺点是一个进程死了,

    会殃及这个进程里的所有线程。不是非常稳定可靠。

7.1.png

    
=====

apache和nginx---》都是提供web服务的软件。

apache 默认情况下使用进程的方式工作,可以调为线程,追求稳定。做web服务器

nginx  采用线程的方式工作,追求高效率,大并发。

经典问题:

        进程怎么调为线程??

apache,nginx很重要

=====

内核态:系统管理进程
用户态:普通的用户打开的进程

=====
top  动态显示进程的信息,ps是静态的显示
ps - report a snapshot of the current processes.
top - display Linux tasks

ps

ps aux
ps -ef

init 是第一个进程,initial--》最初的,这里即初始化
[root@host log_bak]# ps aux|more
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2880  1252 ?        Ss   08:32   0:00 /sbin/init

子进程和父进程
PID-- ----PPID
[root@teacher ~]# bash
[root@teacher ~]# sh
sh-4.1# ps -ef
root      4356  3325  0 10:21 pts/1    00:00:00 bash
root      4366  4356  0 10:21 pts/1    00:00:00 sh
root      4367  4366  0 10:22 pts/1    00:00:00 ps -ef
可以看出bash是sh的父进程,sh是ps -ef的父进程

[root@host log_bak]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  8675  3094  0  80   0 -  1714 -      pts/4    00:00:00 bash
0 S     0  8689  8675  0  80   0 -  3792 -      pts/4    00:00:15 vncviewer
4 R     0  9499  8675  0  80   0 -  1618 -      pts/4    00:00:00 ps
[root@host log_bak]#

[root@host log_bak]# ps aux|more  常用的组合
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2880  1252 ?        Ss   08:32   0:00 /sbin/init
root         2  0.0  0.0      0     0 ?        S    08:32   0:00 [kthreadd]

[root@host log_bak]# cat /etc/shells   查看系统有哪些shell
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh

强制杀死:
先找出来:ps  aux
杀死:kill  -9  PID   -9是强制杀死

注意结果:

[root@teacher vnc]# ps aux|grep firefox
root      3675  0.1  1.3 465268 51244 pts/3    Sl   09:01   0:09 /usr/lib/firefox/firefox 10.0.0.253
root      4460  0.0  0.0   4336   744 pts/4    R+   10:56   0:00 grep firefox
[root@teacher vnc]#

top(五星级命令)

默认每隔3秒刷新一次

top -d 5 每隔5秒刷新显示一次
    h是获得帮助
    shift+>和shift+< 往上和下翻进程
    q 退出
    M    内存使用率
    P       proccesor  处理器cpu使用率
    k  kill

[root@host log_bak]# top

top - 17:16:11 up  8:43,  3 users,  load average: 0.25, 0.23, 0.20     ----》这里功能跟w,uptime同
Tasks: 188 total,   1 running, 187 sleeping,   0 stopped,   0 zombie
Cpu(s):  5.7%us, 11.1%sy,  0.0%ni, 82.3%id,  0.7%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   3984528k total,  3836292k used,   148236k free,    54676k buffers  往内存中写
Swap: 48838648k total,    15780k used, 48822868k free,  3108584k cached 读

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 5948 root      20   0 1670m 1.1g 1.0g S 31.9 28.8 121:36.90 vmware-vmx         
 2557 root      20   0  102m  33m  21m S  1.7  0.9   9:56.91 Xorg      

   2c. SUMMARY Area Fields
       The  summary area fields describing CPU statistics are abbreviated.
       They provide information about times spent in:
           us = user mode
           sy = system mode
           ni = low priority user mode (nice)
           id = idle task
           wa = I/O waiting
           hi = servicing IRQs 服务中断
           si = servicing soft IRQs
           st = steal (time given to other DomU instances)

pstree进程树

显示有差别(虚线和实线)
[root@teacher var]# pstree -p
[root@teacher var]# pstree -pA
===
[root@host log_bak]# nice  -10 stardict  启动stardict(前台) 并给予优先级10
[root@host log_bak]# nice  -10 stardict  启动stardict(后台)

进程间通信:管道、信号

[root@teacher vnc]# w
 11:21:43 up  2:54, 11 users,  load average: 0.28, 0.15, 0.12
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               08:30    6:54m 31.01s 31.01s /usr/b
root     pts/0    :0.0             08:31    2:50m 13:39   0.00s bash
root     pts/1    :3.0             08:31    8:38  21.76s  0.04s bash
root     pts/2    10.0.0.70        08:33    2:48m  0.00s  0.00s -bash
root     pts/3    :3.0             08:37    1:21m  1:07  17.27s ./vncw
root     pts/4    :3.0             10:06    0.00s  0.04s  0.00s w
liuyan   pts/5    10.0.0.6         11:19   40.00s  0.00s  0.00s -bash
liuyan   pts/6    10.0.0.2         11:18   39.00s  0.00s  0.00s -bash
root     pts/7    10.0.0.30        11:20   12.00s  0.00s  0.00s -bash
liuyan   pts/10   10.0.0.20        11:19   30.00s  0.02s  0.02s -bash
liuyan   pts/13   10.0.0.31        11:19    0.00s  0.01s  0.01s -bash
[root@teacher vnc]#
[root@teacher vnc]# pgrep -t pts/10  
4682
[root@teacher vnc]# w
 11:22:45 up  2:56, 11 users,  load average: 0.10, 0.12, 0.11
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               08:30    6:55m 31.40s 31.40s /usr/b
root     pts/0    :0.0             08:31    2:51m 13:47   0.00s bash
root     pts/1    :3.0             08:31    9:40  23.32s  0.04s bash
root     pts/2    10.0.0.70        08:33    2:49m  0.00s  0.00s -bash
root     pts/3    :3.0             08:37    1:22m  1:07  17.48s ./vncw
root     pts/4    :3.0             10:06    0.00s  0.04s  0.00s w
liuyan   pts/5    10.0.0.6         11:19    0.00s  0.00s  0.00s -bash
liuyan   pts/6    10.0.0.2         11:18    1:41   0.00s  0.00s -bash
root     pts/7    10.0.0.30        11:20   42.00s  0.00s  0.00s -bash
liuyan   pts/10   10.0.0.20        11:19    1:32   0.02s  0.02s -bash
liuyan   pts/13   10.0.0.31        11:19    1:01   0.01s  0.01s -bash
[root@teacher vnc]# pgrep -t pts/10  
4682
[root@teacher vnc]# pgrep -u liuyan -l
4681 sshd
4682 bash
4745 sshd
4746 bash
4777 sshd
4778 bash
[root@teacher vnc]#

[root@teacher vnc]# w  查看
 11:24:10 up  2:57, 10 users,  load average: 0.02, 0.09, 0.09
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               08:30    6:57m 31.86s 31.86s /usr/b
root     pts/0    :0.0             08:31    2:52m 13:58   0.00s bash
root     pts/1    :3.0             08:31   11:05  23.52s  0.04s bash
root     pts/2    10.0.0.70        08:33    2:51m  0.00s  0.00s -bash
root     pts/3    :3.0             08:37    1:24m  1:08  17.71s ./vncw
root     pts/4    :3.0             10:06    0.00s  0.05s  0.00s w
liuyan   pts/5    10.0.0.6         11:19   12.00s  0.01s  0.01s -bash
root     pts/6    10.0.0.30        11:23    0.00s  0.00s  0.00s -bash
liuyan   pts/10   10.0.0.20        11:19    2:57   0.02s  0.02s -bash
liuyan   pts/13   10.0.0.31        11:19    0.00s  0.03s  0.03s -bash

[root@teacher vnc]# pkill  -kill -t pts/13 根据终端号去kill某个进程(-u  根据用户)


=============================================


练习:
    杀死vim编辑的进程、firefox的进程、vnc连接的进程、yozo的相关进程、图片程序、ssh远程连接  
    杀死notecase程序前,建议保存好数据
    
练习:
    1.杀死所有的firefox进程
    2.杀死cpu使用率最高的进程
    top查看 然后P看到的最前面的就是
    3.杀死内存使用率最高的进程
    4.杀死打开的图片程序
    [root@host log_bak]# ps -aux
    root     11189  0.0  0.4  89128 19128 ?        Sl   19:29   0:00 eog /root/桌面/
        [root@host log_bak]# kill -9 11189
        ps -aux |grep png   过滤以.png结尾的图片

    5.输入stardict & 然后杀死后台运行的stardict进程
[root@host log_bak]# stardict&
[root@host log_bak]# ps
  PID TTY          TIME CMD
 8675 pts/4    00:00:00 bash
11267 pts/4    00:00:00 stardict
11292 pts/4    00:00:00 ps
[root@host log_bak]# kill -9  11267
[root@host log_bak]# ps
  PID TTY          TIME CMD
 8675 pts/4    00:00:00 bash
11293 pts/4    00:00:00 ps
[1]+  已杀死               stardict
[root@host log_bak]#

    6.如何知道机器里开启了多少进程?
    [root@host log_bak]# ps -aux|wc -l

    7.安装yum install httpd -y
        启动服务service httpd restart
        然后杀死所有的httpd进程
        
[root@host log_bak]# ps -aux|grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root     11369  0.0  0.0  11644  3436 ?        Ss   19:45   0:00 /usr/sbin/httpd
apache   11372  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11373  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11374  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11375  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11376  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11377  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11378  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
apache   11379  0.0  0.0  11644  2136 ?        S    19:45   0:00 /usr/sbin/httpd
root     11893  0.0  0.0   5960   760 pts/4    S+   20:36   0:00 grep httpd
[root@host log_bak]# pkill -u apache
[root@host log_bak]# ps -aux|grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root     11369  0.0  0.0  11644  3436 ?        Ss   19:45   0:00 /usr/sbin/httpd
apache   11897  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11898  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11899  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11900  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11901  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11902  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
apache   11903  0.0  0.0  11644  2136 ?        S    20:37   0:00 /usr/sbin/httpd
root     11905  0.0  0.0   5960   764 pts/4    S+   20:37   0:00 grep httpd
[root@host log_bak]#

时间变了

killall -9  httpd杀死所有的httpd进程

ps aux:新开启的进程,一般排在后面,因为pid号是不停的增加的

================

nice

7.3.png

[root@teacher vnc]# renice -10 5359
5359: old priority 0, new priority -10
[root@teacher vnc]#
top里也可以调整nice值(-20到19)

======

jobs

[root@teacher ~]# jobs    查看当前的后台工作状态
[1]   Stopped                 vim a
[2]-  Stopped                 vim b
[3]+  Stopped                 vim c
===
[root@teacher ~]# jobs -l
[1]   5481 Stopped (tty output)    vim a
[2]-  5482 Stopped (tty output)    vim b
[3]+  5483 Stopped (tty output)    vim c
===
[root@teacher ~]# fg 1  作业编号为1的从后台拿到前台执行
vim a
[root@teacher ~]# jobs
[2]-  Stopped                 vim b
[3]+  Stopped                 vim c
[root@teacher ~]#
===
[root@teacher proc]# kill -l
 1) SIGHUP     2) SIGINT     3) SIGQUIT     4) SIGILL 5) SIGTRAP
 6) SIGABRT     7) SIGBUS     8) SIGFPE     9) SIGKILL    10) SIGUSR1
11) SIGSEGV    12) SIGUSR2    13) SIGPIPE    14) SIGALRM    15) SIGTERM
16) SIGSTKFLT    17) SIGCHLD    18) SIGCONT    19) SIGSTOP    20) SIGTSTP
21) SIGTTIN    22) SIGTTOU    23) SIGURG    24) SIGXCPU    25) SIGXFSZ
26) SIGVTALRM    27) SIGPROF    28) SIGWINCH    29) SIGIO30) SIGPWR

[root@host log_bak]# jobs
[1]+  Running                 vncviewer 10.0.0.253:3 -shared -viewonly &
[root@host log_bak]# fg 1
vncviewer 10.0.0.253:3 -shared -viewonly   前台
^Z                  #  ctrl+z
[1]+  Stopped                 vncviewer 10.0.0.253:3 -shared -viewonly
[root@host log_bak]# jobs
[1]+  Stopped                 vncviewer 10.0.0.253:3 -shared -viewonly
[root@host log_bak]# fg 1    又可以动了,但还是前台
vncviewer 10.0.0.253:3 -shared -viewonly
^Z
[1]+  Stopped                 vncviewer 10.0.0.253:3 -shared -viewonly
[root@host log_bak]# bg 1   切换到后台
[1]+ vncviewer 10.0.0.253:3 -shared -viewonly &
[root@host log_bak]#
7.4.png

===
查看进程里的线程
[root@teacher vnc]# pstree -p|more
===
killall杀死httpd进程
[root@teacher vnc]# yum install httpd -y 安装httpd软件
[root@teacher vnc]# service httpd restart  启动httpd服务,产生进程
Stopping httpd:                                            [FAILED]
Starting httpd:                                            [  OK  ]
[root@teacher vnc]# ps aux|grep httpd|grep -v grep|wc -l  统计进程数
10
[root@teacher vnc]# killall httpd  杀死所有的httpd进程
[root@teacher vnc]#
[root@teacher vnc]# ps aux|grep httpd|grep -v grep|wc -l
0
[root@teacher vnc]#
[root@localhost ~]# pkill -9 -t pts/2 根据终端来杀死进程
[root@localhost ~]# w
 14:54:21 up  1:39,  3 users,  load average: 0.03, 0.03, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               13:15    1:39m 37.22s 37.22s /usr/bin/Xorg :0 -
root     pts/0    :0.0             13:28    1:25m 38.74s  0.00s bash
root     pts/3    10.0.0.253       14:49    0.00s  0.01s  0.00s w
[root@localhost ~]#
====
cp /dev/cdrom  /bak/rhel6.3.iso
将光驱里的光盘制作成一个叫rhel6.3.iso的镜像文件

[root@teacher vnc]# pkill -9 -t pts/2
====
[root@teacher vnc]# free  -m
             total       used       free     shared    buffers     cached
Mem:          3838       3644        193          0         84       2993
-/+ buffers/cache:        567       3271
Swap:        47693          0      47693
[root@teacher vnc]#
=====
buffers/cache  缓冲区/高速缓存    作用加速读写速度(buffers是往磁盘里写数据时的临时空间,cache是内存从磁盘里读数据的时候的临时空间)   都是占用内存空间
=====
[root@teacher proc]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)   单独的文件系统,空间是占用内存的空间
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
[root@teacher proc]#
=====
/proc文件系统里主要是存放内核状态信息和进程信息,可以调整这个目录里的相关文件来告诉内核进行相关操作。
====

[root@host proc]# vim /etc/sysctl.conf  开启路由功能的配置文件

图7.5
7.5.png

[root@host proc]# sysctl -p  使配置文件生效
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
[root@host proc]# cat  /proc/sys/net/ipv4/ip_forward  
1
[root@host proc]# echo 0 >/proc/sys/net/ipv4/ip_forward  
[root@host proc]# cat  /proc/sys/net/ipv4/ip_forward  
0
[root@host proc]#

查看路由功能是否开启,并关闭
[root@localhost sys]# cat /proc/sys/net/ipv4/ip_forward
[root@localhost sys]# echo 0 >/proc/sys/net/ipv4/ip_forward  关闭路由功能
[root@localhost sys]# echo 1 >/proc/sys/net/ipv4/ip_forward  开启路由功能
d[root@localhost sys]#
[root@localhost sys]# cat /proc/cpuinfo    cup信息
[root@localhost sys]# cat /proc/meminfo  内存的信息

yum install redhat-lsb
lsb_release  
===
[root@teacher proc]# dmidecode |grep -A16 "System Information$"
System Information
    Manufacturer: SUPoX COMPUTER CO.,LTD
    Product Name: SUPoX Intel H61 Series
    Version: 1.X
    Serial Number: None
    UUID: 03000200-0400-0500-0006-000700080009
    Wake-up Type: Power Switch
    SKU Number: None
    Family: None

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: SUPoX COMPUTER CO.,LTD
    Product Name: SUPoX Intel H61 Series
    Version: 1.X
    Serial Number: None
    Asset Tag: None

====
[root@teacher proc]# smartctl -a /dev/sda
smartctl 5.42 2011-10-20 r3458 [i686-linux-2.6.32-279.el6.i686] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD5000AVDS-73U7B1
Serial Number:    WD-WMAV93777404
====
[root@teacher proc]# cat /proc/cpuinfo | grep physical | uniq -c

      1 physical id    : 0
      1 address sizes    : 36 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 36 bits physical, 48 bits virtual
[root@teacher proc]# getconf LONG_BIT
32
[root@teacher proc]#
====
[root@teacher proc]# rpm -qf `which iostat`
sysstat-9.0.4-20.el6.i686
[root@teacher proc]#
[root@teacher proc]# iostat -dkt 5  每隔5秒显示磁盘i/o情况
====
[root@teacher proc]# mpstat   查看进程统计信息
Linux 2.6.32-279.el6.i686 (teacher.sxkeji.com)     03/24/2013     _i686_(2 CPU)

05:18:22 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
05:18:22 PM  all    3.93    0.00    1.04    0.59    0.00    0.17    0.00    0.00   94.28
[root@teacher proc]#
==========
练习:
    写一个脚本:监控httpd进程,一旦发现httpd进程不存在了,就启动httpd进程。每隔10分钟检测一次。
提醒:需要用到if判断
    top命令、ps、kill重点练习
==========
视频下载----http://10.0.0.253
=====
[root@teacher httpd]# bash -x h.sh  调试脚本运行 接  -x ,可以看到每步的结果
++ ps aux
++ wc -l
++ grep -v grep
++ grep httpd
+ Httpd=0
+ '[' 0 == 0 ']'
+ echo 'httpd服务未开启,正在开启服务.... '
httpd服务未开启,正在开启服务....
+ service httpd start 1 2
[root@teacher httpd]#
====
 大于greater than   小于less than
 -gt 大于
 -lt 小于
 -eq 等于
if [ $uu -gt 9 ]
===

====
练习:
    1.内存的插槽数、硬盘的品牌、主板的信息、当前的系统运行在32位下还是64位、有几颗cpu几个核、内核的版本、系统的版本

查看系统版本:
yum install redhat-lsb
lsb_release
cat /etc/issue 系统版本  

查看主板型号:

dmidecode |grep -A16 "System Information$"

内存槽及内存条:

dmidecode |grep -A16 "Memory Device$"

硬盘:

fdisk -l

smartctl -a /dev/sda

[root@host proc]# which iostat
/usr/bin/iostat
[root@host proc]# rpm -qf /usr/bin/iostat
sysstat-9.0.4-20.el6.i686
[root@host proc]# yum install sysstat-9.0.4-20.el6.i686
[root@host proc]# iostat
Linux 2.6.32-279.el6.i686 (host.com)     2013年07月24日     _i686_    (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.99    0.00    0.43    0.69    0.00   97.89

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               4.16       177.76        33.33     927588     173928

网卡:

mii-tool

=======
查看CPU信息(型号)
 
# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

      
8  
Intel(R) Xeon(R) CPU            E5410   @ 2.33GHz

(看到有8个逻辑CPU, 也知道了CPU型号)  
 
# cat /proc/cpuinfo | grep physical | uniq -c

      
4 physical id      : 0
      
4 physical id      : 1  
(说明实际上是两颗4核的CPU)  PS:Jay added on 10th, May, 2011  
#
其实是可能有超线程HT技术,不一定是有4核,也可能是2核4线程;当时还理解不清楚
 
 
# getconf LONG_BIT
   
32  (说明当前CPU运行在32bit模式下,但不代表CPU不支持64bit)  
 
# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

   
8  
(结果大于0,说明支持64bit计算. lm指long mode, 支持lm则是64bit)

 
 
再完整看cpu详细信息, 不过大部分我们都不关心而已.
# dmidecode | grep -A81 'Processor Information'

 
查看主板型号:
 
# dmidecode |grep -A16 "System Information$"

 
内存槽及内存条:
 
# dmidecode |grep -A16 "Memory Device$"
 
查看内存信息
 
# cat /proc/meminfo
 
# uname -a  
Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686

i386 GNU/Linux  
(查看当前操作系统内核信息)  
 
# cat /etc/issue | grep Linux  
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)

查看当前操作系统发行版信息
)  

[root@host proc]# getconf LONG_BIT   CPU最大是32位
32
[root@host proc]#

    
    
====

抱歉!评论已关闭.