[magento] find . -type f -exec chmod 644 {} ;

why doesn't this work I am trying to change all files to 644 abd all -d to 755:

find . -type f -exec chmod 644 {} ;

i get: find: missing argument to `-exec' thanks

This question is related to magento ssh find chmod

The answer is


A good alternative is this:

find . -type f | xargs chmod -v 644

and for directories:

find . -type d | xargs chmod -v 755

and to be more explicit:

find . -type f | xargs -I{} chmod -v 644 {}

I need this so often that I created a function in my ~/.bashrc file:

chmodf() {
        find $2 -type f -exec chmod $1 {} \;
}
chmodd() {
        find $2 -type d -exec chmod $1 {} \;
}

Now I can use these shortcuts:

chmodd 0775 .
chmodf 0664 .

Piping to xargs is a dirty way of doing that which can be done inside of find.

find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;

You can be even more controlling with other options, such as:

find . -type d -user harry -exec chown daisy {} \;

You can do some very cool things with find and you can do some very dangerous things too. Have a look at "man find", it's long but is worth a quick read. And, as always remember:

  • If you are root it will succeed.
  • If you are in root (/) you are going to have a bad day.
  • Using /path/to/directory can make things a lot safer as you are clearly defining where you want find to run.

Examples related to magento

Where are Magento's log files located? find . -type f -exec chmod 644 {} ; Get product id and product type in magento? There has been an error processing your request, Error log record number Class 'DOMDocument' not found Magento: Set LIMIT on collection How to remove index.php from URLs? Get skin path in Magento? SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1922-1' for key 'IDX_STOCK_PRODUCT' Service Temporarily Unavailable Magento?

Examples related to ssh

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058" How to solve "sign_and_send_pubkey: signing failed: agent refused operation"? key_load_public: invalid format ssh connection refused on Raspberry Pi Getting permission denied (public key) on gitlab Verify host key with pysftp Can't connect to Postgresql on port 5432 Checkout Jenkins Pipeline Git SCM with credentials? How to open remote files in sublime text 3 how to setup ssh keys for jenkins to publish via ssh

Examples related to find

Find a file by name in Visual Studio Code Explaining the 'find -mtime' command find files by extension, *.html under a folder in nodejs MongoDB Show all contents from all collections How can I find a file/directory that could be anywhere on linux command line? Get all files modified in last 30 days in a directory FileNotFoundError: [Errno 2] No such file or directory Linux find and grep command together find . -type f -exec chmod 644 {} ; Find all stored procedures that reference a specific column in some table

Examples related to chmod

changing the owner of folder in linux find . -type f -exec chmod 644 {} ; Differences between CHMOD 755 vs 750 permissions set Change all files and folders permissions of a directory to 644/755 Difference between using "chmod a+x" and "chmod 755" Correct file permissions for WordPress Python module os.chmod(file, 664) does not change the permission to rw-rw-r-- but -w--wx---- Chmod recursively Chmod 777 to a folder and all contents File Permissions and CHMOD: How to set 777 in PHP upon file creation?