[LINUX] Chown command as root, which is dangerous to get used to chmod command

Introduction

I posted it because I want to tell you that if you make a mistake in chown and chmod as root, the server will be destroyed.

Examples that may be done (Dangerous, so it is strictly prohibited)

Change the owner and permissions under the current directory

$ #Owner change
$ cd /home/testuser/targetdir
$ chown -R ${User name}:${group name} ./

$ #Change permissions
$ cd /home/testuser/targetdir
$ chmod -R ${permission} ./

If you are doing it as above, we recommend that you stop it.

If you mistakenly type "/" in the place of "./"

The target is not currently under the directory but all directories, and various functions are broken. It's almost impossible to get it back.

Rm -rf /, which is often talked about in the command to break the server, may have a safety function depending on the CentOS version, but the above is executed because it seems that the safety function does not currently exist.

If you want to use "-R"

Make the directory specification of the change command an absolute path, Or just before, use the cd command to move up one level of the directory to be changed and specify the directory to be changed.

$ #Make the directory specification of the change command an absolute path
$ chown -R ${User name}:${group name} /home/testuser/targetdir
$ chmod -R ${permission} /home/testuser/targetdir

$ #Just before`cd`Use the command to move up one level of the directory to be changed and specify the directory to be changed.
$ cd /home/testuser/
$ chown -R ${User name}:${group name} targetdir
$ chmod -R ${permission} targetdir

at the end

Don't be overconfident that you won't make such a mistake. People make careless mistakes right away. If you break the server due to the careless mistake, it will not be fashionable.

Recommended Posts

Chown command as root, which is dangerous to get used to chmod command
Chown command as root, which is dangerous to get used to chmod command
[Linux] Search command
What is Linux? [Command list]
First get used to sending
First get used to sending