Dee*_*pen 55 users multiple-users 14.04
我刚刚创建了一个新用户及其主文件夹,现在需要将其删除,而且我在文件中/home/olduser也找不到旧用户的下载、文档、图片等文件夹.Xauthority。不知道怎么删的。当新用户无法登录时,我startx通过按执行命令Alt+Ctrl+F3。
我删除了用户,Users & Groups但它的主文件夹没有被删除。我怎样才能解决这个问题?
如何安全删除新用户的主文件夹?
如何恢复我的旧文档、下载、文件夹?
如果没有,那么我如何创建全新的 /home 文件夹并与操作系统链接?
nux*_*nux 65
列出所有用户:
cut -d: -f1 /etc/passwd
Run Code Online (Sandbox Code Playgroud)
删除用户:
sudo userdel username
Run Code Online (Sandbox Code Playgroud)
删除主目录:
sudo rm -r /home/username
Run Code Online (Sandbox Code Playgroud)
要将主目录添加到现有用户:
创建一个主目录
为用户chown这个目录
sudo usermod -d /home/directory user
Run Code Online (Sandbox Code Playgroud)
mur*_*uru 38
您可以使用更高级的deluser命令:
sudo deluser --remove-home user
Run Code Online (Sandbox Code Playgroud)
您也可以尝试该--remove-all-files选项。来自man deluser:
By default, deluser will remove the user without removing the home
directory, the mail spool or any other files on the system owned by
the user. Removing the home directory and mail spool can be achieved
using the --remove-home option.
The --remove-all-files option removes all files on the system owned by
the user. Note that if you activate both options --remove-home will
have no effect because all files including the home directory and mail
spool are already covered by the --remove-all-files option.
Run Code Online (Sandbox Code Playgroud)
正如所料,第二个选项可能需要一段时间才能完成。
最好的方法是使用命令OPTIONS提供的userdel。
sudo userdel -rfRZ <username>
这会:
强制删除
用户主目录中的文件将与主目录本身和用户的邮件假脱机一起被删除。位于其他文件系统中的文件必须手动搜索和删除。
应用 CHROOT_DIR 目录中的更改并使用 CHROOT_DIR 目录中的配置文件。
删除用户登录的任何 SELinux 用户映射。
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
144611 次 |
| 最近记录: |