restricted.sh
来自「BASH Shell 编程 经典教程 《高级SHELL脚本编程》中文版」· Shell 代码 · 共 48 行
SH
48 行
#!/bin/bash# 脚本开头以"#!/bin/bash -r"来调用, #+ 会使整个脚本在受限模式下运行. echoecho "Changing directory."cd /usr/localecho "Now in `pwd`"echo "Coming back home."cdecho "Now in `pwd`"echo# 非受限的模式下,所有操作都正常. set -r# set --restricted 也具有相同的效果. echo "==> Now in restricted mode. <=="echoechoecho "Attempting directory change in restricted mode."cd ..echo "Still in `pwd`"echoechoecho "\$SHELL = $SHELL"echo "Attempting to change shell in restricted mode."SHELL="/bin/ash"echoecho "\$SHELL= $SHELL"echoechoecho "Attempting to redirect output in restricted mode."ls -l /usr/bin > bin.filesls -l bin.files # 尝试列出刚才创建的文件. echoexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?