Mirage
Mirage

Reputation: 31548

How to change the root folder permission in linux centos

I have currently this permission in my / folder.

drwxr-xr-x. I have seen that anyone can open that folder.

How can remove the executable permission from that so that other permission remain same Also is any other main folder in / where i need to remove public executable permission

Upvotes: 0

Views: 7304

Answers (3)

Tantrik
Tantrik

Reputation: 81

To change all the folders & sub-folders (directories) permission to 755 inside the directory /path/to/directory, use the below command.

find /path/to/directory -type d -exec chmod 755 {} \;

To change all the file permissions to 644 inside the directory /path/to/directory

find /path/to/directory -type f -exec chmod 644 {} \;

For more reading: chmod - Understanding Folder & File Permissions

0: no permission,
1: execute
2: write
3: write and execute
4: read
5: read and execute
6: read and write
7: read, write, and execute

Folder Permissions:

  • Read: Be Able To Read Folder Contents,
  • Write: Edit folders data. delete or create new files/folders inside it and etc,
  • Execute: Able to run\execute the Folder Contents.

Similarly, File Permissions:

  • Read: if it's text file like index.html or index.php then user\browser be able to read it.
  • Write: ability to change its data.
  • Execute: if it's script like index.php run it to get resultant data from it.

Upvotes: 1

Levon
Levon

Reputation: 143017

chmod a-x /

will remove/subtract the execute permission for all ('a') from folder / -- is there a particular reason for wanting to do this?

See the "symbolic Mode" on this chmod man page for more information.

Upvotes: 2

cnicutar
cnicutar

Reputation: 182609

By removing executable permission in / you'll make anything under it inaccessible. You can do it with chmod -x / but it's highly inadvisable.

For most practical purposes this will make everything inaccessible to regular users. Even worse, this will likely prevent ssh connections to the box so even with root you'll need physical access to a tty.

Upvotes: 4

Related Questions