Shell基础01

临时配置网络(ip,网关,dns)+永久配置


#临时配置
ifconfig enp0s3 192.168.16.250 netmask 255.255.255.0 #配置IP地址与子网掩码
route add default gw 192.168.16.254 #设置网关
#永久配置
vim /etc/sysconfig/ifcfg-enp0s3
TYPE="Ethernet"
NAME="enp0s3"
BOOTPROTO="static"
ONBOOT="yes"
DEVICE="enp0s3"
IPADDR="192.168.16.250"
NETMASK="255.255.255.0"
GATEWAY="192.168.16.254"
#重启网络使配置生效
systemctl restart network

为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式


#虚拟机
hostnamectl set-hostname webserver01 #设置主机名
vim /etc/hosts
192.168.16.132 hello01
#主机
hostnamectl set-hostname hello01
vim /etc/hosts
#测试
ping webserver01
PING webserver01 (192.168.16.150) 56(84) bytes of data.
64 bytes from webserver01 (192.168.16.150): icmp_seq=1 ttl=64 time=0.284 ms
64 bytes from webserver01 (192.168.16.150): icmp_seq=2 ttl=64 time=0.167 ms
64 bytes from webserver01 (192.168.16.150): icmp_seq=3 ttl=64 time=0.380 ms
^C
--- webserver01 ping statistics ---

ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试


touch hello#建立测试文件
#上传测试文件
scp hello root@webserver01:/      
root@webserver01's password: 
hello                                         100%    0     0.0KB/s   00:00  
rm -rf hello #删除本地测试文件
#下载测试文件
scp root@webserver01:/hello .
root@webserver01's password: 
hello                                         100%    0     0.0KB/s   00:00    
#修改22端口
vim /etc/ssh/sshd_config
Port 8888
systemctl restart sshd
#登陆测试
ssh root@192.168.16.150 -p 8888
root@192.168.16.150's password: 
Last login: Tue Mar 21 16:40:50 2017
[root@webserver01 ~]# 

整理bash命令类型,验证寻找一个命令的优先级


命令优先级:

优先级 命令类型
1 别名
2 组合命令(if\while...)
3 函数
4 内部命令(cd\ls...)
5 hash路径缓存
6 path环境变量
7 找不到命令

测试优先级

Untitled Image

通配符实验


~/Pictures  ls Wallpaper0*
Wallpaper01.jpeg  Wallpaper03.jpg  Wallpaper05.jpg
Wallpaper02.jpg   Wallpaper04.jpg  Wallpaper06.jpg
 ~/Pictures  ls Wallpaper0?.jpg
Wallpaper02.jpg  Wallpaper04.jpg  Wallpaper06.jpg
Wallpaper03.jpg  Wallpaper05.jpg
posted @ 2017-03-21 17:31  我是你爸爸的爸爸  阅读(268)  评论(0编辑  收藏  举报