CentOS測試,建立jack帳號,刪除時只使用userdel jack,沒加參數
bash
帳號刪除成功,可是對應的home文件夾/home/jack並無刪除。ssh
從新建立帳號,設置密碼,嘗試登錄,提示如下錯誤:ide
Last failed login: Wed Mar 8 14:05:39 CST 2017 from 10.15.105.20 on ssh:notty There were 8 failed login attempts since the last successful login. Could not chdir to home directory /home/jack: Permission denied -bash: /home/jack/.bash_profile: Permission denied
查看home目錄下的文件夾屬主,發現屬主變爲ID測試
[root@localhost ~]# ll /home total 0 drwx------. 2 1000 1001 59 Mar 6 19:34 jack
使用chown更改文件夾屬主進程
[root@localhost ~]# chown jack /home/jack
再次登錄,成功。it
另外,須要禁用某帳號,可添加/etc/nologin文件,查看已鏈接帳號,使用pkill結束進程,便可禁用該帳號登陸。如需從新激活,可刪除/etc/nologin,適用於管理帳號。io
[root@localhost ~]# touch /etc/nologin [root@localhost ~]# w 17:00:53 up 5 days, 21:27, 3 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 Thu19 44:42m 0.00s 0.00s -bash root pts/0 10.15.105.20 09:39 5.00s 0.02s 0.00s w jack pts/1 10.15.105.20 16:28 28:13 0.00s 0.00s bash [root@localhost ~]# pkill -kill -t pts/1 [root@localhost ~]# rm -rf /etc/nologin 知識點: chown root /u Change the owner of /u to "root". chown root:staff /u Likewise, but also change its group to "staff". chown -hR root /u Change the owner of /u and subfiles to "root".