Under Linux mistakenly delete the root folder recovery method

Source: Internet
Author: User
First, how to restore the Linux root folder after deletion?
Today with ordinary users into the system to switch root user prompt without root home directory, do not know what the situation caused

$su - rootwarning: cannot change directory to /root-bash-3.2#

Second, online search method:
Root's home directory is deleted, manually establish/root, and then copy the profile from the user template
The first way to restart:
1. Boot Restart Press "E" key after the kernel this line finally added 1, into single-user mode.

2. Create your own home directory for root
Mkdir/root
#进入家目录
Cd/root
Home Catalogue #复制/etc/skel/templates
Cp-r/etc/skel/*/root
3. Then reboot the system to
Reboot

The second method (no restart required):
At this interface directly in-bash

-bash-3.2#mkdir /root-bash-3.2#cp -a /etc/skel/.[!.]* /root/

Mostly,/etc/skel/, copy the files back inside.

Because the production environment is not easy to restart, I am using the second method to build the root home directory, this late whether there is a problem is unclear.

Under Linux mistakenly delete the root folder recovery method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.