文章目录
网卡信息检查及修改ip
有关虚拟机网卡的工作效果,见下面这个网址,默认主机与虚拟相连的ip是192.168.X.1,网关是192.168.x.2.
https://blog.csdn.net/lyf_ldh/article/details/78695357
查看网卡信息,虚拟机上的linux网卡是ens33,真实机上为eth0
[huang@localhost ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.253.128 netmask 255.255.255.0 broadcast 192.168.253.255
inet6 fe80::288b:abc8:a0e0:bed3 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cc:ec:02 txqueuelen 1000 (Ethernet)
RX packets 193 bytes 16807 (16.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 122 bytes 15014 (14.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
直接查看网卡的配置文件
第一行:网络类型;第四行,获取ip的方式;倒数第二行,网卡名称;倒数第一行,是否开机启动
[root@promote ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="c2170fa1-67a3-496c-b30c-91ea7dd85250"
DEVICE="ens33"
ONBOOT="yes"
修改ip,注意要因为原本是dhcp方式获得ip,会有网关,现在不会自动有网关,需要手动设置。
1.修改ip
[huang@localhost ~]$ sudo -i
[sudo] password for huang:
[root@localhost ~]# ifconfig ens33 192.168.253.100 netmak 255.255.255.0
2.修改网关。
[root@localhost ~]# route add default gw 192.168.253.2
3.检测连通性。
[root@localhost ~]# ping baidu.com
PING baidu.com (123.125.115.110) 56(84) bytes of data.
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=128 time=29.4 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=128 time=29.7 ms
可以在虚拟机网络编辑器中查看关于网络的详细信息,
系统状态信息
系统版本 uname [-选项]
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# uname
Linux
系统负载free用于显示当前系统中内存的使用量信息,格式为“free [-选项]”。
free -h智能改变。
[root@localhost ~]# free
total used free shared buff/cache available
Mem: 995924 154668 627144 8248 214112 646104
Swap: 2097148 0 2097148
系统当前的用户who
(1)Linux的用户不像游戏中的用户一样,Linux中一个用户可以同时登陆在多个终端上。
tty指的就是终端设备,我们可以把它当成我们本地登录的这些终端。
pts指的是虚拟终端,当我们网络登录的时候,总是能看到它。
可以在本机上开多个桌面,也可以开多个pts
[huang@localhost ~]$ who
root tty1 2019-01-19 14:41
huang pts/0 2019-01-19 14:45 (192.168.253.1)
huang pts/1 2019-01-19 14:56 (192.168.253.1)
(2)通过echo可以向用户发送消息。$ echo 消息 > 终端
[huang@localhost ~]$ echo "hello pts" > /dev/pts/0
登陆的历史信息,包括登陆的ip和时间。
是以文本的格式存在的,容易被黑客篡改
[huang@localhost ~]$ last
huang pts/1 192.168.253.1 Sat Jan 19 14:56 still logged in
huang pts/0 192.168.253.1 Sat Jan 19 14:45 still logged in
root tty1 Sat Jan 19 14:41 still logged in
reboot system boot 3.10.0-957.1.3.e Sat Jan 19 14:40 - 15:10 (00:30)
root tty1 Sat Jan 19 14:35 - 14:39 (00:04)
历史命令history
查看历史命令
huang@localhost ~]$ history
1 sudo -i
2 yum -y install vim wget lrzsz unzip bash-completion net-tools bind-utils zip git screen
3 reboot
4 systemctl reboot -i
在家目录里查看历史命令
history-w把此次登陆的命令强制写入历史文件里,历史文件里可以清楚的看到很多的历史命令
[huang@promote ~]$ history -w
[huang@promote ~]$ ls -a
. .bash_history .bash_profile
.. .bash_logout .bashrc
[huang@promote ~]$ cat .bash_history
ll
ls
./.bash_history
ls ./.bash_history
history -w
重复历史命令,根据历史命令前面有标号
我们可以用感叹号后面跟一个数字的方式去执行历史命令中的某一条执行过的命令,例如!9,我们就可以去执行历史命令中索引为9的命令。
[huang@localhost ~]$ !182
$echo > /dev/pts/0
系统检测文件
sosreport
sosreport命令用于收集系统配置及架构信息并输出诊断文档,格式为sosreport。
[root@localhost ~]# yum install sos -y
[root@localhost ~]# sosreport
sosreport (version 3.5)This command will collect diagnostic and configuration information fromthis CentOS Linux system and