linux day03 bash特性 关机重启命令 IP命令

day03目录

一,bash特性

二,关机重启命令

三,ip命令相关用法

四,总结


一.bash特性

  1. 命令补全
    前期好多命令不熟悉经常忘这时候我们就可以用命令补全来命令
    字面意思就是补全命令

实例

 [root@localhost ~]# user #  后面所有命令的结果
useradd     userdel     usermod     usernetctl  users               

2.选项补全
需要安装选补全命令包 选项:要那种执行的结果
实例

yum install -y bash-completion 
# 选项补全安装一个选项补全命令的包
# 有时候不知道要补全的命令属于那个包可以用
yum porevides 命令
[root@localhost ~]# yum provides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic 
# net-tools 就是ifconfig所在包的位置
networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig

选项补全实例:
[root@localhost ~]# systemctl re
reboot                 reload-or-restart      reset-failed
reenable               reload-or-try-restart  restart
reload                 rescue 

3.参数补全
文件或者目录的路经补全

 [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg- 
# 按tab键自动展示相关的命令如果只有一个就直接补全参数

ifcfg-eth0  ifcfg-lo

二,关机重启注销命令

1.更新时间

[root@locahost ~]# yum install  -y  ntpdate
[root@locahost ~]# ntpdate  ntp.aliyun.com

2.关机

[root@locahost ~]# shutdown -h  10	#10分钟之后关机  
[root@locahost ~]# shutdown  -h  now	#立刻关机
[root@locahost ~]# shutdown  -h  0	#立刻关机 
[root@locahost ~]# shutdown  -h  11:00	#定时关机 
[root@locahost ~]# poweroff		#立刻关机  
[root@locahost ~]# halt -p		#立刻关机
[root@locahost ~]# init 0		#立刻关机  通过系统的运行级别 

3.重启

[root@locahost ~]#  shutdown  -r   10	#10分钟之后进行重启 
[root@locahost ~]#  shutdown  -r   0	#立刻重启
[root@locahost ~]# shutdown  -r   now	#立刻重启
[root@locahost ~]#  shutdown  -r  11:00 #定时重启 
[root@locahost ~]#  reboot		#重启 

4.注销 退出当前登录的用户

[root@locahost ~]# logout  #退出当前登录的用户,不能退出非登录式Shell
Ctrl键 +  d 		   #快捷键   退出当前登录的用户
[root@qls ~]# exit	   #退出当前登录的用户   既能退出登录式也能退出非登录式   主要用于脚本退出

[root@locahost ~]# bash
[root@locahost ~]# logout
bash: logout: not login shell: use `exit'
[[root@locahost ~]# exit

exit # 相当于关闭当前的进程 可以退出所有的进程
logout # 只能退出登录的用户

显示IP地址的命令

1.ip or ipconfig 就相当于一个人的身份证id 也就是电脑的唯一标识 独一无二

 Centos7默认显示IP地址的命令  ip a
ip a                    # 获取所有网卡的ip地址 全称 ip address
ip address show eth0    # 单独查看某个网卡的IP地址 简写 ip a s eth0
ifconfig                # 是Centos6默认显示IP地址的命令
ifconfig eth0           # 获取某一个网卡的详细信息

实例
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.100  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::5356:2ac5:e050:737a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:bd:a8:8e  txqueuelen 1000  (Ethernet)
        RX packets 15287  bytes 15558457 (14.8 MiB) # 接受数据size
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6926  bytes 609629 (595.3 KiB)   # 上传数据size
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# hostname -i
::1 127.0.0.1 # 显示所有的ip地址,会显示ipV6的地址
由于我没设置IPv6的地址所以没显示

[root@localhost ~]# hostname -I
10.0.0.100 # 显示ipv4的地址

2.获取到公网地址
公网地址:三大运营分配的公网地址 网络最终的出口地址

[root@localhost ~]# curl ifconfig.me
139.226.13.64

[root@localhost ~]# curl cip.cc # 获取公网地址的详细msg
IP	: 139.226.13.64
地址	: 中国  上海
运营商	: 联通

数据二	: 上海市 | 联通

数据三	: 中国上海上海 | 联通

URL	: http://www.cip.cc/139.226.13.64

原文地址:https://www.cnblogs.com/xiaolang666/p/13261669.html