假如咱们须要限制一个Linux用户只能使用咱们指定的命令,那么可使用限制的shell。python
在正常的命令环境下使用:shell
测试: # bash -r # 进入限制的shell # cd / bash: cd: restricted # exit
具体设置:vim
# useradd test # 添加用户 # cd bin # ln -s bash rbash # 设置软链接 # cd /home/test # vim .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs #PATH=$PATH:$HOME/bin # 注释掉原来的PATH路径 PATH=$HOME/.bin export PATH # mkdir .bin # ln -s /bin/ls .bin/ # ln -s /bin/cat .bin/ # ln -s /bin/touch .bin/ # 给用户指定命令 # # vim /etc/passwd test:x:502:502::/home/test:/bin/rbash # 修改shell为rbash # # passwd test
到此配置结束,登录测试:bash
测试效果仍是很明显的。具体的限制的shell有哪些限制,wiki上有详细的说明:ide
点击链接地址.测试