基本的Linux命令(二)

系统状态检测命令

ifconfig命令

ifconfig命令用于获取网卡配置与网络状态等信息,格式为“ifconfig [网络设备] [参数]”。
使用ifconfig命令来查看本机当前的网卡配置与网络状态等信息时,其实主要查看的就是网卡名称、inet参数后面的IP地址、ether参数后面的网卡物理地址(又称为MAC地址),以及RX、TX的接收数据包与发送数据包的个数及累计流量(即下面加粗的信息内容):
[root@locahost ~]# ifconfig
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::20c:29ff:fec4:a409 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:c4:a4:09 txqueuelen 1000 (Ethernet)
RX packets 36 bytes 3176 (3.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 4757 (4.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 386 bytes 32780 (32.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 386 bytes 32780 (32.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

uname命令

uname命令用于查看系统内核与系统版本等信息,格式为“uname [-a]”。
[root@locahost ~]# uname -a
Linux linuxprobe.com 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2019
x86_64 x86_64 x86_64 GNU/Linux
如果要查看当前系统版本的详细信息,则需要查看redhat-release文件,其命令以及相应的结果如下:
[root@locahost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)

uptime命令

uptime用于查看系统的负载信息,格式为uptime。
可以显示当前系统时间、系统已运行时间、启用终端数量以及平均负载值等信息。平均负载值指的是系统在最近1分钟、5分钟、15分钟内的压力情况(下面加粗的信息部分);负载值越低越好,尽量不要长期超过1,在生产环境中不要超过5。
[root@locahost ~]# uptime
22:49:55 up 10 min, 2 users, load average: 0.01, 0.19, 0.18

free命令

free用于显示当前系统中内存的使用量信息,格式为“free [-h]”。
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 1.9G 608M 862M 10M 513M 1.1G
Swap: 2.0G 0B 2.0G

who命令

who用于查看当前登入主机的用户终端信息,格式为“who [参数]”。
[root@localhost ~]# who
root :0 2019-06-06 19:15 (:0)
root pts/0 2019-06-06 19:16 (:0)
root pts/1 2019-06-07 20:12 (192.168.1.103)

last命令

last命令用于查看所有系统的登录记录,格式为“last [参数]”。
[root@localhost ~]# last
root pts/1 192.168.1.103 Fri Jun 7 20:12 still logged in
root pts/0 :0 Thu Jun 6 19:16 still logged in
root :0 :0 Thu Jun 6 19:15 still logged in
(unknown :0 :0 Thu Jun 6 19:14 - 19:15 (00:01)
reboot system boot 3.10.0-514.el7.x Thu Jun 6 19:13 - 22:58 (1+03:45)
root pts/2 :0 Thu Jun 6 01:07 - crash (18:06)
root pts/3 192.168.1.103 Thu Jun 6 00:15 - crash (18:57)
root pts/2 192.168.1.103 Thu Jun 6 00:08 - 00:32 (00:23)
root pts/2 :0 Thu Jun 6 00:07 - 00:08 (00:00)
root pts/1 192.168.1.103 Wed Jun 5 19:51 - 02:08 (06:16)
root pts/1 :0 Wed Jun 5 19:51 - 19:51 (00:00)
root pts/0 192.168.1.103 Wed Jun 5 17:51 - 01:31 (07:40)
root pts/0 :0 Thu Jun 6 01:50 - 17:50 (-7:-59)
root :0 :0 Thu Jun 6 01:49 - crash (17:23)
(unknown :0 :0 Thu Jun 6 01:49 - 01:49 (00:00)
reboot system boot 3.10.0-514.el7.x Thu Jun 6 01:48 - 22:58 (1+21:10)
root pts/1 192.168.228.1 Thu Jun 6 01:35 - down (00:12)
root pts/0 :0 Thu Jun 6 01:17 - 01:48 (00:31)
root pts/0 :0 Thu Jun 6 00:35 - 01:04 (00:28)
root :0 :0 Thu Jun 6 00:34 - 01:48 (01:13)

wtmp begins Sat Mar 17 05:57:44 2018

history命令

history命令用于显示历史执行过的命令,格式为“history [-c]”。
[root@locahost ~]# history
1 tar xzvf VMwareTools-9.9.0-2304977.tar.gz
2 cd vmware-tools-distrib/
3 ls
4 ./vmware-install.pl -d
5 reboot

6 history

sosreport命令

sosreport命令用于收集系统配置及架构信息并输出诊断文档,格式为sosreport。
[root@locahost ~]# sosreport
sosreport (version 3.0)
This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.

An archive containing the collected information will be generated in
/var/tmp and may be provided to a Red Hat support representative.
Any information provided to Red Hat will be treated in accordance with
the published support policies at:
https://access.redhat.com/support/
The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.
Press ENTER to continue, or CTRL-C to quit. 此处敲击回车来确认收集信息

Please enter your first initial and last name [linuxprobe.com]: 此处敲击回车来确认主机编号
Please enter the case number that you are generating this report for: 此处敲击回车来确认主机编号

Running plugins. Please wait ...
Running 70/70: yum...
Creating compressed archive...
Your sosreport has been generated and saved in:

/var/tmp/sosreport-linuxprobe.com-20170905230631.tar.xz
The checksum is: 79436cdf791327040efde48c452c6322
Please send this file to your support representative.

pwd命令

pwd命令用于显示用户当前所处的工作目录,格式为“pwd [选项]”。
[root@locahost etc]# pwd
/etc

cd命令

cd命令用于切换工作路径,格式为“cd [目录名称]”。
“cd -”命令返回到上一次所处的目录,
使用“cd…”命令进入上级目录,
以及使用“cd ~”命令切换到当前用户的家目录,
亦或使用“cd ~username”切换到其他用户的家目录。

ls命令

ls命令用于显示目录中的文件信息,格式为“ls [选项] [文件] ”。
使用ls命令的“-a”参数看到全部文件(包括隐藏文件),使用“-l”参数可以查看文件的属性、大小等详细信息。
[root@locahost ~]# ls -al
total 60
dr-xr-x---. 14 root root 4096 May 4 07:56 .
drwxr-xr-x. 17 root root 4096 May 4 15:55 ..
-rw-------. 1 root root 1213 May 4 15:44 anaconda-ks.cfg
-rw-------. 1 root root 957 May 4 07:54 .bash_history
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
drwx------. 10 root root 4096 May 4 07:56 .cache
drwx------. 15 root root 4096 May 4 07:49 .config
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
drwx------. 3 root root 24 May 4 07:46 .dbus
drwxr-xr-x. 2 root root 6 May 4 07:49 Desktop
drwxr-xr-x. 2 root root 6 May 4 07:49 Documents
drwxr-xr-x. 2 root root 6 May 4 07:49 Downloads
-rw-------. 1 root root 16 May 4 07:49 .esd_auth
-rw-------. 1 root root 628 May 4 07:56 .ICEauthority
-rw-r--r--. 1 root root 1264 May 4 07:48 initial-setup-ks.cfg
drwx------. 3 root root 18 May 4 07:49 .local
drwxr-xr-x. 2 root root 6 May 4 07:49 Music
drwxr-xr-x. 2 root root 6 May 4 07:49 Pictures
drwxr-xr-x. 2 root root 6 May 4 07:49 Public
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
drwxr-xr-x. 2 root root 6 May 4 07:49 Templates
drwxr-xr-x. 2 root root 6 May 4 07:49 Videos
-rw-------. 1 root root 1962 May 4 07:54 .viminfo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值