当前位置:首页 > linux基础 > 正文内容

linux 查看系统信息命令

5年前 (2019-10-17)linux基础944

# uname -a # 查看内核/操作系统/CPU信息 

# head -n 1 /etc/issue # 查看操作系统版本 

# cat /proc/cpuinfo # 查看CPU信息 

# hostname # 查看计算机名 

# lspci -tv # 列出所有PCI设备 

# lsusb -tv # 列出所有USB设备 

# lsmod # 列出加载的内核模块 

# env # 查看环境变量资源 

# free -m # 查看内存使用量和交换区使用量 

# df -h # 查看各分区使用情况 

# du -sh <目录名> # 查看指定目录的大小 

# grep MemTotal /proc/meminfo # 查看内存总量 

# grep MemFree /proc/meminfo # 查看空闲内存量 

# uptime # 查看系统运行时间、用户数、负载 

# cat /proc/loadavg # 查看系统负载磁盘和分区 

# mount | column -t # 查看挂接的分区状态 

# fdisk -l # 查看所有分区 

# swapon -s # 查看所有交换分区 

# hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) 

# dmesg | grep IDE # 查看启动时IDE设备检测状况网络 

# ifconfig # 查看所有网络接口的属性 

# iptables -L # 查看防火墙设置 

# route -n # 查看路由表 

# netstat -lntp # 查看所有监听端口 

# netstat -antp # 查看所有已经建立的连接 

# netstat -s # 查看网络统计信息进程 

# ps -ef # 查看所有进程 

# top # 实时显示进程状态用户 

# w # 查看活动用户 

# id <用户名> # 查看指定用户信息 

# last # 查看用户登录日志 

# cut -d: -f1 /etc/passwd # 查看系统所有用户 

# cut -d: -f1 /etc/group # 查看系统所有组 

# crontab -l # 查看当前用户的计划任务服务 

# chkconfig –list # 列出所有系统服务 

# chkconfig –list | grep on # 列出所有启动的系统服务程序 

# rpm -qa # 查看所有安装的软件包


查看linux系统版本信息(Oracle Linux、Centos、Redhat、Debian、Ubuntu)

一、查看Linux系统版本的命令(3种方法)

1、cat /etc/issue,此命令也适用于所有的Linux发行版。


  [root@S-CentOS home]# cat /etc/issue

  CentOS release 6.5 (Final)

  Kernel \r on an \m


2、cat /etc/redhat-release,这种方法只适合Redhat系的Linux:


  [root@S-CentOS home]# cat /etc/redhat-release

  CentOS release 6.5 (Final)


 3、lsb_release -a,即可列出所有版本信息:


  [root@S-CentOS ~]# lsb_release -a

  LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch

  Distributor ID: CentOS



一、linux CPU大小

  cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep "physical id"



二、内存大小


cat /proc/meminfo |grep MemTotal


三、硬盘大小

fdisk -l |grep Disk


六、cat /proc/cpuinfo # 查看CPU信息的linux系统信息命令


七、hostname # 查看计算机名的linux系统信息命令


八、lspci -tv # 列出所有PCI设备


九、lsusb -tv # 列出所有USB设备的linux系统信息命令


十、lsmod # 列出加载的内核模块


十一、env # 查看环境变量资源


十二、free -m # 查看内存使用量和交换区使用量


十三、df -h # 查看各分区使用情况

十四、du -sh # 查看指定目录的大小

十五、grep MemTotal /proc/meminfo # 查看内存总量

十六、grep MemFree /proc/meminfo # 查看空闲内存量

十七、uptime # 查看系统运行时间、用户数、负载

十八、cat /proc/loadavg # 查看系统负载磁盘和分区

十九、mount | column -t # 查看挂接的分区状态

二十、fdisk -l # 查看所有分区

二十一、swapon -s # 查看所有交换分区

二十二、hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)

二十三、dmesg | grep IDE # 查看启动时IDE设备检测状况网络

二十四、ifconfig # 查看所有网络接口的属性

二十五、iptables -L # 查看防火墙设置

二十六、route -n # 查看路由表

二十七、netstat -lntp # 查看所有监听端口

二十八、netstat -antp # 查看所有已经建立的连接

二十九、netstat -s # 查看网络统计信息进程

三十、ps -ef # 查看所有进程

三十一、top # 实时显示进程状态用户

三十二、w # 查看活动用户

三十三、id # 查看指定用户信息

三十四、last # 查看用户登录日志

三十五、cut -d: -f1 /etc/passwd # 查看系统所有用户

三十六、cut -d: -f1 /etc/group # 查看系统所有组

三十七、crontab -l # 查看当前用户的计划任务服务

三十七、chkconfig –list # 列出所有系统服务

三十八、chkconfig –list | grep on # 列出所有启动的系统服务程序

三十九、rpm -qa # 查看所有安装的软件包

四十、cat /proc/cpuinfo :查看CPU相关参数的linux系统命令

四十一、cat /proc/partitions :查看linux硬盘和分区信息的系统信息命令

四十二、cat /proc/meminfo :查看linux系统内存信息的linux系统命令

四十三、cat /proc/version :查看版本,类似uname -r

四十四、cat /proc/ioports :查看设备io端口

四十五、cat /proc/interrupts :查看中断

四十六、cat /proc/pci :查看pci设备的信息

四十七、cat /proc/swaps :查看所有swap分区的信息


防火墙会限制端口只能用虚拟机图形操作:


firewall-cmd --state 查看火墙状态


firewall-cmd --get-active-zones列出当前被系统使用的域


firewall-cmd --get-default-zone查看火墙默认生效的域


firewall-cmd --get-zones查看默认的规则


firewall-cmd --list-all-zones查看所有的域


firewall-cmd --zone=public --list-all查看public域里面的信息


firewall-cmd --get-services列出系统中用名称表示的服务


firewall-cmd --set-default-zone=dmz 设定默认使用的域


[root@client Desktop]# yum install firewalld firewalld-config 安装


[root@client Desktop]# firewall-config 会直接打开界面


[root@client Desktop]# systemctl stop iptables 关闭iptables


[root@client Desktop]# systemctl disable iptables 开机自动关闭


[root@client Desktop]# systemctl start firewalld 打开防火墙


[root@client Desktop]# systemctl enable firewalld 开机自动开启


[root@client Desktop]# yum search iptables 寻找iptables安装包


[root@client Desktop]# yum install iptables-services.x86_64 安装


firewall-cmd --state 查看火墙状态


running


[root@client Desktop]# firewall-cmd --get-active-zones 列出当前被系统使用的域


ROL


sources: 172.25.0.252/32


public


interfaces: eth0


[root@client Desktop]# firewall-cmd --get-default-zone 查看火墙默认生效的域


public


[root@client Desktop]# firewall-cmd --get-zones 查看默认的规则


ROL block dmz drop external home internal public trusted work



系统发行版本--内核版本、位数
RedHatcat /etc/issuecat /etc/redhat-releaselsb_release -a
CentOScat /etc/issuecat /etc/centos-releasecat /proc/version
Debiancat /etc/issuecat /etc/debian_versioncat /proc/version
Ubuntucat /etc/issuecat /etc/lsb_releasecat /proc/version
Oraclecat /etc/issuecat /etc/oracle-releaselsb_release -a


RedHat


查看系统发行版本

[root@getlnx05 ~]# cat /etc/issue

Red Hat Enterprise Linux Server release 5.7 (Tikanga)

Kernel \r on an \m

通过cat /etc/redhat-release也查到看到相关的信息。



查看系统内核版本、位数

[root@getlnx05 ~]# lsb_release -a

LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: RedHatEnterpriseServer

Description:    Red Hat Enterprise Linux Server release 5.7 (Tikanga)

Release:        5.7

Codename:      Tikanga

LSB Version项显示的是系统的内核版本,其中amd64表示系统是64位的。


CentOS


查看系统发行版本 cat /etc/issue

[chenyurong@localhost local]$ cat /etc/issue

CentOS release 6.5 (Final)

Kernel \r on an \m

通过cat /etc/centos-release也可以查询到一样的信息。



查看系统内核版本、位数 more /proc/version

[chenyurong@localhost local]$ cat /proc/version

Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013

Linux version 2.6.32-431.el6.x86_64显示了Linux的版本,x86_64显示了是64位的系统。通过uname -r也可以查到相关信息。


Oracle Linux


查看系统发行版本

[root@DB-Server ~]# cat /etc/issue

Oracle Linux Server release 5.7

Kernel \r on an \m

通过cat /etc/oracle-release也可以查询到相关信息。



查看系统内核版本、位数

[root@DB-Server ~]# lsb_release -a

LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: EnterpriseEnterpriseServer

Description:    Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)

Release:        5.7

Codename:      Carthage

LSB Version显示的是系统的内核版本,其中amd64表示系统是64位的。


查看系统发行版本

命令 适用范围

lsb_release -a 所有Linux发行版

cat /etc/redhat-release RedHat系Linux

cat /etc/issue 所有Linux发行版


查看系统内核位数

命令 适用范围

uname -a、uname -r 所有Linux发行版

cat /proc/version 所有Linux发行版


“linux 查看系统信息命令” 的相关文章

find文件查找

find查找find命令可以根据不同的条件来进行查找文件,例如:文件名称、文件大小、文件修改时间、属主属组、权限、等等方式。同时find命令是Linux下必须掌握的。find 命令的基本语法如下命令路径选项表达式动作find[path...][options][expression][action]...

sersync实时同步

sersync实时同步

实时同步概述实时同步是一种只要当前目录发生变化则会触发一个事件,事件触发后会将变化的目录同步至远程服务器。保证数据的连续性, 减少人力维护成本,解决nfs单点故障实时同步工具选择sersync+rsync(√)、inotify+rsyncInotify是一个通知接口,用来监控文件系统的各种变化,如果...

Shell介绍(一)变量、传参、数值运算

Shell编程1.什么情况下使用Shell1:安装CentOS系统 自动化安装操作系统(kickstart cobbler) 底层shell2:网络IP地址3:初始化操作系统(ntp时间同步,更改默认YUM源,SSH端口,SSH远程连接禁止DNS解析,禁止root登录,关闭seilnux,防火墙优化...

Shell介绍(三)if判断,case控制,for循环,while循环,流程控制语句

if判断单分支if [你有房] then     我就嫁给你 fi多分支if [ 你有房 ] then     我就嫁给你 else   &nbs...

Shell介绍(四)条件表达式,字符串比对

条件表达式[ ]======test   []常用[ -f file ] 文件是否存在 且为普通文件 重点[ -e file ] 文件存在则为真[ -d file ] 目录存在则为真 重点[ -x file ] 文件有执行权限则为真[ -w file ] 文件可写则为真[...

自动化运维(一)Ansible安装及模块的使用

自动化运维(一)Ansible安装及模块的使用

1:Ansible安装1.什么是AnsibleAnsible是python 中的一套模块,系统中的一套自动化工具,只需要使用ssh协议连接及可用来系统管理、自动化执行命令等任务。2.Ansible优势1、ansible不需要单独安装客户端,也不需要启动任何服务2、ansible是python中的一套...