rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 操作系统 » CentOS

CentOS常用基础命令

CentOS常用命令在我们的使用中,经常被使用。所以,我们对一些经常使用又很重要的CentOS常用命令进行了全面的整理。下面,就来介绍这些CentOS常用命令。 一:使用CentOS常用命令查看cpu ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.more /proc/cpuinfo | grep "model name"   2.grep "model name" /proc/cpuinfo   3.[root@localhost /]# grep "CPU" /proc/cpuinfo   4.model name      : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz   5.model name      : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz 如果觉得需要看的更加舒服 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.grep "model name" /proc/cpuinfo | cut -f2 -d: 二:使用CentOS常用命令查看内存 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.grep MemTotal /proc/meminfo   2.grep MemTotal /proc/meminfo | cut -f2 -d:   3.free -m |grep "Mem" | awk '{print $2}' 三:使用CentOS常用命令查看cpu是32位还是64位

查看CPU位数(32 or 64)

・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.getconf LONG_BIT 四:使用CentOS常用命令查看当前linux的版本 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.more /etc/redhat-release 2.cat /etc/redhat-release 五:使用CentOS常用命令查看内核版本 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.uname -r 2.uname -a 六:使用CentOS常用命令查看当前时间

date上面已经介绍如何同步时间了

七:使用CentOS常用命令查看硬盘和分区 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.df -h 2.fdisk -l 也可以查看分区 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.du -sh

可以看到全部占用的空间

・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.du /etc -sh

可以看到这个目录的大小

八:使用CentOS常用命令查看安装的软件包

查看系统安装的时候装的软件包

・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.cat -n /root/install.log 2.more /root/install.log | wc -l

查看现在已经安装了那些软件包

・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.rpm -qa 2.rpm -qa | wc -l 3.yum list installed | wc -l

不过很奇怪,我通过rpm,和yum这两种方式查询的安装软件包,数量并不一样。没有找到原因。

九:使用CentOS常用命令查看键盘布局 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.cat /etc/sysconfig/keyboard 2.cat /etc/sysconfig/keyboard | grep KEYTABLE | cut -f2 -d= 十:使用CentOS常用命令查看selinux情况 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.sestatus 2.sestatus | cut -f2 -d: 3.cat /etc/sysconfig/selinux 十一:使用CentOS常用命令查看ip,mac地址 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 01.在ifcfg-eth0 文件里你可以看到mac,网关等信息。   02.ifconfig   03.cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR   04.cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut -f2 -d=   05.ifconfig eth0 |grep "inet addr:" |awk '{print $2}'|cut -c 6-   06.ifconfig   | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'   07.查看网关   08.cat /etc/sysconfig/network   09.查看dns   10.cat /etc/resolv.conf 十二:使用CentOS常用命令查看默认语言 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.echo $LANG $LANGUAGE 2.cat /etc/sysconfig/i18n 十三:使用CentOS常用命令查看所属时区和是否使用UTC时间 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.cat /etc/sysconfig/clock 十四:使用CentOS常用命令查看主机名 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.hostname 2.cat /etc/sysconfig/network

修改主机名就是修改这个文件,同时最好也把host文件也修改。

十五:使用CentOS常用命令查看开机运行时间 ・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.uptime 2.09:44:45 up 67 days, 23:32, ...

看来刚才确实是网段的问题,我的机器还是67天前开机的。

#系统资源使用情况

・・・・・・・・・10・・・・・・・・20・・・・・・・・30・・・・・・・・40・・・・・・・・50・・・・・・・・60・・・・・・・・70・・・・・・・・80・・・・・・・・90 1.vmstat 1 -S m   2.procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------   3.r b   swpd   free   buff cache   si   so    bi    bo   in   cs us sy id wa st   4.0 0      0    233    199    778    0    0     4    25    1    1 3 0 96 0 0   5.0 0      0    233    199    778    0    0     0     0 1029 856 13 1 86 0 0
顶一下
(0)
踩一下
(1)