linux添加只读用户


USER=onlyread 

02 chattr -i /etc/passwd /etc/shadow /etc/group 

03 ln -s /bin/bash /bin/rbash 

04 echo /bin/rbash >> /etc/shells 

05 useradd -c "A Restricted User" -s /bin/rbash $USER 

06 rm -rf /home/$USER/\.* 

07 echo "export PATH=/home/$USER/bin" > /home/$USER/.bashrc 

08 for i in .bash_login .bash_profile .bash_logout .profile .bashrc; do echo ". .bashrc" > /home/$USER/$i; done

09 mkdir /home/$USER/bin/ 

10 CMD="cat awk sed ping"//设置要给用户的命令 

11 for i in $CMD; do ln -sf $(which $i|grep -v alias|sed 's/\t*//g') /home/$USER/bin/$i; done

12 chmod 750 /home/$USER -R 

13 chmod 444 /home/$USER/.bash* /home/$USER/.profile 

14 chown root:$USER /home/$USER/.bash* /home/$USER -R 

15 echo 111111 | passwd --stdin $USER



相关内容

    暂无相关文章