A-A+
CentOS硬件信息收集与运维中常用命令
今天总结一下在安全运维中对于硬件信息收集过程会用到的linux命令。
演示环境:CentOS 7
1.CentOS常用命令查看 CPU
[root@localhost ~]# more /proc/cpuinfo | grep "model name"
model name : Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
[root@localhost ~]#
2.CentOS常用命令查看内存
[root@localhost ~]# free -m
total used free shared buff/cache available
Mem: 976 678 70 3 227 82
Swap: 2047 4 2043
[root@localhost ~]#
3.CentOS常用命令查看cpu是32位还是64位
[root@localhost ~]# getconf LONG_BIT
64
[root@localhost ~]#
4.使用CentOS常用命令查看当前linux的版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]#
5.使用CentOS常用命令查看内核版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64
[root@localhost ~]#
6.使用CentOS常用命令查看硬盘和分区
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 17G 8.0G 9.1G 47% /
devtmpfs 473M 0 473M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 7.2M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 1014M 161M 854M 16% /boot
tmpfs 98M 4.0K 98M 1% /run/user/42
tmpfs 98M 36K 98M 1% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]#
7.使用CentOS常用命令查看selinux情况
[root@localhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
[root@localhost ~]#
8.查看IP地址
[root@localhost ~]# ifconfig
9.使用CentOS常用命令查看所属时区和是否使用UTC时间
- CentOS 7查看方法:
[root@localhost ~]# timedatectl
Local time: 三 2018-10-03 17:17:22 UTC
Universal time: 三 2018-10-03 17:17:22 UTC
RTC time: 三 2018-10-03 17:17:22
Time zone: Universal (UTC, +0000)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]# date
2018年 10月 03日 星期三 17:17:39 UTC
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai
[root@localhost ~]# timedatectl
Local time: 四 2018-10-04 01:18:46 CST
Universal time: 三 2018-10-03 17:18:46 UTC
RTC time: 三 2018-10-03 17:18:46
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]# date
2018年 10月 04日 星期四 01:20:02 CST
[root@localhost ~]# rm -rf /etc/localtime
[root@localhost ~]# ln -s /usr/share/zoneinfo/Universal /etc/localtime
[root@localhost ~]# timedatectl
Local time: 三 2018-10-03 17:22:44 UTC
Universal time: 三 2018-10-03 17:22:44 UTC
RTC time: 三 2018-10-03 17:22:43
Time zone: Universal (UTC, +0000)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]# date
2018年 10月 03日 星期三 17:22:51 UTC
[root@localhost ~]#
- CentOS 6查看方法:
# cat /etc/sysconfig/clock
10.使用CentOS常用命令查看主机名
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]#
11.使用CentOS常用命令查看开机运行时间
[root@localhost ~]# uptime
16:49:14 up 2:22, 2 users, load average: 0.00, 0.01, 0.05
[root@localhost ~]#
12.查看主板信息
[root@localhost ~]# dmidecode | more
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
620 structures occupying 29060 bytes.
Table at 0x000E0010.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Phoenix Technologies LTD
Version: 6.00
Release Date: 05/19/2017
Address: 0xEA520
Runtime Size: 88800 bytes
ROM Size: 64 kB
Characteristics:
ISA is supported
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
Selectable boot is supported
EDD is supported
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
Smart battery is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
--More--
13.查看磁盘使用情况
[root@localhost ~]# fdisk -l
磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d1bd6
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
[root@localhost ~]#
参考文章:http://zone.secevery.com/article/995
评论已关闭!