tab补全、命令行快捷键、history、别名、关机重启、重启、注销、显示IP地址命令、修改主机名

day03 Bash的特性

1. tab补全(*********)
1.#命令补全

[root@localhost ~]# user #
useradd     userdel     usermod     usernetctl  users

[root@localhost ~]# s
Display all 220 possibilities? (y or n)#以s开头的命令共有220个,是否补全,y显示 n不显示
#

2.#选项补全

 yum install -y bash-completion  #需要安装补全软件

[root@localhost ~]# ls --
--all
--almost-all
--author
--block-size=
--classify

[root@localhost ~]# systemctl st
start   status  stop    

#参数补全
文件或者目录的补全

[root@localhost ~]# ls  /etc/sysconfig/network-scripts/ifcfg-
ifcfg-ens33  ifcfg-ens36  ifcfg-lo 


2.命令行快捷键(主要通过xshall)
ctrl + c :   #取消当前操作     cancel
ctrl + d :   #退出当前登录的用户,相当于exit或logout
ctrl + z :   #杀死当前进程
ctrl + l :   #清除屏幕上的内容    clear
ctrl + a :   #将光标跳转到行首
ctrl + e :   #将光标跳转到行尾
ctrl + u :   #将当前光标行首的内容进行剪切
ctrl + y :   #粘贴当前粘贴板上面的内容
ctrl + k :   #将当前光标到行尾对的内容进行剪切
ctrl + ← :   #将当前光标向左移动一组字符串,以空格为分隔符
ctrl + → :   #将当前光标向右移动一组字符串,以空格为分隔符
ctrl + w :   #删除当前光标向前一组字符串,以空格为分隔符
ctrl + r :   #搜索最近一次包含某个命令的指令
  delete     #从前往后删除一个字符
esc + . :    #获取上一条命令最后一个参数、内容
!$          #也是获取上一条命令最后一个参数
!ls         #执行最近一次以ls开头的命令




ctrl + s    #锁屏    危险不能用
ctrl + q    #解锁






3.history(历史记录)
1.history=====历史记录

[root@localhost yum.repos.d]# history
    1  ping 192.168.100.0
    2  ping 192.168.0.100.
    3  ping 192.168.96.0
    4  ping192.168.100.100
    5  ping 192.168.100.100
    6  ip a
2.选项:
[root@localhost yum.repos.d]# history -d 6   #删除历史ID为6的命令

[root@localhost yum.repos.d]# history -w                     #将当前历史记录写入到默认的文件中       root/.bash_history

[root@localhost yum.repos.d]# history -c  #清空历史记录
[root@localhost yum.repos.d]# 


4.别名
[root@localhost ~]# alias           #系统默认的别名
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'


#设置别名   临时生效,退出即失效

[root@localhost ~]# alias test='ping baidu.com'

#查看是否设置成功

[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias test='ping baidu.com'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

#测试别名

[root@localhost ~]# test
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=29.6 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=28.3 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=29.7 ms


#取消别名
[root@localhost ~]# unalias test
[root@localhost ~]# 
[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'


#让别名永久生效

[root@localhost ~]# ls /etc/bashrc 》》别名的设置文件(对所有用户生效)
/etc/bashrc
[root@localhost ~]# ls ~/.bashrc(对当前用户生效)
/root/.bashrc


[root@localhost network-scripts]# alias dd='cat /etc/sysconfig/network-scripts/ifcfg-ens33'

[root@localhost network-scripts]# network
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
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=b68194c8-0b5b-4792-b121-407e0999640a
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.100
PREFIX=24
GATEWAY=192.168.100.2
DNS1=114.114.114.114
IPV6_PRIVACY=no

#取消临时别名   
  \   #取消特殊字符的特殊含义   取消转义  撬棍
[root@localhost network-scripts]#\network



#取消别名永久生效
[root@localhost ~]# sed -i '/network/d' /etc/bashrc
[root@localhost ~]# logout

#需要退出登录


[root@localhost ~]# network
-bash: network: command not found

5.关机重启及注销命令

同步时间:
yun install -y ntpdate
ntpdate ntp.aliyun.com

关机:
shutdown -h 10	#10是以分钟为节点的
shutdown -c	#取消你的关机操作

立即关机
shutdown -h now
shutdown -h 0
#都表示立刻关机

shutdown -h 11:00	#定时关机

init 0  #立刻关机  通过系统的运行级别

poweroff	#立即关机

halt  #立刻关机
halt,-p#关闭电源及系统

5.1重启的相关命令

shutdown -r 10 #10分钟后立刻重启
shutdown -r 0	#立即重启
shutdown -r now	#立即重启
shutdown -r 11:00	#11:00重启

reboot	#系统推荐的重启操作

5.2注销的相关命令

logout	#退出当前登录的用户	只能退出登录式shell,不能退出非登陆式shell

ctrl+d	#快捷键	退出当前登录的用户

exit	#退出当前登录的用户	能退出登录式shell,也能退出非登陆式shell,主要用于脚本退出

6.显示IP地址的命令

#获取所有网卡的ip地址
ip a #
ip address

#单独显示某块网卡的ip地址
ip a s eth0	#s=show的缩写

ifconfig	#是Centos6默认的,获取所有
yum install -y net-tools #其他的需要使用的话需要安装

ifconfig eyh0	#显示某块网卡的信息

hostname   #显示系统主机名
hostname -i #显示的IPV6
hostname -I #显示的IPV4

curl ifconfig.me
curl cip.cc	#获取公网IP地址
7.修改主机名
方法一:

[root@local-work ~]# hostnamectl set-hostname local-work

# 需要重新登录或者执行一个解析器

方法二:

[root@local-work ~]# echo "string" > /etc/hostname
[root@local-work ~]# cat /etc/hostname
string
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

琴声浮或沉__听懂只一人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值