shell初识(loginshell、nologinshell、执行方式)

1. shell 脚本第一行

shell 脚本中 第一行 #!/usr/bin/bash
作用用来 指定 该脚本的解释器
查看当前有哪些shell:
cat /etc/shells

2. shell 脚本中嵌套其他脚本

#!/bin/bash
echo "hello shell"
/usr/bin/python <<-EOF
# python 代码
print("hello python")
EOF

3. shell的执行方式

	. 执行
	source 执行
	这两种方式执行的脚本中的变量 可以在当前shell 中直接使用,属于在当前shell中执行
	其他情况基本使用 sub shell 方式执行

4. loginshell 和nologinshell

loginshell 登录的shell  
命令:su - tom  # 登录tom 用户的shell
nologinshell 没有登录的shell
命令: su tom #  使用的是 没有登录的shell

用户登录时执行:
# 系统级
/etc/profile
/etc/bashrc
# 用户级
~/.bash_profile
~/.bashrc

# 用户退出执行
# 用户级
~/.bash_logout
~/.bash_history

# login shell 执行 
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc
# nologin shell 执行
/etc/bashrc
~/.bashrc

5. 历史命令

1. 上下键可以 查看历史命令
2. !number 执行 历史该编号命令
3. !string   比如 !da 执行 da开始的命令
4. !! 执行上一条命令
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值