Linux創(chuàng)建只讀用戶腳本

vim read_user.sh

#/bin/bash
user=$1
passwd=$2
useradd -s /bin/bash ${user}
echo -e "${passwd}"|passwd --stdin ${user}
mkdir /home/${user}/.bin
chown root. /home/${user}/.bash_profile
chmod 755 /home/${user}/.bash_profile
echo -e "PATH=/home/${user}/.bin\nexport PATH" >> /home/${user}/.bash_profile
su - ${user} -c "source /home/${user}/.bash_profile"
ln -s /usr/bin/wc /home/${user}/.bin/wc
ln -s /usr/bin/cd /home/${user}/.bin/cd
ln -s /usr/bin/tail /home/${user}/.bin/tail
ln -s /bin/more /home/${user}/.bin/more
ln -s /bin/cat /home/${user}/.bin/cat
ln -s /bin/grep /home/${user}/.bin/grep
ln -s /bin/find /home/${user}/.bin/find
ln -s /bin/pwd /home/${user}/.bin/pwd
ln -s /bin/ls /home/${user}/.bin/ls
ln -s /bin/less /home/${user}/.bin/less
ln -s /bin/tar /home/${user}/.bin/tar
ln -s /bin/echo /home/${user}/.bin/echo

sh read_uaer.sh user_name passwd

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容