linux-网络相关配置,ssh服务,bash命令及优先级,元字符
二:临时配置网络(ip,网关,dns)+永久配置
临时配置:
[[email protected] ~]# ifconfig ens32: inet inet6 ether RX RX TX TX lo: inet inet6 loop RX RX TX TX [[email protected] ~]# [[email protected] ~]# route Kernel IP routing table Destination 192.168.152.0 [[email protected] ~]# route [[email protected] ~]# route Kernel IP routing table Destination 0.0.0.0 192.168.152.0 [[email protected] ~]# cat # Generated by search localdomain nameserver 192.168.152.2 nameserver 202.106.0.20 |
永久配置:
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32 TYPE=Ethernet BOOTPROTO=dhcp IPADDR=192.168.152.134 NETMASK=255.255.255.0 GATEWAY=192.168.152.2 DNS1=192.168.152.2 DNS2=202.106.0.20 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens32 UUID=9eff3909-2614-4df9-80c9-a6a7d9f1be28 DEVICE=ens32 ONBOOT=yes [[email protected] ~]# |
三:为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式
修改主机名:
hostname python_web1
cat /etc/hostname
python_web1
修改host文件:
[[email protected]_web1 ~]# cat /etc/hosts
192.168.2.3 python_web1
[[email protected]_web1 ~]# ping python_web1
四:ssh登录,scp上传、下载,ssh秘钥登录,修改ssh
server端的端口为8888然后进行登录和scp测试
SSH登录:
[[email protected] ~]# scp /etc/hosts web01:/tmp The authenticity of ECDSA key Are you sure you want Warning: Permanently [email protected]‘s password: hosts [[email protected] ~]# scp [email protected]‘s password: hosts [[email protected] ~]# ls -l -rw-r--r-- 1 root root 274 |
秘钥登录:
[[email protected] ~]# ssh-keygen Generating public/private rsa Enter Enter passphrase Enter same passphrase Your identification has Your public key The key 29:90:f7:3a:24:0a:e2:f9:22:ec:f4:07:75:7c:10:6b The key‘s randomart +--[ RSA 2048]----+ | | . | o | |o o + |o..o o |.+. . |ooo . |o..o. +-----------------+ [[email protected] ~]# /usr/bin/ssh-copy-id: INFO: /usr/bin/ssh-copy-id: INFO: [email protected]‘s password: Number of key(s) added: 1 Now try logging into the and check to make sure that [[email protected] ~]# [[email protected] ~]# The authenticity of ECDSA key Are you sure you want to continue connecting /usr/bin/ssh-copy-id: INFO: /usr/bin/ssh-copy-id: INFO: [email protected]‘s password: Number of key(s) added: 1 Now try logging into the and check to make sure that [[email protected] ~]# The authenticity of host ‘web03 ECDSA key Are you sure you want /usr/bin/ssh-copy-id: INFO: /usr/bin/ssh-copy-id: INFO: [email protected]‘s password: Number of key(s) added: 1 Now try logging into the and check to make sure that # 修改SSH端口 [[email protected] ~]# ssh Last login: Tue Mar 21 [[email protected] ~]# sed -i [[email protected] ~]# grep 8888 Port 8888 [[email protected] ~]# exit logout Connection to web01 closed. [[email protected] ~]# ssh Last login: Tue Mar 21 [[email protected] ~]# sed -i [[email protected] ~]# grep 8888 Port 8888 [[email protected] ~]# exit logout Connection to web02 closed. [[email protected] ~]# ssh Last login: Tue Mar 21 [[email protected] ~]# sed -i [[email protected] ~]# grep 8888 Port 8888 [[email protected] ~]# exit logout Connection to web03 closed. [[email protected] ~]# # SCP 远程拷贝文件 [[email protected] ~]# touch [[email protected] ~]# scp oldgirl.txt [[email protected] ~]# scp passwd |
五:整理bash命令类型,验证寻找一个命令的优先级
# 以ls命令为例
命令分为:
==> alias
==> Compound Commands
==> function
==> build_in
==> hash
==> $PATH
==> error: command not found
获取一个命令会按照上述优先级取寻找,先找同名的alias命令,再找compound命令。。。