Top19:RHEL学习札记-3-重定向、环境变量、通配符

重定向服务 是 命令 和 文件 之间传输的纽带
管道符是 命令 和 命令 之间的纽带

重定向

输入重定向 <

​ 例:wc -l < anaconda-ks.cfg ,只输出行数

输出重定向

​ 作用将原先要输出到屏幕的内容,重定向到文件里

 >  清空写入
	 例: uptime > a    将当前时间信息输出到a文件里,
	 	  但是这种写法是会区分信息是否正确,如果信息有误的时候还是会输出到屏幕上,不会写入文件
 &>    不进行区分信息是否有误
 
 >> 追加写入

管道符

​ 将前边要输出到屏幕上的内容,交给管道符后进行二次处理
​ 例:echo redhat123 | passwd --stdin linux1
​ 是将linux1用户的密码重置为 redhat123 ,不用产生交互,再二次确认

passwd 重置密码
passwd 用户,重置指定用户的密码

通配符

​ ? 匹配单个值
​ * 所有
​ [0-9] 单个数字
​ [1,3,5] 具体数字 {1,3,5}
​ [a-z] 小写字母
​ [A-Z] 大写字母
​ [a,c,d] 具体字母
​ 中括号[] 和大括号{} 的区别:中括号匹配不到不会报错,大括号会报错

$$ 两个美元符号一起,指的是输出当前进程的PID值
\   单个字符转义
' '  全部字符转义
" " 定义范围 如果参数中包括空格,可以加上双引号
    例:echo "haha haha haha" 是将这三个组成了一个整理
` ` 反单引号 执行命令
    例:echo `uptime`   输出执行uptime命令后的结果

环境变量

绝对路径
alias 命令别名

​ 例: alias nn=“nmcli connection up ens160”
​ 给重启网卡的命令起个别名,使用时直接执行 nn 就可使用
​ unalias 撤销 命令别名

内部命令 bash
外部命令

​ 例:$PATH 存放命令的位置,当我们敲一个命令后,会从path里找这个命令存放在哪儿,找到命令后再执行
​ $HOME 家目录所在位置
​ $SHRLL 当前使用的终端名称
​ $HISTSIZE 保存命令执行记录的条数
​ $MAIL 记录着邮件保存在什么位置
​ $LANG 记录着编码格式 en_US.UTF-8 ,当远程服务器出现了乱码,那八九不离十就是这个不一致的原因,需要将自己终端改一致就行了
​ $RANDOM 随机输出一个数字
​ PS1 当前终端的提示符是什么 例: PS1=# 会将提示符改为 #
​ $EDITOR 用户默认的文本编辑器

直接定义 和使用 export的区别

​ 变量直接定义 自己用
​ 使用export 定义 所有人用

例:

​ mkdir /home/haha
​ WORKDIR=/home/haha
​ cd $WORKDIR # 这样只能当前用户使用

​ su linux1 # 切换到linux1用户
​ cd $WORKDIR #无法使用这个变量

​ export WORKDIR # 使用export提权后即可所有用户使用
​ cd $EDITOR # 可以使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
为什么会这样[user_mongo@nosql01 replicaset]$ cd /opt [user_mongo@nosql01 opt]$ ll total 0 drwxr-xr-x. 3 root root 25 Mar 16 17:08 servers drwxr-xr-x. 2 root root 51 Mar 16 17:10 software [user_mongo@nosql01 opt]$ tar -zxvf /opt/software/mongodb-linux-x86_64-rhel70-4.4.12.tgz -C /opt/servers/mongodb_demo/replicaset/ mongodb-linux-x86_64-rhel70-4.4.12/LICENSE-Community.txt tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/LICENSE-Community.txt: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/MPL-2 tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/MPL-2: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/README tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/README: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/THIRD-PARTY-NOTICES tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/THIRD-PARTY-NOTICES: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/install_compass tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/install_compass: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongo tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongo: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongod tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongod: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongos tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongos: Cannot open: No such file or directory tar: Exiting with failure status due to previous errors [user_mongo@nosql01 opt]$ tar -zcvf /opt/software/mongodb-linux-x86_64-rhel70-4.4.12.tgz -C /opt/servers/mongodb_demo/replicaset/ tar: Cowardly refusing to create an empty archive Try `tar --help' or `tar --usage' for more information.
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Carl_blog

给我点根烟

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

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

打赏作者

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

抵扣说明:

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

余额充值