给定以下目录:
drwx------ 2 joe joe 4096 Jan 11 2010 /home/joe
有没有办法让我作为用户的根,以避免不小心cd到这个目录?
我不是在寻找实际的权限执行,而是为了帮助root用户避免这样的“私人”目录的某些设置(例如,在bash shell中)。
没有办法阻止root访问目录 – 在Unix系统中,root是无所不能的。
至于意外这样做…..这取决于你用什么来访问目录。
你可以试试….
export PS1="\u@\h [\$(check_path.sh)]>
其中check_path.sh是类似于…
#!/bin/bash if [ `whoami` = 'root' -a `pwd` = '/home/joe'] ; then echo -n "!!!!!!accessing /home/joe as root !!!!!!!!!" fi
你可以在.bashrc里写一个脚本
像…如果[命令==“cd / home / joe”]做问题