linux配置网路 设定主机名 ssh bash命令 通配符

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

#ifconfig ens33 192.168.185/24    #ens33网卡名称、192.168.185/24是要配置的ip地址/子网掩码

#vim /etc/resolv.conf     #dns配置文件,修改其中的nameserver即可

#route -n     #查看当前网关
#route add default gw 192.168.185.2 netmask 255.255.255.0     #添加默认网关和子网掩码
#route del default gw 192.168.185.2 netmask 255.255.255.0     #删除

永久配置网络

#vim /etc/sysconfig/network-scripts/ifcfg-ens33     #ifcfg-ens33网卡名为ens33的配置文件

添加结果,其中将BOOTPROTO由dhcp改为static,依次为IP地址、子网掩码、网关、nds1、dns2:

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

#hostname    #查看主机名
#hostnamectl set-hostname server1     #主机名改为server1
#vim /etc/hosts     #修改本地dns配置文件

添加结果,主机ip、主机名:192.168.185.146 server1

#ping server1     #web1客户端ping主机

#vim /etc/nginx/nginx.conf     #客户机ip可以使用主机名

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

#ssh 192.168.185.146     #ip连接登录
#ssh server1     #主机名连接登录

#scp /test1.txt server1:/     #上传

#scp server1:/test2.txt /     #下载

#ssh-kengen     #生成秘钥
#ls /root/home/.ssh/     #秘钥生成目录
#ssh-copy-id -i server1     #发送锁给服务机

#vim /etc/ssh/sshd_config     #修改主机ssh端口为8888
#systemctl restart sshd     #重启主机ssh服务

#ssh server1 -p 8888     #客户端使用主机名+端口登录

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

命令解释器bash优先级从左向右依次递减:
alias>Compound Commands>function>build_in>hash>$PATH>error
alias:别名,简化输出长参数的命令,优先级最高
compound commands:for、if、while
function:function test(){echo 'hello';}
build_in:内置命令,删除路径不影响使用,cd、source
hash:将命令缓存,hash 、hash -r(清楚缓存命令)
$PATH:别名和内部命令都搜到不到时到这里找
error:命令以上都找不到

通配符

?匹配任意一个字符

#ls ??.txt
原文地址:https://www.cnblogs.com/sunqim16/p/6594139.html