linux让普通用户锁定在home家目录


建立伪shell

[[email protected] ~]# ln -s /bin/bash /bin/rbash
[[email protected] ~]# echo "/bin/rbash">>/etc/shells

添加你想限制的用户:
[[email protected] ~]# chsh -s /bin/rbash test
Changing shell for test.
Shell changed.

切换到test用户测试一下:
[[email protected] ~]# su - test
[[email protected] ~]$ cd /
-rbash: cd: restricted
[[email protected] ~]$ ls
[[email protected] ~]$ pwd
/home/test
[[email protected] ~]$ cd ..

-rbash: cd: restricted

QQ截图20131212114144.jpg


Whatever is worth doing is worth doing well.