search
HomeSystem TutorialLINUXHow to solve the problem of accidentally deleting the /root directory in CentOS?

During testing, I accidentally deleted centos/root using rm -rf

Delete the /root directory, the system will not crash, and it can start normally, but it just looks unpleasant!

Solution:

1. Create the /root directory directly; mkdir /root

2. Copy the hidden files under /etc/skel/ to the /root directory; cp /etc/skel/.bash* /root

3. Restart

4. Be careful when using rm -rf in the production environment. It is best to test it in the test environment to make sure there are no problems before using it! ! !

The above is the detailed content of How to solve the problem of accidentally deleting the /root directory in CentOS?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:脚本之家. If there is any infringement, please contact admin@php.cn delete
Linux how to change the owner of a fileLinux how to change the owner of a fileAug 13, 2025 pm 01:02 PM

To change the owner of a Linux file, use the chown command. 1. Change the file owner only: sudochownnewuserfilename, for example sudochownlicereport.txt changes the owner of report.txt to alice. 2. Change the owner and group at the same time: sudochownuser:groupfilename, for example, sudochownalice:developersproject.log sets the owner to alice and the group to developers. 3. Change the group only: sudochown:groupfilename, e.g.

Advanced `grep` Usage with Regular Expressions in LinuxAdvanced `grep` Usage with Regular Expressions in LinuxAug 13, 2025 pm 12:51 PM

Use-Eforextendedregularexpressionstosimplifypatternsyntaxwith ,?,|,and();2.Applywordboundarieswith\borPOSIX[[::]]tomatchwholewords;3.Anchorpatternsusing^and$totargetlinebeginningsandendings;4.Combinemultiplepatternswith|inEREforlogicalORmatching;5.Le

What is the syntax of a crontab file?What is the syntax of a crontab file?Aug 13, 2025 am 08:19 AM

Crontabsyntaxschedulestasksusingfivetimefieldsfollowedbyacommand.1.Firstfieldsetsminutes(0–59).2.Secondfielddefineshours(0–23).3.Thirdfieldspecifiesdayofthemonth(1–31).4.Fourthfielddeterminesthemonth(1–12).5.Fifthfieldindicatesdayoftheweek(0–7,0/7=Su

How to Compile Software from Source Code on LinuxHow to Compile Software from Source Code on LinuxAug 12, 2025 pm 06:19 PM

Installbuildtoolslikebuild-essentialorDevelopmentTools.2.DownloadandextractsourcecodefromarchivesorGit.3.Run./configurewithoptionslike--prefixtosetupthebuild.4.Compileusingmake,optionallywith-j$(nproc)forspeed.5.Installwithsudomakeinstallorusecheckin

Linux how to create an alias for a commandLinux how to create an alias for a commandAug 12, 2025 pm 06:14 PM

To create a temporary alias, you only need to run the alias command in the current session, such as aliasll='ls-la', which will be invalid after closing the terminal; 2. To permanently save the alias, you need to add the alias command to the ~/.bashrc (Bash) or ~/.zshrc (Zsh) file, and run the source command after saving to make the changes take effect immediately; 3. You can use the unalias command to delete the temporary alias, or redefine it to overwrite the existing alias. It is recommended to use meaningful names and avoid overwriting standard commands to maintain the predictability and manageability of the system.

Linux how to check for disk I/O performanceLinux how to check for disk I/O performanceAug 12, 2025 pm 05:27 PM

Useiostat-x1tomonitordiskutilization(%util),awaittime,andI/Ooperationspersecond,wherehigh%utilandawaitindicateabottleneck.2.Performaquicksequentialwritespeedtestwithddif=/dev/zeroof=/tmp/testfilebs=1Gcount=1oflag=directstatus=progress,followedbyaread

Linux how to manage groupsLinux how to manage groupsAug 12, 2025 pm 04:29 PM

To effectively manage groups in Linux, you need to master the following 10 steps: 1. Use cat/etc/group, groups or id commands to view existing groups; 2. Use sudogroupaddgroupname to create a new group, and you can specify the GID; 3. Use sudogroupdelgroupname to delete the group, but cannot delete the group that is the main group of the user; 4. Use sudogroupmod-n to modify the group name or -sudogroupmod-g to modify the GID; 5. Use sudousermod-aG or sudogpasswd-a to add the user to the group; 6. Use sudogpasswd-d to remove the user from the group, or use user

Linux how to manage user passwordsLinux how to manage user passwordsAug 12, 2025 pm 04:23 PM

Usepasswdusernametosetorchangeauser’spassword,withsudoforotherusers.2.EnforcestrongpasswordsviaPAMbyconfiguring/etc/pam.d/common-passwordwithruleslikeminlen=8,ucredit=-1,lcredit=-1,dcredit=-1,ocredit=-1,difok=3,andremember=5,andsetdefaultsin/etc/logi

See all articles

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools