linux:shell入门

centos7查看系统支持的shell
[root@node1 ~]# cat /etc/shells
/bin/sh					# Linux常用的shell,指向/bin/bash。
/bin/bash				# Linux常用的shell,默认使用的shell。
/sbin/nologin			# Linux常用的shell,用于禁止用户登录。
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
查看系统默认shell,两种方式
[root@node1 ~]# echo $SHELL
/bin/bash
[root@node1 ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
末尾的/bin/bash就是用户登录后使用的shell
查看bash版本
[root@node1 ]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
[root@node1 ]# bash --version
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
检测是否有bash漏洞
[root@node1 system]# env x='() { :;}; echo be careful' bash -c "echo this is a test"
this is a test
# 出现上述表示正常
[root@node1 system]# env x='() { :;}; echo be careful' bash -c "echo this is a test"
be careful
this is a test
# 表示存在漏洞,需尽快修复
升级bash
yum update bash -y
shell脚本的执行方式
  1. bash script-file或sh script-file,不需要文件有可执行权限。
  2. path/script-file或./script-file,文件需要有可执行权限。
  3. source script-file或 . script-file,读入脚本并执行脚本;在当前shell中加载并执行脚本文 件(其他运行shell脚本的方式会产生一个子shell来执行)
  4. bash < script-file或cat script-file|bash
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值