假如咱們須要限制一個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
點擊鏈接地址.測試