Linux命令(一)

来源:互联网 发布:真皮床哪个品牌好 知乎 编辑:程序博客网 时间:2024/05/29 18:34

#CPU

# 物理CPU个数:

[root@demo ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

# CPU中core的个数(核数):

[root@demo ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq

# 逻辑CPU的个数:

[root@demo ~]# cat /proc/cpuinfo | grep "processor" | wc -l

#内存

# 内存使用情况

[root@demo ~]# free -m

[root@demo ~]# free -m

            total       used       free     shared    buffers     cached

Mem:          2010        277       1733          0         15        159

-/+ buffers/cache:        102       1908

Swap:         2047          0       2047

说明:

shared:多个进程共享的内存总额

- buffers/cache:  已用的内存数,即 used-buffers-cached

+ buffers/cache:  可用的内存数,即 free+buffers+cached

计算:

可用内存=free+buffers+cached,即 1733MB + 15MB + 159MB =  1907MB

内存总数= total(2010) = used (277) +free (1733)

- buffers/cache: used-buffers-cached = 102

+ buffers/cache:  free+buffers+cached = 1908

可见-buffers/cache反映的是被程序实实在在用掉的内存,+buffers/cache 反映的是可以挪用的内存总数。

#硬盘

#查看硬盘及分区信息

[root@demo ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1912    15358108+  83  Linux

/dev/sda2            1913        2173     2096482+  82  Linux swap / Solaris

/dev/sda3            2174        2610     3510202+  83  Linux

#检查文件系统磁盘空间使用情况:

[root@demo ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1              15G  3.1G   11G  23% /

/dev/sda3             3.3G  109M  3.0G   4% /opt

tmpfs                1006M     0 1006M   0% /dev/shm

# 查看硬盘IO性能

[root@demo ~]# iostat -d -x -k 1 10

# 查看某目录的大小

[root@demo ~]# du -sh /root

100M  /root

# dd 命令把指定的输入文件拷贝到指定的输出文件中,并且在拷贝过程中可以进行格式转换

   制作交换文件:

                dd if=/dev/zero of=/swapfile bs=1024 count=65536

    制作驱动盘:

               dd if = rhel40.img of =/dev/fd0 bs=10k

    制作ISO镜像:

               dd if=/dev/cdrom of=/root/cd.iso

# 查看平均负载

[root@demo /]# uptime

06:45:21 up 54 min,  1 user,  load average: 0.00, 0.00, 0.00

[root@demo /]# top

# 查看当前哪些用户占用了哪些终端

[root@demo /]# w

# 整体性能分析工具

[root@demo /]# vmstat 1 5

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

0  0      0 1717596  18868 212380    0    0    67    26  844   35  0  1 97  1  0

0  0      0 1717596  18868 212380    0    0     0     0  827   28  0  0 100  0  0

0  0      0 1717596  18868 212380    0    0     0     0  848   31  0  2 98  0  0

0  0      0 1717596  18876 212380    0    0     0    36  830   21  0  0 100  0  0

0  0      0 1717596  18876 212380    0    0     0     0  846   31  0  0 100  0  0

# 查看内核

[root@demo /]# uname -a

Linux demo.com 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[root@demo /]# uname -r

2.6.18-194.el5

# 查看系统32/64位

[root@demo /]# ls -lF /| grep /$

drwxr-xr-x   2 root root  4096 Jul 28 20:27 bin/

drwxr-xr-x   3 root root  4096 Jul 10 17:47 boot/

drwxr-xr-x   2 root root  4096 Jul 15 01:42 demo/

drwxr-xr-x  12 root root  3940 Sep  3 05:52 dev/

drwxr-xr-x 100 root root 12288 Sep  3 05:52 etc/

drwxr-xr-x   3 root root  4096 Jul 14 20:04 home/

drwxr-xr-x  11 root root  4096 Jul 28 20:26 lib/

drwxr-xr-x   7 root root  4096 Jul 28 20:26 lib64/

drwx------   2 root root 16384 Jul 10 17:38 lost+found/

drwxr-xr-x   2 root root  4096 Jan 27  2010 media/

drwxr-xr-x   2 root root  4096 Mar 31  2010 misc/

drwxr-xr-x   3 root root  4096 Jul 16 19:41 mnt/

drwxr-xr-x   3 root root  4096 Sep  2 01:59 mongodb/

dr-xr-xr-x   2 root root  4096 Jul 14 23:59 net/

drwxr-xr-x   4 root root  4096 Jul 28 20:01 opt/

dr-xr-xr-x 107 root root     0 Sep  3 05:51 proc/

drwxr-x---   6 root root  4096 Sep  2 01:58 root/

drwxr-xr-x   2 root root 12288 Jul 28 20:27 sbin/

drwxr-xr-x   4 root root     0 Sep  3 05:51 selinux/

drwxr-xr-x   2 root root  4096 Jan 27  2010 srv/

drwxr-xr-x  11 root root     0 Sep  3 05:51 sys/

drwxr-xr-x   2 root root     0 Sep  3 05:52 testnfs/

drwxrwxrwt   4 root root  4096 Sep  3 05:52 tmp/

drwxr-xr-x  15 root root  4096 Jul 10 17:41 usr/

drwxr-xr-x  23 root root  4096 Jul 28 19:43 var/

[root@demo /]# file /sbin/init

/sbin/init: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

# 查看服务器使用Linux发行版的名称、版本号及描述信息等:

[root@demo /]# lsb_release -a

LSB Version:  :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch

Distributor ID:  CentOS

Description:  CentOS release 5.5 (Final)

Release:  5.5

Codename:  Final

# 查看系统已载入相关模块

[root@demo /]# lsmod | grep ip_vs

# 查找PCI设置

[root@demo /]# lspci | grep Ether

02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)