zoukankan      html  css  js  c++  java
  • linux普通用户目录被删后恢复

      如题,普通用户/home/wlf被别人删了,而wlf用户下其实还有进程在跑,如果直接用userdel删是没法删的:

    [root@wlf88 ~]# userdel -r wlf
    userdel: user wlf is currently used by process 1253

      它会提示你当前还有个进程1253在跑着呢。现在我的用户是存在的,但是进去却没有任何权限,因为目录被删了:

    [root@wlf88 ~]# su - wlf
    Last login: Tue Apr 28 15:36:29 CST 2020 on pts/4
    su: warning: cannot change directory to /home/wlf: No such file or directory
    -bash-4.2$ ll
    ls: cannot open directory .: Permission denied
    -bash-4.2$ pwd
    /root
    -bash-4.2$ exit
    logout
    [root@wlf88 ~]# 

      我们发现进去一个不存在的目录,用户变成了-bash-4.2。新建一个同名目录wlf:

    [root@wlf88 ~]# cd /home
    [root@wlf88 home]# mkdir wlf -m 700

      上面指定了权限为700,还需要指定该目录的用户、用户组:

    chown wlf:wlf wlf

      接着我们新建一个普通用户wlf1,目的是为了把wlf1中的环境变量文件复制给wlf目录:

    [root@wlf88 home]# useradd wlf1 -m -d /home/wlf1 -s /bin/bash
    [root@wlf88 home]# cp wlf1/.bash_logout wlf1/.bash_profile wlf1/.bashrc wlf
    [root@wlf88 home]# chown wlf:wlf wlf/.bash_logout wlf/.bash_profile wlf/.bashrc 
    [root@wlf88 home]# su - wlf
    Last login: Tue Apr 28 16:06:21 CST 2020 on pts/4

      现在可以登录wlf了,那么wlf1也就没有利用价值了,删掉:

    userdel -r wlf1

      注意一点:现在仅仅是用户恢复了,但是原来wlf用户里面的文件是没有恢复的。

  • 相关阅读:
    回归分析举例
    用js实现在文本框中检测字数和限制字数功能
    深入理解CSS盒子模型
    CSS盒子模型小剖析
    iphone开发“关闭键盘的例子”
    最全的CSS浏览器兼容问题整理(IE6.0、IE7.0 与 FireFox)
    Soap UI 负载测试
    应聘时最漂亮的回答! 留着 早晚用的上 2012
    SOAP UI 简单使用
    乔布斯做管理的十条戒律
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/12795049.html
Copyright © 2011-2022 走看看