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用户里面的文件是没有恢复的。

  • 相关阅读:
    用mysql+redis实现微博feed架构上需要注意哪些问题
    windows7下安装zend studio5.5
    鼠标移出DIV层时,触发onMouseOut事件
    关于MVVM和RAC的一些拓展阅读
    Swift(上) 常量, 变量, 数据类型, 循环, 选择结构 简单函数
    SDWebImage的使用
    App Store新应用提审攻略
    关于iOS的推送服务的点点
    iOS开发代码规范
    伟大的RAC和MVVM入门(二)
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/12795049.html
Copyright © 2011-2022 走看看