Wednesday, April 27, 2022

[SOLVED] Modify permissions for scripts recursively

Issue

Trying to set permissions recursively for multiple scripts:

chmod -R /export/home/*.sh

But some files do not have .sh extension, e.g. .ksh and some scripts have no extension at all.

How can I make all scripts/files executable? (any type, extension or not)


Solution

This command should do the trick:

find /export/home -type f -exec chmod +x {} \;

However, I don't think you really want to make all files executable - there is significant security risk in this. You'd be better off just determining what files should be executable, or putting them in a "bin/" subdirectory, which you could then search for:

find /export/home -type d -name bin -exec chmod -R +x {} \;


Answered By - Virtually Nick
Answer Checked By - Willingham (WPSolving Volunteer)