今天给大家展示一下多用于查看系统状态信息的命令,分别是lscpu,free,df,uptime,uname以及w
lscpu #查看cpu信息
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 1 #核心数 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 #cpu颗数 NUMA node(s): 1 Vendor ID: AuthenticAMD CPU family: 23 Model: 96 Model name: AMD Ryzen 7 4800H with Radeon Graphics Stepping: 1 CPU MHz: 2894.561 BogoMIPS: 5789.12 Hypervisor vendor: VMware Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 512K L3 cache: 4096K NUMA node0 CPU(s): 0 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2free #查看内存和swap
[root@backup ~]# free # 总大小 已使用 空闲 共享内存 缓冲/缓存 可用内存 total used free shared buff/cache available Mem: 2027868 178760 1716552 9792 132556 1702516 Swap: 2097148 0 2097148 [root@backup ~]# free -h #以人类可读形式展示 total used free shared buff/cache available Mem: 1.9G 174M 1.6G 9.6M 129M 1.6G Swap: 2.0G 0B 2.0G [root@backup ~]# free -m #以MB为单位展示 total used free shared buff/cache available Mem: 1980 174 1676 9 129 1662 Swap: 2047 0 2047df #分区使用情况
[root@backup ~]# df #硬件名称 大小 已用 可用 使用率 挂载点 Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 1001920 0 1001920 0% /dev tmpfs 1013932 0 1013932 0% /dev/shm tmpfs 1013932 9792 1004140 1% /run tmpfs 1013932 0 1013932 0% /sys/fs/cgroup /dev/mapper/centos-root 49250820 2638936 46611884 6% / /dev/sda1 1038336 140696 897640 14% /boot tmpfs 202788 0 202788 0% /run/user/0 [root@backup ~]# df -h #以人类可读形式展示 Filesystem Size Used Avail Use% Mounted on devtmpfs 979M 0 979M 0% /dev tmpfs 991M 0 991M 0% /dev/shm tmpfs 991M 9.6M 981M 1% /run tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/mapper/centos-root 47G 2.6G 45G 6% / /dev/sda1 1014M 138M 877M 14% /boot tmpfs 199M 0 199M 0% /run/user/0 [root@backup ~]# df -i #显示inode使用情况 Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 250480 390 250090 1% /dev tmpfs 253483 1 253482 1% /dev/shm tmpfs 253483 749 252734 1% /run tmpfs 253483 16 253467 1% /sys/fs/cgroup /dev/mapper/centos-root 24637440 62489 24574951 1% / /dev/sda1 524288 326 523962 1% /boot tmpfs 253483 1 253482 1% /run/user/0 [root@backup ~]# df -T #查看文件系统类型 Filesystem Type 1K-blocks Used Available Use% Mounted on devtmpfs devtmpfs 1001920 0 1001920 0% /dev tmpfs tmpfs 1013932 0 1013932 0% /dev/shm tmpfs tmpfs 1013932 9792 1004140 1% /run tmpfs tmpfs 1013932 0 1013932 0% /sys/fs/cgroup /dev/mapper/centos-root xfs 49250820 2638944 46611876 6% / /dev/sda1 xfs 1038336 140696 897640 14% /boot tmpfs tmpfs 202788 0 202788 0% /run/user/0uptime #查看系统负载情况
[root@backup ~]# uptime # 当前时间 运行时长 目前连接数 平均负载 一分钟 五分钟 十五分钟 17:04:20 up 4:50, 2 users, load average: 0.00, 0.01, 0.05w #与uptime类似,查询谁登陆了系统,并且正在做什么
[root@backup ~]# w 17:06:28 up 4:52, 2 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 10.0.0.1 12:26 3:07m 0.08s 0.08s -bash root pts/1 10.0.0.1 13:55 4.00s 0.16s 0.00s w #登录用户 终端 哪个IP链接的 登陆时间 正在执行什么命令uname #查看系统名
[root@backup ~]# uname Linux [root@backup ~]# uname -a #查看完整的系统内核版本 Linux backup 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux [root@backup ~]# uname -r #查看内核版本号 3.10.0-1160.el7.x86_64拓展内容:whereis,which,man,--help这四个命令都是用于查询命令相关,接下来我给大家展示一下具体用法
which #查询命令位置
[root@backup ~]# which cd /usr/bin/cdwhereis #which进阶版,查询命令位置及其帮助
[root@backup ~]# whereis cd cd: /usr/bin/cd /usr/share/man/man1/cd.1.gz /usr/share/man/mann/cd.n.gzman #查询命令帮助,中括号中的内容可以省略
[root@backup ~]# man pwd PWD(1) User Commands PWD(1) NAME #命令简介 pwd - print name of current/working directory SYNOPSIS #命令格式 pwd [OPTION]... DESCRIPTION #选项 Print the full filename of the current working directory. -L, --logical use PWD from environment, even if it contains symlinks -P, --physical avoid all symlinks --help display this help and exit --version output version information and exit--help #查询命令帮助
[root@backup ~]# rm --help Usage: rm [OPTION]... FILE... #命令格式 Remove (unlink) the FILE(s). #命令简介 #以下为命令选项 -f, --force ignore nonexistent files and arguments, never prompt -i prompt before every removal -I prompt once before removing more than three files, or when removing recursively; less intrusive than -i, while still giving protection against most mistakes --interactive[=WHEN] prompt according to WHEN: never, once (-I), or always (-i); without WHEN, prompt always --one-file-system when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument --no-preserve-root do not treat '/' specially --preserve-root do not remove '/' (default) -r, -R, --recursive remove directories and their contents recursively -d, --dir remove empty directories -v, --verbose explain what is being done --help display this help and exit --version output version information and exit By default, rm does not remove directories. Use the --recursive (-r or -R) option to remove each listed directory, too, along with all of its contents. To remove a file whose name starts with a '-', for example '-foo', use one of these commands: rm -- -foo rm ./-foo Note that if you use rm to remove a file, it might be possible to recover some of its contents, given sufficient expertise and/or time. For greater assurance that the contents are truly unrecoverable, consider using shred. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'rm invocation'