一,文件传输scp sftp xftp rz sz
scp linux主机之间的文件传输
sftp linux主机之间的文件传输
xftp window 和linux主机之间的文件传输
rz 将 windows主机文件发送到linux主机(xshell7需要下载包)
sz 将 linux主机的文件发送到window主机 (xshell7需要下载包)
二,bash shell 特性
1.变量
变量环境变量(全局变量) 自定义变量 (局部变量)
变量名=值 --自定义变量 作用域范围 ( 仅在当前运行终端生效)
export 变量名=值 --环境变量 作用域范围 (当前运行终端生效,子shell下生效)
echo $变量名
//局部变量
[root@a ~]# i=1
[root@a ~]# echo $i
1
[root@a ~]# export j=1
[root@a ~]# echo $j
1
set 显示所有变量
unset 取消变量
2.内置命令 外置命令
查看命令类型 type
特点: 内置命令执行效率高于外置命令 time cd time passwd
//查看命令位置
[root@a ~]# type cd
cd is a shell builtin
[root@a ~]# type passwd
passwd is hashed (/usr/bin/passwd)
//查看命令的运行时间
[root@a ~]# time cd
real 0m0.000s
user 0m0.000s
sys 0m0.000s
[root@a ~]# time passwd
Changing password for user root.
New password:
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password:
Sorry, passwords do not match.
passwd: Failed preliminary check by password service
real 0m13.808s
user 0m0.014s
sys 0m0.035s
alias 命令别名(临时生效)
alias 别名='命令本身' alias chaxun=''/usr/sbin/ip"
定义chaxun为:使用这个位置的命令
[root@a ~]# alias chuangjian=touch //定义chuangjian为touch的属性
[root@a ~]# chuangjian daibi //创建一个叫daibi的文件
[root@a ~]# ls
anaconda-ks.cfg Documents initial-setup-ks.cfg Public
bashrc Downloads Music shabi
daibi file1 new_file.txt Templates
Desktop file.txt Pictures Videos
//定义chaxun为ip
[root@a ~]# which ip a
/usr/sbin/ip
/usr/bin/which: no a in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@a ~]# chaxun="/usr/sbin/ip"
[root@a ~]# $chaxun a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:32:58:80 brd ff:ff:ff:ff:ff:ff
inet 192.168.220.128/24 brd 192.168.220.255 scope global dynamic ens160
valid_lft 1390sec preferred_lft 1390sec
inet6 fe80::89bd:edbb:24b2:ed65/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:8a:57:f6 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:8a:57:f6 brd ff:ff:ff:ff:ff:ff
unalias 取消别名
[root@a ~]# unalias chuangjian
[root@a ~]# chuangjian nihao
bash: chuangjian: command not found...
永久生效的别名
将命令追加写入指定文件
在根目录下:
/etc/bashrc 对系统用户都生效永久别名
使用 source /etc/bashrc 或者 exit 或者 bash进行刷新
在~目录下
~/.bashrc 仅对当前用户生效永久别名(~代表所有的家目录下的bashrc)
使用source /etc/bashrc 或者 exit 或者 bash进行刷新
//在这个[root@a ~]# vim ~/.bashrc操作下
alias hello='echo hello,everybody>>file.txt'
alias shuaxin='echo 当前时间为`date`>new_file.txt'
此时可以查看
[root@a ~]# source /root/bashrc //刷新root下的bach
[root@a ~]# hello
[root@a ~]# cat file.txt
hello,everybody
[root@a ~]# hello|cat file.txt
hello,everybody
[root@a ~]# hello|cat file.txt
hello,everybody
hello,everybody
[root@a ~]# hello|cat file.txt
hello,everybody
hello,everybody
hello,everybody
3.history 命令历史
history -w 将缓存区的历史保存在历史文件
-C 清空所有命令历史
-d 删除指定的命令历史 history -d 11
~/.bash_history
!2 匹配第二条命令历史执行该命名
!-2 匹配倒数第二条命令历史执行该命名
!! 匹配上一次执行的命令
[root@a ~]# history -c
[root@a ~]# history -w
[root@a ~]# history
1 history -w
2 history
[root@a ~]# !!
history
1 history -w
2 history
[root@a ~]# ehco shabi
bash: ehco: command not found...
Similar command is: 'echo'
[root@a ~]# echo shabi
shabi
[root@a ~]# !!
echo shabi
shabi
[root@a ~]# !-3
history
1 history -w
2 history
3 ehco shabi
4 echo shabi
5 history
[root@a ~]# history
1 history -w
2 history
3 ehco shabi
4 echo shabi
5 history
[root@a ~]#
4.hash 命令缓存(!!!如果定义了变量,hash是无法表示的)
hash 显示所有命令缓存
hash -t cat 查看指定命令的缓存(cat)
hash -p /usr/bin/touch chuangjian 手动添加缓存,并定义别名
hash -d 命令名称 hash -d chuangjian 删除指定命令缓存
hash -r 清空所有命令缓存
[root@a ~]# hash
hits command
3 /usr/sbin/groupadd
10 /usr/bin/sort
5 /usr/bin/rm
11 /usr/bin/cat
13 /usr/bin/vim
3 /usr/bin/touch
6 /usr/sbin/useradd
2 /usr/bin/whereis
1 /usr/bin/mkdir
2 /usr/bin/passwd
5 /usr/bin/cut
11 /usr/bin/ls
8 /usr/sbin/usermod
5.通配符
[] [1apd] [1-9] [^] [!] * ? { } touch file{1..10}
6.引号的特点
`` ' ' " "
7.帮助使用方式
内置命令 help cd man cd
外置命令 passwd --help man passwd
man 手册第一个章节 所有用户可以执行的命令帮助信息
第五章节 配置文件的帮助信息 man 5 passwd
第八章节 管理员可以执行的命令帮助信息