不能恢复被删除的文件数据!仅恢复用户的登录目录与shell环境。
建立故障环境
1、建立测试用户,并指定Home目录
useradd -d /home/home test1
2、删除用户的home 目录
rm -rf /home/home/
3、用户登录会提示错误,提示符显示为bash:
[root@test88 ~]# su - test1
su: warning: cannot change directory to /home/home1: No such file or directory
-bash-4.1$
故障排除:
4、查看用户的home 目录(经查为/home/home):
[soly@test88 ~]$ cat /etc/passwd | grep test1
test1:x:507:508::/home/home:/bin/bash
5、新建home目录 ,并将所属为此用户,权限改为700
[root@test88 ~]# mkdir /home/home
[root@test88 ~]# chown test1:test1 /home/home/
[root@test88 ~]# chmod 700 /home/home/
6、 复制其他用户的几个 .bashrc* 文件至此Home目录
[root@test88 ~]# cp /home/soly/.bash* /home/home/
[root@test88 ~]# ls -al /home/home/
total 24
drwx------. 2 test1 test1 4096 Dec 20 16:26 .
drwxr-xr-x. 8 root root 4096 Dec 20 16:24 ..
-rw-------. 1 root root 1972 Dec 20 16:26 .bash_history
-rw-r--r--. 1 root root 18 Dec 20 16:26 .bash_logout
-rw-r--r--. 1 root root 176 Dec 20 16:26 .bash_profile
-rw-r--r--. 1 root root 124 Dec 20 16:26 .bashrc
7、更改那些 .bash* 文件归属及权限:
[root@test88 ~]# chown test1:test1 /home/home/.bash*
[root@test88 ~]# chmod 700 /home/home/.bash*
[root@test88 ~]# ll -a /home/home/
total 24
drwx------. 2 test1 test1 4096 Dec 20 16:26 .
drwxr-xr-x. 8 root root 4096 Dec 20 16:24 ..
-rwx------. 1 test1 test1 1972 Dec 20 16:26 .bash_history
-rwx------. 1 test1 test1 18 Dec 20 16:26 .bash_logout
-rwx------. 1 test1 test1 176 Dec 20 16:26 .bash_profile
-rwx------. 1 test1 test1 124 Dec 20 16:26 .bashrc
8、 切换至test1,并执行以下命令后,提示符恢复正常:
[root@test88 ~]# su - test1
[test1@test88 ~]$
建立故障环境
1、建立测试用户,并指定Home目录
useradd -d /home/home test1
2、删除用户的home 目录
rm -rf /home/home/
3、用户登录会提示错误,提示符显示为bash:
[root@test88 ~]# su - test1
su: warning: cannot change directory to /home/home1: No such file or directory
-bash-4.1$
故障排除:
4、查看用户的home 目录(经查为/home/home):
[soly@test88 ~]$ cat /etc/passwd | grep test1
test1:x:507:508::/home/home:/bin/bash
5、新建home目录 ,并将所属为此用户,权限改为700
[root@test88 ~]# mkdir /home/home
[root@test88 ~]# chown test1:test1 /home/home/
[root@test88 ~]# chmod 700 /home/home/
6、 复制其他用户的几个 .bashrc* 文件至此Home目录
[root@test88 ~]# cp /home/soly/.bash* /home/home/
[root@test88 ~]# ls -al /home/home/
total 24
drwx------. 2 test1 test1 4096 Dec 20 16:26 .
drwxr-xr-x. 8 root root 4096 Dec 20 16:24 ..
-rw-------. 1 root root 1972 Dec 20 16:26 .bash_history
-rw-r--r--. 1 root root 18 Dec 20 16:26 .bash_logout
-rw-r--r--. 1 root root 176 Dec 20 16:26 .bash_profile
-rw-r--r--. 1 root root 124 Dec 20 16:26 .bashrc
7、更改那些 .bash* 文件归属及权限:
[root@test88 ~]# chown test1:test1 /home/home/.bash*
[root@test88 ~]# chmod 700 /home/home/.bash*
[root@test88 ~]# ll -a /home/home/
total 24
drwx------. 2 test1 test1 4096 Dec 20 16:26 .
drwxr-xr-x. 8 root root 4096 Dec 20 16:24 ..
-rwx------. 1 test1 test1 1972 Dec 20 16:26 .bash_history
-rwx------. 1 test1 test1 18 Dec 20 16:26 .bash_logout
-rwx------. 1 test1 test1 176 Dec 20 16:26 .bash_profile
-rwx------. 1 test1 test1 124 Dec 20 16:26 .bashrc
8、 切换至test1,并执行以下命令后,提示符恢复正常:
[root@test88 ~]# su - test1
[test1@test88 ~]$
同样适用于 更换 home目录
[root@test88 ~]# mkdir /home/test1
[root@test88 ~]# usermod -d /home/test1 test1
[root@test88 ~]# chmod 700 /home/test1
然后接第6步---
[root@test88 ~]# mkdir /home/test1
[root@test88 ~]# usermod -d /home/test1 test1
[root@test88 ~]# chmod 700 /home/test1
然后接第6步---