Changing permissions only on files or only on directories

The following two commands will change the permissions only on the files in a directory even if there are also other directories, and the same for directories only:

This only chmods files to 644:
[root@box ~]# find -type f | xargs -i chmod 644 {}

This only chmods directories to 755:
[root@box ~]# find -name ‘*’ -type d | xargs -i chmod 755 {}

Also, as an addition here the most common permissions on server are 644 for files and 755 for directories, you may want to make sure that the files/directories are not having 777 permissions as this is a big security risk. Most of the time some scripts will need 777 permissions and if this is the case would be a good idea to find a way around this or just find another script that does not need 777 permissions set.

  • Email, SSL
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Add multiple IPs to a server

For example if you want to add a few IPs from the class: [root@box ~]# cd...

How to install IonCube Loaders

How to install ionCube loader: ionCube produces leading tools for PHP source code protection...

Basic commands

How to use Linux:Linux is a Unix based operating system. Linux has a reputation as a very...

How to change mysql root password

MySQL Change root Password: Setting up mysql password is one of the essential tasks. By default...

How to install mod_evasive

  How to install mod_evasive How to install mod_evasive on a Directadmin server by admin on...